本文整理汇总了C++中Rose_STL_Container类的典型用法代码示例。如果您正苦于以下问题:C++ Rose_STL_Container类的具体用法?C++ Rose_STL_Container怎么用?C++ Rose_STL_Container使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Rose_STL_Container类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ROSE_ASSERT
/*
* The function
* queryNodePragmaDeclarationFromName()
* takes as a first parameter a SgNode*. As a second parameter it takes
* a SgNode* who must be of type SgName. The SgName contains a std::string which
* should be the same as the left side in the pragma or a part of the left
* side of the pragma. If the std::string is empty,
* there will be an error message.
*
* #pragma std::stringInSgNode = information
*
*/
Rose_STL_Container<SgNode*> NodeQuery::queryNodePragmaDeclarationFromName(SgNode* node, SgNode* nameNode){
ROSE_ASSERT( nameNode != NULL );
ROSE_ASSERT( node != NULL );
Rose_STL_Container<SgNode*> returnList;
//finds the name which should be matched to
SgName* sageName = isSgName(nameNode);
ROSE_ASSERT( sageName != NULL );
std::string nameToMatch = sageName->str();
ROSE_ASSERT( nameToMatch.length() > 0 );
if(node->variantT() == V_SgPragmaDeclaration){
SgPragmaDeclaration* sagePragmaDeclaration = isSgPragmaDeclaration(node);
ROSE_ASSERT( sagePragmaDeclaration );
ROSE_ASSERT( sagePragmaDeclaration->get_pragma() != NULL );
// ROSE_ASSERT( sagePragmaDeclaration->get_pragma()->get_pragma() );
std::string pragmaDeclarationString = sagePragmaDeclaration->get_pragma()->get_pragma();
//extract the part before the leftmost = is pragmaDeclarationString
pragmaDeclarationString = pragmaDeclarationString.substr(0,pragmaDeclarationString.find("="));
//if the name-criteria is met accept node
if(pragmaDeclarationString.find( nameToMatch ) != pragmaDeclarationString.length() ){
cout << pragmaDeclarationString << endl;
returnList.push_back(node);
}
}
return returnList;
}
示例2: normalizeLoops
// normalize all loops within candidate function definitions
void normalizeLoops (std::vector<SgFunctionDefinition* > candidateFuncDefs)
{
for (std::vector<SgFunctionDefinition* >::iterator iter = candidateFuncDefs.begin(); iter != candidateFuncDefs.end(); iter++)
{
SgFunctionDefinition* funcDef = *iter;
ROSE_ASSERT (funcDef);
// This has to happen before analyses are called.
// For each loop
VariantVector vv (V_SgForStatement);
Rose_STL_Container<SgNode*> loops = NodeQuery::querySubTree(funcDef, vv);
if (enable_debug)
cout<<"Normalize loops queried from memory pool ...."<<endl;
// normalize C99 style for (int i= x, ...) to C89 style: int i; (i=x, ...)
// Liao, 10/22/2009. Thank Jeff Keasler for spotting this bug
for (Rose_STL_Container<SgNode*>::iterator iter = loops.begin();
iter!= loops.end(); iter++ )
{
SgForStatement* cur_loop = isSgForStatement(*iter);
ROSE_ASSERT(cur_loop);
if (enable_debug)
cout<<"\t loop at:"<< cur_loop->get_file_info()->get_line() <<endl;
// skip for (;;) , SgForStatement::get_test_expr() has a buggy assertion.
SgStatement* test_stmt = cur_loop->get_test();
if (test_stmt!=NULL &&
isSgNullStatement(test_stmt))
{
if (enable_debug)
cout<<"\t skipped due to empty loop header like for (;;)"<<endl;
continue;
}
// skip system header
if (insideSystemHeader (cur_loop) )
{
if (enable_debug)
cout<<"\t skipped since the loop is inside a system header "<<endl;
continue;
}
#if 0 // we now always normalize loops, then later undo some normalization 6/22/2016
// SageInterface::normalizeForLoopInitDeclaration(cur_loop);
if (keep_c99_loop_init)
{
// 2/29/2016, disable for loop init declaration normalization
// This is not used . No longer used.
normalizeForLoopTest(cur_loop);
normalizeForLoopIncrement(cur_loop);
ensureBasicBlockAsBodyOfFor(cur_loop);
constantFolding(cur_loop->get_test());
constantFolding(cur_loop->get_increment());
}
else
#endif
SageInterface::forLoopNormalization(cur_loop);
} // end for all loops
} // end for all function defs
}
示例3: main
int main(int argc, char *argv[])
{
// Build the AST used by ROSE
SgProject* sageProject = frontend(argc,argv);
// Process all function definition bodies for static control flow graph generation
Rose_STL_Container<SgNode*> functions = NodeQuery::querySubTree(sageProject, V_SgFunctionDefinition);
for (Rose_STL_Container<SgNode*>::const_iterator i = functions.begin(); i != functions.end(); ++i)
{
SgFunctionDefinition* proc = isSgFunctionDefinition(*i);
ROSE_ASSERT (proc != NULL);
string fileName= StringUtility::stripPathFromFileName(proc->get_file_info()->get_filenameString());
string dotFileName1=fileName+"."+ proc->get_declaration()->get_name() +".debug.dot";
string dotFileName2=fileName+"."+ proc->get_declaration()->get_name() +".interesting.dot";
StaticCFG::CFG cfg(proc);
// Dump out the full CFG, including bookkeeping nodes
cfg.buildFullCFG();
cfg.cfgToDot(proc, dotFileName1);
// Dump out only those nodes which are "interesting" for analyses
cfg.buildFilteredCFG();
cfg.cfgToDot(proc, dotFileName2);
}
return 0;
}
示例4:
string
CommandlineProcessing::generateStringFromArgList ( Rose_STL_Container<string> argList, bool skipInitialEntry, bool skipSourceFiles )
{
string returnString;
for (Rose_STL_Container<string>::iterator i = argList.begin();
i != argList.end(); ++i) {
if (skipInitialEntry && i == argList.begin()) continue;
if (skipSourceFiles == true) {
string arg = *i;
string suffix = "";
if (arg.length() > 2) suffix = arg.substr(arg.size() - 2);
if (suffix == ".C" || arg.find("--edg:definition_list_file") == 0) {
// DQ (5/13/2004): It was not a great idea to put this filter into this function
// remove it and handle the filtering of definition_list_file better ... later!
continue;
}
}
// returnString += *i;
returnString += *i + " ";
}
// printf ("In generateStringFromArgList(): returnString = %s \n",returnString.c_str());
return returnString;
}
示例5: getVariablesProcessedByInnerLoops
// obtain read or write variables processed by all nested loops, if any
void getVariablesProcessedByInnerLoops (SgScopeStatement* current_loop_body, bool isRead, std::set<SgInitializedName*>& var_set)
{
// AST query to find all loops
// add all read/write variables into the var_set
VariantVector vv;
vv.push_back(V_SgForStatement);
vv.push_back(V_SgFortranDo);
Rose_STL_Container<SgNode*> nodeList = NodeQuery::querySubTree(current_loop_body, vv);
for (Rose_STL_Container<SgNode *>::iterator i = nodeList.begin(); i != nodeList.end(); i++)
{
SgStatement* loop = isSgStatement(*i);
if (debug)
cout<< "Found nested loop at line:"<< loop->get_file_info()->get_line()<<endl;
std::set<SgInitializedName*> src_var_set ;
if (isRead)
src_var_set = LoopLoadVariables[loop];
else
src_var_set = LoopStoreVariables[loop];
std::set<SgInitializedName*>::iterator j;
if (debug)
cout<< "\t Insert processed variable:"<<endl;
for (j= src_var_set.begin(); j!= src_var_set.end(); j++)
{
var_set.insert(*j);
if (debug)
cout<< "\t \t "<<(*j)->get_name()<<endl;
}
}
}
示例6: main
int
main ( int argc, char* argv[] )
{
ROSE_INITIALIZE;
if (SgProject::get_verbose() > 0)
printf ("In preprocessor.C: main() \n");
SgProject* project = frontend(argc,argv);
ROSE_ASSERT (project != NULL);
Rose_STL_Container<SgNode*> nodeList;
nodeList = NodeQuery::querySubTree (project,V_SgForStatement);
printf ("\nnodeList.size() = %zu \n",nodeList.size());
Rose_STL_Container<SgNode*>::iterator i = nodeList.begin();
while (i != nodeList.end())
{
Sg_File_Info & fileInfo = *((*i)->get_file_info());
printf ("Query node = %p = %s in %s \n ----- at line %d on column %d \n",
*i,(*i)->sage_class_name(),fileInfo.get_filename(),
fileInfo.get_line(), fileInfo.get_col());
i++;
}
if (project->get_verbose() > 0)
printf ("Calling the backend() \n");
return 0;
}
示例7: while
// DQ (7/8/2005):
Rose_STL_Container<string>
CommandlineProcessing::generateArgListFromString ( string commandline )
{
Rose_STL_Container<string> argList;
// DQ (12/21/2006): Required to be long to avoid "if (subStringEnd == string::npos)" always evaluating to false.
unsigned long int subStringStart = 0;
unsigned long int subStringEnd = commandline.find(" ");
// printf ("commandline.size() = %ld \n",commandline.size());
while (subStringStart < commandline.size())
{
string subString = commandline.substr(subStringStart,subStringEnd-subStringStart);
// printf ("subString (%ld,%ld) = %s \n",subStringStart,subStringEnd,subString.c_str());
// DQ (8/1/2005): Fix suggested by Milind (supporting astMerge in compilation of multiple files)
// subStringStart = subStringEnd;
// subStringEnd = commandline.find(" ",subStringStart+1);
subStringStart = subStringEnd + 1;
subStringEnd = commandline.find(" ",subStringStart);
// printf ("New values subStringStart = %ld subStringEnd = %ld \n",subStringStart,subStringEnd);
if (subStringEnd == string::npos)
{
subStringEnd = commandline.size();
// printf ("Reset subStringEnd = %ld \n",subStringEnd);
}
argList.push_back(subString);
}
return argList;
}
示例8: buildListOfGlobalVariables
Rose_STL_Container<SgInitializedName*>
buildListOfGlobalVariables ( SgSourceFile* file )
{
// This function builds a list of global variables (from a SgFile).
assert(file != NULL);
Rose_STL_Container<SgInitializedName*> globalVariableList;
SgGlobal* globalScope = file->get_globalScope();
assert(globalScope != NULL);
Rose_STL_Container<SgDeclarationStatement*>::iterator i = globalScope->get_declarations().begin();
while(i != globalScope->get_declarations().end())
{
SgVariableDeclaration *variableDeclaration = isSgVariableDeclaration(*i);
if (variableDeclaration != NULL)
{
Rose_STL_Container<SgInitializedName*> & variableList = variableDeclaration->get_variables();
Rose_STL_Container<SgInitializedName*>::iterator var = variableList.begin();
while(var != variableList.end())
{
globalVariableList.push_back(*var);
var++;
}
}
i++;
}
return globalVariableList;
}
示例9: main
int main(int argc, char *argv[])
{
SgProject* sageProject = frontend(argc,argv);
AstTests::runAllTests(sageProject);
Rose_STL_Container <SgNode*> functions = NodeQuery::querySubTree(sageProject, V_SgFunctionDefinition);
for (Rose_STL_Container <SgNode*>::const_iterator i = functions.begin(); i != functions.end(); ++i)
{
SgFunctionDefinition* proc = isSgFunctionDefinition(*i);
ROSE_ASSERT (proc);
string file_name = StringUtility::stripPathFromFileName(proc->get_file_info()->get_filename());
string file_func_name= file_name+ "_"+proc->get_mangled_name().getString();
string full_output = file_func_name +"_scfg.dot";
// Full CFG graph
StaticCFG::CFG cfg(proc);
cfg.buildFullCFG();
cfg.cfgToDot(proc, full_output);
#if 0 // not ready
string simple_output = file_func_name +"_simple_vcfg.dot";
std::ofstream simplegraph(simple_output.c_str());
// Simplified CFG suitable for most analyses
// This will cause assertion failure
//StaticCFG::cfgToDot(simplegraph, proc->get_declaration()->get_name(), StaticCFG::makeInterestingCfg(proc));
// This will generate identical graph as cfgToDotForDebugging ()
StaticCFG::cfgToDot(simplegraph, proc->get_declaration()->get_name(), proc->cfgForBeginning());
#endif
}
return 0;
}
示例10: DefUseAnalysisPF
/******************************************
* Traversal over all functions
* this needs to be improved... for correctness, the traversal must
* be according to controlflow (otherwise global variables are incorrect)
*****************************************/
bool DefUseAnalysis::start_traversal_of_functions() {
if (DEBUG_MODE)
cout << "START: Traversal over Functions" << endl;
nrOfNodesVisited = 0;
dfaFunctions.clear();
// Traverse through each FunctionDefinition and check for DefUse
Rose_STL_Container<SgNode*> functions = NodeQuery::querySubTree(project, V_SgFunctionDefinition);
DefUseAnalysisPF* defuse_perfunc = new DefUseAnalysisPF(DEBUG_MODE, this);
bool abortme=false;
for (Rose_STL_Container<SgNode*>::const_iterator i = functions.begin(); i != functions.end(); ++i) {
SgFunctionDefinition* proc = isSgFunctionDefinition(*i);
if (DEBUG_MODE)
cout << "\t function [email protected]"<< proc->get_file_info()->get_filename() <<":" << proc->get_file_info()->get_line() << endl;
FilteredCFGNode <IsDFAFilter> rem_source = defuse_perfunc->run(proc,abortme);
nrOfNodesVisited += defuse_perfunc->getNumberOfNodesVisited();
//cout << nrOfNodesVisited << " ......... function " << proc->get_declaration()->get_name().str() << endl;
if (rem_source.getNode()!=NULL)
dfaFunctions.push_back(rem_source);
}
delete defuse_perfunc;
if (DEBUG_MODE) {
dfaToDOT();
}
if (DEBUG_MODE)
cout << "FINISH: Traversal over Functions" << endl;
return abortme;
}
示例11: main
int main( int argc, char * argv[] )
{
// Build the AST used by ROSE
SgProject* project = frontend(argc,argv);
generatePDF ( *project );
Rose_STL_Container<SgNode*> functions = NodeQuery::querySubTree(project, V_SgFunctionDefinition);
for (Rose_STL_Container<SgNode*>::const_iterator i = functions.begin(); i != functions.end(); ++i) {
SgFunctionDefinition* curFunc = isSgFunctionDefinition(*i);
ROSE_ASSERT(curFunc);
SgBasicBlock *funcBody = curFunc->get_body();
InterestingNode funcCFGStart = (InterestingNode)funcBody->cfgForBeginning();;
// output the CFG to a file
ofstream fileCFG;
fileCFG.open((curFunc->get_declaration()->get_name().getString()+"_cfg.dot").c_str());
cout << "writing to file "<<(curFunc->get_declaration()->get_name().getString()+"_cfg.dot")<<"\n";
VirtualCFG::cfgToDot(fileCFG, curFunc->get_declaration()->get_name(), funcCFGStart);
fileCFG.close();
}
// Unparse and compile the project (so this can be used for testing)
return backend(project);
}
示例12: replaceMintForWithOmpFor
//note that we keep mint for pragma as well
//#pragma mint for
//#pragma omp for
void MintCudaMidend::replaceMintForWithOmpFor(SgSourceFile* file)
{
Rose_STL_Container<SgNode*> nodeList = NodeQuery::querySubTree(file, V_SgPragmaDeclaration);
Rose_STL_Container<SgNode*>::reverse_iterator nodeListIterator = nodeList.rbegin();
for ( ;nodeListIterator !=nodeList.rend(); ++nodeListIterator)
{
SgPragmaDeclaration* node = isSgPragmaDeclaration(*nodeListIterator);
ROSE_ASSERT(node != NULL);
//checks if the syntax is correct and the parallel region is followed by
//a basic block
if(MintPragmas::isForLoopPragma(node))
{
SgStatement* loop = getNextStatement(node);
ROSE_ASSERT(loop);
if(isSgForStatement(loop))
{
removeStatement(loop);
SgOmpForStatement* omp_stmt = new SgOmpForStatement(NULL, loop);
setOneSourcePositionForTransformation(omp_stmt);
loop->set_parent(omp_stmt);
insertStatementAfter(node, omp_stmt);
}
}
}
}
示例13: getCanonicalDecl
Function::Function(string name)
{
//printf("Function::Function(string name) this=0x%x\n", this);
//def = NULL;
Rose_STL_Container<SgNode*> functions = NodeQuery::querySubTree(cfgUtils::project, V_SgFunctionDeclaration);
for (Rose_STL_Container<SgNode*>::const_iterator it = functions.begin(); it != functions.end(); it++)
{
ROSE_ASSERT(isSgFunctionDeclaration(*it));
if(isSgFunctionDeclaration(*it)->get_name().getString() == name)
{
// decl will be initialized to the defining declaration of this function or
// the first non-defining declaratio,n if there is no definition
decl = getCanonicalDecl(isSgFunctionDeclaration(*it));
break;
/*decls.insert(isSgFunctionDeclaration(*it));
if(isSgFunctionDeclaration(*it)->get_definition())
{
// save the current function's definition inside def
// ensure that either def has not been set yet or that there is a unique definition
if(def==NULL)
def = isSgFunctionDeclaration(*it)->get_definition();
else
ROSE_ASSERT(def == isSgFunctionDeclaration(*it)->get_definition());
}*/
}
}
// every function must have at least one declaration
//ROSE_ASSERT(decls.size()>0);
ROSE_ASSERT(decl);
}
示例14: getArrayReferenceCounts
void CudaOptimizer::getArrayReferenceCounts(SgBasicBlock* kernel_body,
std::map<SgInitializedName*, int>& varCount_map)
{
Rose_STL_Container<SgNode*> arrList = NodeQuery::querySubTree(kernel_body, V_SgPntrArrRefExp);
Rose_STL_Container<SgNode*>::iterator arr;
for(arr = arrList.begin(); arr != arrList.end(); arr++)
{
SgExpression* arrayName;
vector<SgExpression*> subscripts; //first index is i if E[j][i]
//index list are from right to left
bool yes = MintArrayInterface::isArrayReference(isSgExpression(*arr), &arrayName, &subscripts);
assert(yes);
SgInitializedName *i_name = SageInterface::convertRefToInitializedName(isSgVarRefExp (arrayName));
//this is the first time the var appears
if(varCount_map.find(i_name) == varCount_map.end())
varCount_map[i_name] = 0;
varCount_map[i_name]++;
int arrayDim = subscripts.size() ;
arr = arr + arrayDim - 1;
}
}
示例15: clearNodesAndEdges
void CFG::buildFullCFG()
{
// Before building a new CFG, make sure to clear all nodes built before.
all_nodes_.clear();
clearNodesAndEdges();
std::set<VirtualCFG::CFGNode> explored;
graph_ = new SgIncidenceDirectedGraph;
if (SgProject* project = isSgProject(start_))
{
Rose_STL_Container<SgNode*> functions = NodeQuery::querySubTree(project, V_SgFunctionDefinition);
for (Rose_STL_Container<SgNode*>::const_iterator i = functions.begin(); i != functions.end(); ++i)
{
SgFunctionDefinition* proc = isSgFunctionDefinition(*i);
if (proc)
{
buildCFG<VirtualCFG::CFGNode, VirtualCFG::CFGEdge>
(proc->cfgForBeginning(), all_nodes_, explored);
}
}
}
else
buildCFG<VirtualCFG::CFGNode, VirtualCFG::CFGEdge>
(start_->cfgForBeginning(), all_nodes_, explored);
}