本文整理汇总了C++中VariableIdMapping类的典型用法代码示例。如果您正苦于以下问题:C++ VariableIdMapping类的具体用法?C++ VariableIdMapping怎么用?C++ VariableIdMapping使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了VariableIdMapping类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char* argv[]) {
cout << "INIT: Parsing and creating AST."<<endl;
SgProject* sageProject = frontend(argc,argv);
VariableIdMapping variableIdMapping;
variableIdMapping.computeVariableSymbolMapping(sageProject);
Labeler labeler(sageProject,&variableIdMapping);
CFAnalyzer cfanalyzer(&labeler);
RDAnalyzer rdAnalyzer(&cfanalyzer);
rdAnalyzer.initialize();
rdAnalyzer.run();
return 0;
}
开发者ID:adrian-prantl,项目名称:rose,代码行数:12,代码来源:rdmain.C
示例2: checkLargeSets
void checkLargeSets() {
VariableIdMapping variableIdMapping;
VariableId var_x=variableIdMapping.createUniqueTemporaryVariableId("x");
AType::ConstIntLattice i;
using namespace AType;
set<CppCapsuleConstIntLattice> cilSet;
cilSet.insert(CppCapsuleConstIntLattice(ConstIntLattice(Bot())));
cilSet.insert(CppCapsuleConstIntLattice(ConstIntLattice(Top())));
for(int i=-10;i<10;i++) {
cilSet.insert(CppCapsuleConstIntLattice(ConstIntLattice(i)));
}
check("integer set: bot,-10, ... ,+10,top",cilSet.size()==22); // 1+20+1
}
开发者ID:adrian-prantl,项目名称:edg4x-rose,代码行数:13,代码来源:InternalChecks.C
示例3: printCodeStatistics
void printCodeStatistics(SgNode* root) {
SgProject* project=isSgProject(root);
VariableIdMapping variableIdMapping;
variableIdMapping.computeVariableSymbolMapping(project);
VariableIdSet setOfUsedVars=AnalysisAbstractionLayer::usedVariablesInsideFunctions(project,&variableIdMapping);
DeadCodeElimination dce;
cout<<"----------------------------------------------------------------------"<<endl;
cout<<"Statistics:"<<endl;
cout<<"Number of empty if-statements: "<<dce.listOfEmptyIfStmts(root).size()<<endl;
cout<<"Number of functions : "<<SgNodeHelper::listOfFunctionDefinitions(project).size()<<endl;
cout<<"Number of global variables : "<<SgNodeHelper::listOfGlobalVars(project).size()<<endl;
cout<<"Number of used variables : "<<setOfUsedVars.size()<<endl;
cout<<"----------------------------------------------------------------------"<<endl;
cout<<"VariableIdMapping-size : "<<variableIdMapping.getVariableIdSet().size()<<endl;
cout<<"----------------------------------------------------------------------"<<endl;
}
开发者ID:8l,项目名称:rose,代码行数:16,代码来源:woodpecker.C
示例4: analyzeVariableDeclaration
VariableValuePair FIConstAnalysis::analyzeVariableDeclaration(SgVariableDeclaration* decl,VariableIdMapping& varIdMapping) {
SgNode* initName0=decl->get_traversalSuccessorByIndex(1); // get-InitializedName
if(initName0) {
if(SgInitializedName* initName=isSgInitializedName(initName0)) {
SgSymbol* initDeclVar=initName->search_for_symbol_from_symbol_table();
assert(initDeclVar);
VariableId initDeclVarId=varIdMapping.variableId(initDeclVar);
SgInitializer* initializer=initName->get_initializer();
SgAssignInitializer* assignInitializer=0;
if(initializer && (assignInitializer=isSgAssignInitializer(initializer))) {
if(detailedOutput) cout << "initializer found:"<<endl;
SgExpression* rhs=assignInitializer->get_operand_i();
assert(rhs);
return VariableValuePair(initDeclVarId,analyzeAssignRhs(rhs));
} else {
if(detailedOutput) cout << "no initializer (OK)."<<endl;
return VariableValuePair(initDeclVarId,AType::Top());
}
} else {
cerr << "Error: in declaration (@initializedName) no variable found ... bailing out."<<endl;
exit(1);
}
} else {
cerr << "Error: in declaration: no variable found ... bailing out."<<endl;
exit(1);
}
}
开发者ID:alexjohn1362,项目名称:rose,代码行数:27,代码来源:FIConstAnalysis.C
示例5: astSubTreeVariables
VariableIdSet AnalysisAbstractionLayer::astSubTreeVariables(SgNode* node, VariableIdMapping& vidm) {
VariableIdSet vset;
RoseAst ast(node);
for(RoseAst::iterator i=ast.begin();i!=ast.end();++i) {
VariableId vid; // default creates intentionally an invalid id.
if(SgVariableDeclaration* varDecl=isSgVariableDeclaration(*i)) {
vid=vidm.variableId(varDecl);
} else if(SgVarRefExp* varRefExp=isSgVarRefExp(*i)) {
vid=vidm.variableId(varRefExp);
} else if(SgInitializedName* initName=isSgInitializedName(*i)) {
vid=vidm.variableId(initName);
}
if(vid.isValid())
vset.insert(vid);
}
return vset;
}
开发者ID:Federico2014,项目名称:edg4x-rose,代码行数:17,代码来源:AnalysisAbstractionLayer.C
示例6: addAllArrayElements
void DefUseVarsInfo::addAllArrayElements(SgInitializedName* array_name, VariableIdMapping& vidm, bool def)
{
assert(array_name);
VariableId array_var_id = vidm.variableId(array_name);
SgArrayType* array_type = isSgArrayType(array_name->get_type());
if (!array_type)
return;
int elements = vidm.getArrayElementCount(array_type);
if (!elements)
elements = vidm.getArrayDimensionsFromInitializer(isSgAggregateInitializer(array_name->get_initializer()));
VarsInfo& info = (def ? def_vars_info : use_vars_info);
VariableIdTypeInfo sgn_type_info_elem = getVariableIdTypeInfo(array_var_id, vidm);
for (int e = 0; e < elements; e++) {
VariableId element_id = vidm.variableIdOfArrayElement(array_var_id, e);
info.first.insert(VariableIdInfo(element_id, sgn_type_info_elem));
}
}
开发者ID:billhoffman,项目名称:rose-develop,代码行数:17,代码来源:defUseQuery.C
示例7: determineVariable
bool FIConstAnalysis::determineVariable(SgNode* node, VariableId& varId, VariableIdMapping& _variableIdMapping) {
assert(node);
if(SgVarRefExp* varref=isSgVarRefExp(node)) {
// found variable
//assert(_variableIdMapping);
#if 1
SgSymbol* sym=varref->get_symbol();
ROSE_ASSERT(sym);
varId=_variableIdMapping.variableId(sym);
#else
// MS: to investigate: even with the new var-sym-only case this does not work
// MS: investigage getSymbolOfVariable
varId=_variableIdMapping.variableId(varref);
#endif
return true;
} else {
VariableId defaultVarId;
varId=defaultVarId;
return false;
}
}
开发者ID:alexjohn1362,项目名称:rose,代码行数:21,代码来源:FIConstAnalysis.C
示例8:
std::string SPRAY::VariableIdSetPrettyPrint::str(VariableIdSet& vset, VariableIdMapping& vidm)
{
std::ostringstream ostr;
ostr << "[";
VariableIdSet::iterator it = vset.begin();
for( ; it != vset.end(); )
{
ostr << "<" << (*it).toString() << ", " << vidm.variableName(*it) << ">";
it++;
if(it != vset.end())
ostr << ", ";
}
ostr << "]";
return ostr.str();
}
开发者ID:8l,项目名称:rose,代码行数:15,代码来源:VariableIdUtils.C
示例9: computeVarConstValues
VarConstSetMap FIConstAnalysis::computeVarConstValues(SgProject* project, SgFunctionDefinition* mainFunctionRoot, VariableIdMapping& variableIdMapping) {
VarConstSetMap varConstIntMap;
VariableIdSet varIdSet=AnalysisAbstractionLayer::usedVariablesInsideFunctions(project,&variableIdMapping);
// initialize map such that it is resized to number of variables of interest
for(VariableIdSet::iterator i=varIdSet.begin(); i!=varIdSet.end(); ++i) {
set<CppCapsuleConstIntLattice> emptySet;
varConstIntMap[*i]=emptySet;
}
cout<<"STATUS: Initialized const map for "<<varConstIntMap.size()<< " variables."<<endl;
cout << "STATUS: Number of global variables: ";
list<SgVariableDeclaration*> globalVars=SgNodeHelper::listOfGlobalVars(project);
cout << globalVars.size()<<endl;
VariableIdSet setOfUsedVars=AnalysisAbstractionLayer::usedVariablesInsideFunctions(project,&variableIdMapping);
cout << "STATUS: Number of used variables: "<<setOfUsedVars.size()<<endl;
#if 0
int filteredVars=0;
set<CppCapsuleConstIntLattice> emptySet;
for(list<SgVariableDeclaration*>::iterator i=globalVars.begin(); i!=globalVars.end(); ++i) {
VariableId globalVarId=variableIdMapping.variableId(*i);
if(setOfUsedVars.find(globalVarId)!=setOfUsedVars.end()) {
VariableValuePair p=analyzeVariableDeclaration(*i,variableIdMapping);
ConstIntLattice varValue=p.varValue;
varConstIntMap[p.varId]=emptySet; // create mapping
varConstIntMap[p.varId].insert(CppCapsuleConstIntLattice(varValue));
variablesOfInterest.insert(p.varId);
//set<CppCapsuleConstIntLattice>& myset=varConstIntMap[p.varId];
} else {
filteredVars++;
}
}
cout << "STATUS: Number of filtered variables for initial state: "<<filteredVars<<endl;
#endif
variablesOfInterest=setOfUsedVars;
if(mainFunctionRoot!=0) {
determineVarConstValueSet(mainFunctionRoot,variableIdMapping,varConstIntMap);
} else {
// compute value-sets for entire program (need to cover all functions without inlining)
determineVarConstValueSet(project,variableIdMapping,varConstIntMap);
}
return varConstIntMap;
}
开发者ID:alexjohn1362,项目名称:rose,代码行数:44,代码来源:FIConstAnalysis.C
示例10: getVariableIdTypeInfo
VariableIdTypeInfo getVariableIdTypeInfo(VariableId vid, VariableIdMapping& vidm)
{
SgSymbol* symb = vidm.getSymbol(vid); ROSE_ASSERT(symb);
SgType* sgn_type = symb->get_type();
VariableIdTypeInfo sgn_type_info;
if(isSgArrayType(sgn_type))
sgn_type_info = arrayType;
else if(isSgPointerType(sgn_type))
sgn_type_info = pointerType;
else if(isSgReferenceType(sgn_type))
sgn_type_info = referenceType;
else if(isSgClassType(sgn_type))
sgn_type_info = classType;
else
sgn_type_info = variableType;
return sgn_type_info;
}
开发者ID:billhoffman,项目名称:rose-develop,代码行数:19,代码来源:defUseQuery.C
示例11: varsInfoPrettyPrint
std::string DefUseVarsInfo::varsInfoPrettyPrint(VarsInfo& vars_info, VariableIdMapping& vidm)
{
std::ostringstream oss;
oss << "[" << (vars_info.second? "true" : "false") << ", ";
oss << "{";
VariableIdInfoMap::iterator it = vars_info.first.begin();
for( ; it != vars_info.first.end(); )
{
// oss << "<" << (*it).first.toString() << ", " << vidm.variableName((*it).first) << ", ";
oss << "<" << vidm.uniqueShortVariableName((*it).first) << ", " << variableIdTypeInfoToString((*it).second);
oss <<">";
it++;
if(it != vars_info.first.end())
oss << ", ";
}
oss << "}";
oss <<"]";
return oss.str();
}
开发者ID:billhoffman,项目名称:rose-develop,代码行数:19,代码来源:defUseQuery.C
示例12: printResult
void printResult(VariableIdMapping& variableIdMapping, VarConstSetMap& map) {
cout<<"Result:"<<endl;
VariableConstInfo vci(&variableIdMapping, &map);
for(VarConstSetMap::iterator i=map.begin();i!=map.end();++i) {
VariableId varId=(*i).first;
//string variableName=variableIdMapping.uniqueShortVariableName(varId);
string variableName=variableIdMapping.variableName(varId);
set<ConstIntLattice> valueSet=(*i).second;
stringstream setstr;
setstr<<"{";
for(set<ConstIntLattice>::iterator i=valueSet.begin();i!=valueSet.end();++i) {
if(i!=valueSet.begin())
setstr<<",";
setstr<<(*i).toString();
}
setstr<<"}";
cout<<variableName<<"="<<setstr.str()<<";";
#if 1
cout<<"Range:"<<VariableConstInfo::createVariableValueRangeInfo(varId,map).toString();
cout<<" width: "<<VariableConstInfo::createVariableValueRangeInfo(varId,map).width().toString();
cout<<" top: "<<VariableConstInfo::createVariableValueRangeInfo(varId,map).isTop();
cout<<endl;
#endif
cout<<" isAny:"<<vci.isAny(varId)
<<" isUniqueConst:"<<vci.isUniqueConst(varId)
<<" isMultiConst:"<<vci.isMultiConst(varId);
if(vci.isUniqueConst(varId)||vci.isMultiConst(varId)) {
cout<<" width:"<<vci.width(varId);
} else {
cout<<" width:unknown";
}
cout<<" Test34:"<<vci.isInConstSet(varId,34);
cout<<endl;
}
cout<<"---------------------"<<endl;
}
开发者ID:8l,项目名称:rose,代码行数:36,代码来源:woodpecker.C
示例13: checkTypes
void checkTypes() {
VariableIdMapping variableIdMapping;
PState s1;
cout << "RUNNING CHECKS:"<<endl;
{
// check temporary variables (create and delete)
VariableId var_tmp=variableIdMapping.createUniqueTemporaryVariableId("tmp");
variableIdMapping.deleteUniqueTemporaryVariableId(var_tmp);
}
{
cout << "------------------------------------------"<<endl;
cout << "RUNNING CHECKS FOR BOOLLATTICE TYPE:"<<endl;
AType::BoolLattice a;
a=true;
check("a=true => isTrue",a.isTrue());
AType::BoolLattice b;
b=false;
check("b=false => isFalse",b.isFalse());
AType::BoolLattice c=a||b;
check("c=a||b => c isTrue ",c.isTrue());
AType::Top e;
AType::BoolLattice d;
d=e;
check("Top e; d=e => d isTop",d.isTop());
c=c||d;
check("c=c||d: true",c.isTrue());
AType::BoolLattice f=AType::Bot();
d=AType::Bot();
check("d=bot: bot",d.isBot());
check("f=bot: bot",f.isBot());
a=d&&f;
check("a=d&&f => a isBot",a.isBot());
f=false;
check("f=false => f isFalse",f.isFalse());
a=d&&f;
check("a=d&&f: a isFalse (we define it this way)",a.isFalse());
}
{
cout << "RUNNING CHECKS FOR CONSTINT LATTICE TYPE:"<<endl;
AType::ConstIntLattice a;
a=true;
check("a=true => isTrue",a.isTrue());
check("a=true => !isFalse",!a.isFalse());
AType::ConstIntLattice b;
b=false;
check("b=false => isFalse",b.isFalse());
check("b=false => !isTrue",!b.isTrue());
AType::ConstIntLattice c=a.operatorOr(b);
check("c=a.operatorOr(b): ",c.isTrue());
AType::Top e;
AType::ConstIntLattice d;
d=e;
check("Top e; d=e; d isTop ",d.isTop());
c=c.operatorOr(d);
check("c=c.operatorOr(d) => c isTrue ",c.isTrue());
AType::ConstIntLattice f=AType::Bot();
d=AType::Bot();
a=d.operatorAnd(f);
check("d=bot;f=bot;a=d.operatorAnd(f); => a isBot",a.isBot());
f=false;
a=d.operatorAnd(f);
check("f=false; a=d.operatorAnd(f); => a isFalse",a.isFalse());
a=5;
check("a=5; a.isTrue()==true",a.isTrue()==true);
check("a=5; a.isFalse()==false",a.isFalse()==false);
a=0;
check("a=0; a.isTrue()==false",a.isTrue()==false);
check("a=0; a.isFalse())==true",a.isFalse()==true);
}
{
cout << "------------------------------------------"<<endl;
cout << "RUNNING CHECKS FOR CONSTRAINT TYPE:"<<endl;
VariableId var_x=variableIdMapping.createUniqueTemporaryVariableId("x");
VariableId var_y=variableIdMapping.createUniqueTemporaryVariableId("y");
cout << "P1"<<endl;
Constraint c1(Constraint::EQ_VAR_CONST,var_x,1);
cout << "P2"<<endl;
Constraint c2(Constraint::NEQ_VAR_CONST,var_y,2);
cout << "P3"<<endl;
Constraint c3=DISEQUALITYCONSTRAINT;
cout << "P4"<<endl;
Constraint c4=Constraint(Constraint::EQ_VAR_CONST,var_y,2);
cout << "P5"<<endl;
ConstraintSet cs;
cout << "P6"<<endl;
cs.addConstraint(c1);
cout << "P7"<<endl;
cout << "CS1:"<<cs.toString()<<endl;
cs.addConstraint(c2);
cout << "CS2:"<<cs.toString()<<endl;
check("inserted 2 different constraints, size of constraint set == 3",cs.size()==2);
check("c1:constraintExists(EQ_VAR_CONST,x,1) == true",cs.constraintExists(Constraint::EQ_VAR_CONST,var_x,1));
check("c1:constraintExists(NEQ_VAR_CONST,x,1) == false",!cs.constraintExists(Constraint::NEQ_VAR_CONST,var_x,1));
check("c2:constraintExists(NEQ_VAR_CONST,y,2) == true",cs.constraintExists(Constraint::NEQ_VAR_CONST,var_y,2));
check("c3:isDisequality==false",cs.disequalityExists()==false);
//.........这里部分代码省略.........
开发者ID:8l,项目名称:rose,代码行数:101,代码来源:InternalChecks.C
示例14: main
//.........这里部分代码省略.........
// clean up string-options in argv
for (int i=1; i<argc; ++i) {
if (string(argv[i]) == "--csv-assert"
|| string(argv[i]) == "--csv-const-result"
) {
// do not confuse ROSE frontend
argv[i] = strdup("");
assert(i+1<argc);
argv[i+1] = strdup("");
}
}
global_option_multiconstanalysis=boolOptions["enable-multi-const-analysis"];
#if 0
if(global_option_multiconstanalysis) {
cout<<"INFO: Using flow-insensitive multi-const-analysis."<<endl;
} else {
cout<<"INFO: Using flow-insensitive unique-const-analysis."<<endl;
}
#endif
cout << "INIT: Parsing and creating AST started."<<endl;
SgProject* root = frontend(argc,argv);
// AstTests::runAllTests(root);
// inline all functions
cout << "INIT: Parsing and creating AST finished."<<endl;
if(args.count("stats")) {
printCodeStatistics(root);
exit(0);
}
VariableIdMapping variableIdMapping;
variableIdMapping.computeVariableSymbolMapping(root);
if(args.count("transform-thread-variable")) {
Threadification* threadTransformation=new Threadification(&variableIdMapping);
threadTransformation->transform(root);
root->unparse(0,0);
delete threadTransformation;
cout<<"STATUS: generated program with introduced thread-variable."<<endl;
exit(0);
}
SgFunctionDefinition* mainFunctionRoot=0;
if(boolOptions["inline"]) {
cout<<"STATUS: eliminating non-called trivial functions."<<endl;
// inline functions
TrivialInlining tin;
tin.setDetailedOutput(detailedOutput);
tin.inlineFunctions(root);
DeadCodeElimination dce;
// eliminate non called functions
int numEliminatedFunctions=dce.eliminateNonCalledTrivialFunctions(root);
cout<<"STATUS: eliminated "<<numEliminatedFunctions<<" functions."<<endl;
} else {
cout<<"INFO: Inlining: turned off."<<endl;
}
if(boolOptions["eliminate-empty-if"]) {
DeadCodeElimination dce;
cout<<"STATUS: Eliminating empty if-statements."<<endl;
size_t num=0;
size_t numTotal=num;
do {
开发者ID:8l,项目名称:rose,代码行数:67,代码来源:woodpecker.C
示例15: runAnalyses
void runAnalyses(SgProject* root, Labeler* labeler, VariableIdMapping* variableIdMapping) {
SPRAY::DFAnalysisBase::normalizeProgram(root);
if(option_fi_constanalysis) {
VarConstSetMap varConstSetMap;
FIConstAnalysis fiConstAnalysis(variableIdMapping);
fiConstAnalysis.runAnalysis(root);
fiConstAnalysis.attachAstAttributes(labeler,"const-analysis-inout"); // not iolabeler
if(csvConstResultFileName) {
cout<<"INFO: generating const CSV file "<<option_prefix+csvConstResultFileName<<endl;
fiConstAnalysis.writeCvsConstResult(*variableIdMapping, option_prefix+csvConstResultFileName);
}
cout << "INFO: annotating analysis results as comments."<<endl;
AstAnnotator ara(labeler);
ara.annotateAstAttributesAsCommentsBeforeStatements(root, "const-analysis-inout");
ara.annotateAstAttributesAsCommentsAfterStatements(root, "const-analysis-inout");
}
if(option_at_analysis) {
cout<<"STATUS: running address taken analysis."<<endl;
cout << "STATUS: computing variable and function mappings."<<endl;
// compute variableId mappings
VariableIdMapping variableIdMapping;
variableIdMapping.computeVariableSymbolMapping(root);
// Compute function id mappings:
FunctionIdMapping functionIdMapping;
functionIdMapping.computeFunctionSymbolMapping(root);
if(option_trace) {
std::cout << std::endl << "TRACE: Variable Id Mapping:" << std::endl;
variableIdMapping.toStream(std::cout);
std::cout << std::endl << "TRACE: Function Id Mapping:" << std::endl;
functionIdMapping.toStream(std::cout);
}
cout << "STATUS: computing address taken sets."<<endl;
SPRAY::FIPointerAnalysis fipa(&variableIdMapping, &functionIdMapping, root);
fipa.initialize();
fipa.run();
//cout << "STATUS: computed address taken sets:"<<endl;
//fipa.getFIPointerInfo()->printInfoSets();
bool createCsv = false;
ofstream addressTakenCsvFile;
if(csvAddressTakenResultFileName) {
std::string addressTakenCsvFileName = option_prefix;
addressTakenCsvFileName += csvAddressTakenResultFileName;
addressTakenCsvFile.open(addressTakenCsvFileName.c_str());
createCsv = true;
}
cout << "INFO: annotating declarations of address taken variables and functions."<<endl;
// Annotate declarations/definitions of variables from which the address was taken:
VariableIdSet addressTakenVariableIds = fipa.getAddressTakenVariables();
for(VariableIdSet::const_iterator idIter = addressTakenVariableIds.begin(); idIter != addressTakenVariableIds.end(); ++idIter) {
// Determine the variable declaration/definition:
SgLocatedNode* decl = variableIdMapping.getVariableDeclaration(*idIter);
if(!decl) {
// The current variable is presumably a function parameter: Try to get the initialized name:
SgVariableSymbol* varSymbol = isSgVariableSymbol(variableIdMapping.getSymbol(*idIter));
ROSE_ASSERT(varSymbol);
SgInitializedName* paramDecl = isSgInitializedName(varSymbol->get_declaration());
// We should not have a real variable declaration for the parameter:
ROSE_ASSERT(isSgFunctionParameterList(paramDecl->get_declaration()));
// Use the InitializedName:
decl = paramDecl;
}
if(decl) {
// Create the comment:
ostringstream commentStream;
commentStream << "/* Address of \"" << variableIdMapping.variableName(*idIter) << "\" is "
<< "presumably taken.*/";
// Annotate first declaration:
insertComment(commentStream.str(), PreprocessingInfo::before, decl);
// TODO: Annotate other declarations too!
// Annotate definition if available (e.g. not available in case of parameter):
if(SgDeclarationStatement* variableDeclaration = isSgDeclarationStatement(decl)) {
if(SgDeclarationStatement* definingDeclaration = variableDeclaration->get_definingDeclaration()) {
insertComment(commentStream.str(), PreprocessingInfo::before, definingDeclaration);
}
}
if(createCsv) {
// Write variable info to csv:
addressTakenCsvFile << VariableId::idKindIndicator << ","
// The id of the variable (id codes are influenced by the used system headers
// and are therefore not stable/portable):
<< (option_csv_stable ? string("<unstable>") : int_to_string((*idIter).getIdCode())) << ","
// Name of the variable:
<< variableIdMapping.variableName(*idIter) << ","
// TODO: Mangled scope and type are currently not stable/portable
// (see comments in getScopeAsMangledStableString(...))
//.........这里部分代码省略.........
开发者ID:ian-bertolacci,项目名称:rose-develop,代码行数:101,代码来源:analyterix.C
示例16: main
//.........这里部分代码省略.........
option_prefix=args["prefix"].as<string>().c_str();
}
if (args.count("trace")) {
option_trace=true;
}
if(args.count("stats")) {
option_stats=true;
}
if(args.count("rd-analysis")) {
option_rd_analysis=true;
}
if(args.count("lv-analysis")) {
option_lv_analysis=true;
}
if(args.count("interval-analysis")) {
option_interval_analysis=true;
}
if(args.count("ud-analysis")) {
option_rd_analysis=true; // required
option_ud_analysis=true;
}
if(args.count("rose-rd-analysis")) {
option_rose_rd_analysis=true;
}
if(args.count("fi-constanalysis")) {
option_fi_constanalysis=true;
}
if (args.count("csv-fi-constanalysis")) {
csvConstResultFileName=args["csv-fi-constanalysis"].as<string>().c_str();
option_fi_constanalysis=true;
}
if(args.count("at-analysis")) {
option_at_analysis=true;
}
// clean up string-options in argv
for (int i=1; i<argc; ++i) {
if (string(argv[i]) == "--prefix"
|| string(argv[i]) == "--csv-const-result"
) {
// do not confuse ROSE frontend
argv[i] = strdup("");
assert(i+1<argc);
argv[i+1] = strdup("");
}
}
cout << "INIT: Parsing and creating AST."<<endl;
boolOptions.registerOption("semantic-fold",false); // temporary
boolOptions.registerOption("post-semantic-fold",false); // temporary
SgProject* root = frontend(argc,argv);
// AstTests::runAllTests(root);
if(option_stats) {
SPRAY::ProgramStatistics::printBasicCodeInfo(root);
}
cout<<"STATUS: computing variableid mapping"<<endl;
VariableIdMapping variableIdMapping;
if (args.count("print-varidmapping-array")) {
variableIdMapping.setModeVariableIdForEachArrayElement(true);
}
variableIdMapping.computeVariableSymbolMapping(root);
cout<<"VariableIdMapping size: "<<variableIdMapping.getVariableIdSet().size()<<endl;
Labeler* labeler=new Labeler(root);
//cout<<"Labelling:\n"<<labeler->toString()<<endl;
#if 0
IOLabeler* iolabeler=new IOLabeler(root,&variableIdMapping);
//cout<<"IOLabelling:\n"<<iolabeler->toString()<<endl;
#endif
if (args.count("print-varidmapping")||args.count("print-varidmapping-array")) {
variableIdMapping.toStream(cout);
}
runAnalyses(root, labeler, &variableIdMapping);
cout << "INFO: generating annotated source code."<<endl;
root->unparse(0,0);
if(option_rose_rd_analysis) {
Experimental::RoseRDAnalysis::generateRoseRDDotFiles(labeler,root);
}
cout<< "STATUS: finished."<<endl;
// main function try-catch
} catch(char* str) {
cerr << "*Exception raised: " << str << endl;
return 1;
} catch(const char* str) {
cerr << "Exception raised: " << str << endl;
return 1;
} catch(string str) {
cerr << "Exception raised: " << str << endl;
return 1;
}
return 0;
}
开发者ID:iN3O,项目名称:edg4x-rose,代码行数:101,代码来源:analyterix.C
示例17: writeCvsConstResult
/* format: varname, isAny, isUniqueconst, isMultiConst, width(>=1 or 0 or -1 (for any)), min, max, numBits, "{...}"
*/
void FIConstAnalysis::writeCvsConstResult(VariableIdMapping& variableIdMapping, string filename) {
ofstream myfile;
myfile.open(filename.c_str());
// cout<<"Result:"<<endl;
//VariableConstInfo vci(&variableIdMapping, &map);
for(VarConstSetMap::iterator i=_varConstSetMap.begin(); i!=_varConstSetMap.end(); ++i) {
VariableId varId=(*i).first;
//string variableName=variableIdMapping.uniqueShortVariableName(varId);
string variableName=variableIdMapping.variableName(varId);
myfile<<variableName;
myfile<<",";
myfile<<global_variableConstInfo->isAny(varId);
myfile<<",";
myfile<<global_variableConstInfo->isUniqueConst(varId);
myfile<<",";
myfile<<global_variableConstInfo->isMultiConst(varId);
myfile<<",";
if(global_variableConstInfo->isUniqueConst(varId)||global_variableConstInfo->isMultiConst(varId)) {
myfile<<global_variableConstInfo->minConst(varId);
myfile<<",";
myfile<<global_variableConstInfo->maxConst(varId);
size_t mywidth=global_variableConstInfo->width(varId);
assert(mywidth==(size_t)global_variableConstInfo->maxConst(varId)-global_variableConstInfo->minConst(varId)+1);
int mylog2=log2(mywidth);
// compute upper whole number
int bits=-1;
// casts on pow args to ensure that the correct overloaded C++ cmath function is selected
if(mywidth==static_cast<size_t>(pow(2.0,(double)mylog2))) {
if(mylog2==0)
bits=1;
else
bits=mylog2;
} else {
bits=mylog2+1;
}
assert(bits!=-1);
myfile<<",";
myfile<<bits;
} else {
myfile<<INT_MIN
<<","
<<INT_MAX
<<","
<<sizeof(int)*8;
}
myfile<<",";
// TODO: print array size
// myfile<<",";
SgType* varType=variableIdMapping.getType(varId);
if(isSgArrayType(varType))
myfile<<"CA_ARRAY";
else if(isSgPointerType(varType))
myfile<<"CA_PTR";
else if(isSgTypeInt(varType))
myfile<<"CA_INT";
else
myfile<<"CA_UNKNOWN";
myfile<<",";
//myfile<<arraySize<<",";
#if 1
set<CppCapsuleConstIntLattice> valueSet=(*i).second;
stringstream setstr;
myfile<<"{";
for(set<CppCapsuleConstIntLattice>::iterator i=valueSet.begin(); i!=valueSet.end(); ++i) {
if(i!=valueSet.begin())
myfile<<",";
myfile<<(*i).getValue().toString();
}
myfile<<"}";
#endif
myfile<<endl;
}
myfile.close();
}
开发者ID:alexjohn1362,项目名称:rose,代码行数:79,代码来源:FIConstAnalysis.C
示例18: runAnalyses
void runAnalyses(SgProject* root, Labeler* labeler, VariableIdMapping* variableIdMapping) {
SPRAY::DFAnalysisBase::normalizeProgram(root);
if(option_fi_constanalysis) {
VarConstSetMap varConstSetMap;
FIConstAnalysis fiConstAnalysis(variableIdMapping);
fiConstAnalysis.runAnalysis(root);
fiConstAnalysis.attachAstAttributes(labeler,"const-analysis-inout"); // not iolabeler
if(csvConstResultFileName) {
cout<<"INFO: generating const CSV file "<<option_prefix+csvConstResultFileName<<endl;
fiConstAnalysis.writeCvsConstResult(*variableIdMapping, option_prefix+csvConstResultFileName);
}
cout << "INFO: annotating analysis results as comments."<<endl;
AstAnnotator ara(labeler);
ara.annotateAstAttributesAsCommentsBeforeStatements(root, "const-analysis-inout");
ara.annotateAstAttributesAsCommentsAfterStatements(root, "const-analysis-inout");
}
if(option_at_analysis) {
cout<<"STATUS: running address taken analysis."<<endl;
// compute variableId mappings
VariableIdMapping variableIdMapping;
variableIdMapping.computeVariableSymbolMapping(root);
SPRAY::FIPointerAnalysis fipa(&variableIdMapping,root);
fipa.initialize();
fipa.run();
#if 0
VariableIdSet vidset=fipa.getModByPointer();
cout<<"mod-set: "<<SPRAY::VariableIdSetPrettyPrint::str(vidset,variableIdMapping)<<endl;
#endif
}
if(option_interval_analysis) {
cout << "STATUS: creating interval analyzer."<<endl;
SPRAY::IntervalAnalysis* intervalAnalyzer=new SPRAY::IntervalAnalysis();
cout << "STATUS: initializing interval analyzer."<<endl;
intervalAnalyzer->initialize(root);
cout << "STATUS: initializing interval transfer functions."<<endl;
intervalAnalyzer->initializeTransferFunctions();
cout << "STATUS: initializing interval global variables."<<endl;
intervalAnalyzer->initializeGlobalVariables(root);
intervalAnalyzer->setSolverTrace(option_trace);
std::string funtofind="main";
RoseAst completeast(root);
SgFunctionDefinition* startFunRoot=completeast.findFunctionByName(funtofind);
intervalAnalyzer->determineExtremalLabels(startFunRoot);
intervalAnalyzer->run();
#if 0
intervalAnalyzer->attachInInfoToAst("iv-analysis-in");
intervalAnalyzer->attachOutInfoToAst("iv-analysis-out");
AstAnnotator ara(intervalAnalyzer->getLabeler(),intervalAnalyzer->getVariableIdMapping());
ara.annotateAstAttributesAsCommentsBeforeStatements(root, "iv-analysis-in");
ara.annotateAstAttributesAsCommentsAfterStatements(root, "iv-analysis-out");
#else
AnalysisAstAnnotator ara(intervalAnalyzer->getLabeler(),intervalAnalyzer->getVariableIdMapping());
ara.annotateAnalysisPrePostInfoAsComments(root,"iv-analysis",intervalAnalyzer);
#endif
}
if(option_lv_analysis) {
cout << "STATUS: creating LV analysis."<<endl;
SPRAY::LVAnalysis* lvAnalysis=new SPRAY::LVAnalysis();
cout << "STATUS: initializing LV analysis."<<endl;
lvAnalysis->setBackwardAnalysis();
lvAnalysis->initialize(root);
cout << "STATUS: initializing LV transfer functions."<<endl;
lvAnalysis->initializeTransferFunctions();
cout << "STATUS: initializing LV global variables."<<endl;
lvAnalysis->initializeGlobalVariables(root);
std::string funtofind="main";
RoseAst completeast(root);
SgFunctionDefinition* startFunRoot=completeast.findFunctionByName(funtofind);
cout << "generating icfg_backward.dot."<<endl;
write_file("icfg_backward.dot", lvAnalysis->getFlow()->toDot(lvAnalysis->getLabeler()));
lvAnalysis->determineExtremalLabels(startFunRoot);
lvAnalysis->run();
cout << "INFO: attaching LV-data to AST."<<endl;
#if 0
lvAnalysis->attachInInfoToAst("lv-analysis-in");
lvAnalysis->attachOutInfoToAst("lv-analysis-out");
AstAnnotator ara(lvAnalysis->getLabeler(),lvAnalysis->getVariableIdMapping());
ara.annotateAstAttributesAsCommentsBeforeStatements(root, "lv-analysis-in");
ara.annotateAstAttributesAsCommentsAfterStatements(root, "lv-analysis-out");
#else
AnalysisAstAnnotator ara(lvAnalysis->getLabeler(),lvAnalysis->getVariableIdMapping());
ara.annotateAnalysisPrePostInfoAsComments(root,"lv-analysis",lvAnalysis);
#endif
delete lvAnalysis;
}
if(option_rd_analysis) {
cout << "STATUS: creating RD analyzer."<<endl;
SPRAY::RDAnalysis* rdAnalysis=new SPRAY::RDAnalysis();
cout << "STATUS: initializing RD analyzer."<<endl;
rdAnalysis->initialize(root);
cout << "STATUS: initializing RD transfer functions."<<endl;
//.........这里部分代码省略.........
开发者ID:iN3O,项目名称:edg4x-rose,代码行数:101,代码来源:analyterix.C
示例19:
string
VariableId::toString(VariableIdMapping& vim) const {
return vim.uniqueShortVariableName(*this);
}
开发者ID:InstRO,项目名称:InstRO-ROSE,代码行数:4,代码来源:VariableIdMapping.C
示例20: main
int main( int argc, char * argv[] )
{
// If we want this translator to take specific options (beyond those defined
// by ROSE) then insert command line processing for new options here.
// To better support the stencil specification that might beni
|
请发表评论