本文整理汇总了C++中NodeQuerySynthesizedAttributeType类的典型用法代码示例。如果您正苦于以下问题:C++ NodeQuerySynthesizedAttributeType类的具体用法?C++ NodeQuerySynthesizedAttributeType怎么用?C++ NodeQuerySynthesizedAttributeType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了NodeQuerySynthesizedAttributeType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: queryIsImportantForSliceTypeWithCalls
NodeQuerySynthesizedAttributeType queryIsImportantForSliceTypeWithCalls(SgNode * astNode)
{
NodeQuerySynthesizedAttributeType retVal;
if (IsImportantForSliceSgFilter(astNode) || isSgFunctionCallExp(astNode))
retVal.push_back(astNode);
return retVal;
}
示例2: queryIsImportantForSliceType
NodeQuerySynthesizedAttributeType queryIsImportantForSliceType(SgNode * astNode)
{
NodeQuerySynthesizedAttributeType retVal;
if (IsImportantForSliceSgFilter(astNode))
retVal.push_back(astNode);
return retVal;
}
示例3: isSgName
NodeQuerySynthesizedAttributeType NodeQuery::queryNodeClassDeclarationFromName(SgNode* node, SgNode* nameNode){
NodeQuerySynthesizedAttributeType returnList;
ROSE_ASSERT( nameNode != NULL );
ROSE_ASSERT( node != NULL );
//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 );
SgClassDeclaration *sageClassDeclaration = isSgClassDeclaration (node);
if (sageClassDeclaration != NULL)
{
std::string name = sageClassDeclaration->get_name ().str ();
if( name == nameToMatch )
returnList.push_back(node);
}
return returnList;
} /* End function:queryNodeCLassDeclarationFromName() */
示例4: forStatementNodeQuery
// search for for statements
NodeQuerySynthesizedAttributeType forStatementNodeQuery(SgNode* node)
{
ROSE_ASSERT(node != 0);
NodeQuerySynthesizedAttributeType returnNodeList;
if(isSgForStatement(node)) returnNodeList.push_back(node);
return returnNodeList;
}
示例5:
NodeQuerySynthesizedAttributeType NodeQuery::queryNodeList ( NodeQuerySynthesizedAttributeType nodeList, VariantVector targetVariantVector)
{
NodeQuerySynthesizedAttributeType returnList;
AstQueryNamespace::queryRange(nodeList.begin(), nodeList.end(), boost::bind(querySolverGrammarElementFromVariantVector, _1,targetVariantVector,&returnList));
return returnList;
}
示例6: ROSE_ASSERT
NodeQuerySynthesizedAttributeType
NodeQuery::querySolverVariableDeclarations (SgNode * astNode)
{
ROSE_ASSERT (astNode != 0);
NodeQuerySynthesizedAttributeType returnNodeList;
switch (astNode->variantT ())
{
case V_SgVariableDeclaration:
returnNodeList.push_back (astNode);
break;
case V_SgFunctionDeclaration:
case V_SgMemberFunctionDeclaration:
{
SgFunctionDeclaration * sageFunctionDeclaration =
isSgFunctionDeclaration (astNode);
ROSE_ASSERT (sageFunctionDeclaration != NULL);
SgInitializedNamePtrList sageInitializedNameList =
sageFunctionDeclaration->get_args ();
typedef SgInitializedNamePtrList::iterator variableIterator;
for (variableIterator variableListElement =
sageInitializedNameList.begin ();
variableListElement != sageInitializedNameList.end ();
++variableListElement)
{
SgInitializedName* elmVar = *variableListElement;
//SgVariableDeclaration* sageVariableDeclaration = isSgVariableDeclaration((elmVar.get_declaration())->copy());
//ROSE_ASSERT(sageVariableDeclaration != NULL);
//if( sageVariableDeclaration != NULL)
//AS (9/26/03) I must put an object of type const SgDeclarationStatement into the list because
// I have no other way of finding the SgVariableDeclaration in the arguments. This is safe
// because arguments are Variable Declarations, but puts unwelcome limits on use of returned
// list because of it's constantness.
ROSE_ASSERT (elmVar != NULL);
returnNodeList.push_back (elmVar->get_declaration ());
//returnNodeList.push_back (sageVariableDeclaration);
}
break;
}
default:
{
// DQ (8/20/2005): Added default to avoid compiler warnings about unrepresented cases
}
} /* End switch-case */
return returnNodeList;
} /* End function querySolverVariableDeclarations() */
示例7: runCurrentFile
void runCurrentFile(vector<string> &argvList, bool debug, bool debug_map) {
// Build the AST used by ROSE
if (debug)
std::cout << ">>>> Starting ROSE frontend ... " << endl;
SgProject* project = frontend(argvList);
if (debug)
std::cout << ">>>> generate PDF " << endl;
generatePDF ( *project );
if (debug)
std::cout << ">>>> start def-use analysis ... " << endl;
// Call the Def-Use Analysis
DFAnalysis* defuse = new DefUseAnalysis(project);
int val = defuse->run(debug);
if (debug)
std::cout << "Analysis is : " << (val ? "failure" : "success" ) << " " << val <<std::endl;
if (val==1) exit(1);
if (debug==false)
defuse->dfaToDOT();
LivenessAnalysis* liv = new LivenessAnalysis(true,(DefUseAnalysis*)defuse);
//example usage
// testing
std::vector <FilteredCFGNode < IsDFAFilter > > dfaFunctions;
bool abortme=false;
NodeQuerySynthesizedAttributeType vars = NodeQuery::querySubTree(project, V_SgFunctionDefinition);
NodeQuerySynthesizedAttributeType::const_iterator i = vars.begin();
for (; i!=vars.end();++i) {
SgFunctionDefinition* func = isSgFunctionDefinition(*i);
string funcName = func->get_declaration()->get_qualified_name().str();
if (debug)
cerr << " running live analysis for func : " << funcName << endl;
FilteredCFGNode <IsDFAFilter> rem_source = liv->run(func,abortme);
if (rem_source.getNode()!=NULL)
dfaFunctions.push_back(rem_source);
if (abortme)
break;
}
std::ofstream f2("var.dot");
dfaToDot(f2, string("var"), dfaFunctions,
(DefUseAnalysis*)defuse, liv);
f2.close();
if (abortme) {
cerr<<"ABORTING ." << endl;
exit(1);
}
delete project;
delete defuse;
}
示例8: main
int main(int argc, char *argv[]) {
SgProject* sageProject = frontend(argc,argv);
AstTests::runAllTests(sageProject);
NodeQuerySynthesizedAttributeType functions = NodeQuery::querySubTree(sageProject, V_SgFunctionDefinition);
for (NodeQuerySynthesizedAttributeType::const_iterator i = functions.begin(); i != functions.end(); ++i) {
SgFunctionDefinition* proc = isSgFunctionDefinition(*i);
ROSE_ASSERT (proc);
testCFG(proc);
}
return 0;
}
示例9: isSgTypedefDeclaration
/*
* The function
* queryNodeAnonymousTypedef()
* is a NodeQuery which finds all Anonymous Typedefs is the scope.
*/
NodeQuerySynthesizedAttributeType NodeQuery::queryNodeAnonymousTypedef(SgNode* node)
{
NodeQuerySynthesizedAttributeType returnList;
ROSE_ASSERT( node != NULL );
SgTypedefDeclaration* sageTypedefDeclaration = isSgTypedefDeclaration(node);
if (sageTypedefDeclaration != NULL)
if(isSgClassType(sageTypedefDeclaration->get_base_type()))
returnList.push_back(node);
return returnList;
} /* End function:queryNodeCLassDeclarationFromName() */
示例10: main
int main(int argc, char *argv[])
{
std::string filename;
SgProject *project = frontend(argc, argv);
std::vector<InterproceduralInfo*> ip;
// list < SgNode * >functionDeclarations = NodeQuery::querySubTree(project, V_SgFunctionDeclaration);
NodeQuerySynthesizedAttributeType functionDeclarations = NodeQuery::querySubTree(project, V_SgFunctionDeclaration);
// for (list < SgNode * >::iterator i = functionDeclarations.begin(); i != functionDeclarations.end(); i++)
for (NodeQuerySynthesizedAttributeType::iterator i = functionDeclarations.begin(); i != functionDeclarations.end(); i++)
{
ControlDependenceGraph *cdg;
InterproceduralInfo *ipi;
SgFunctionDeclaration *fD = isSgFunctionDeclaration(*i);
// SGFunctionDefinition * fDef;
ROSE_ASSERT(fD != NULL);
// CI (01/08/2007): A missing function definition is an indicator to a
//
//
// librarycall.
// * An other possibility would be a programmer-mistake, which we
// don't treat at this point. // I assume librarycall
if (fD->get_definition() == NULL)
{
}
else
{
// get the control depenence for this function
ipi=new InterproceduralInfo(fD);
ROSE_ASSERT(ipi != NULL);
// get control dependence for this function defintion
cdg = new ControlDependenceGraph(fD->get_definition(), ipi);
cdg->computeAdditionalFunctioncallDepencencies();
// cdg->computeInterproceduralInformation(ipi);
// cdg->debugCoutNodeList();
// Liao, Feb. 7/2008,
//strip off absolute path to avoid polluting the source tree with generated .dot files
filename = StringUtility::stripPathFromFileName((fD->get_definition()->get_file_info()->get_filenameString ()))
+ "." +
(fD->get_name().getString()) + ".cdg.dot";
cdg->writeDot((char *)filename.c_str());
}
}
}
示例11: mergeList
void
mergeList ( NodeQuerySynthesizedAttributeType & nodeList, const Rose_STL_Container<SgNode*> & localList )
{
// Supporting function for querySolverGrammarElementFromVariantVector
unsigned localListSize = localList.size();
unsigned nodeListSize = nodeList.size();
for (Rose_STL_Container<SgNode*>::const_iterator i = localList.begin(); i != localList.end(); i++)
{
// printf ("Adding node to list (%s) \n",(*i)->sage_class_name());
nodeList.push_back(*i);
}
ROSE_ASSERT (nodeList.size() == nodeListSize+localListSize);
}
示例12: check_unique
/** Checks that all nodes in the list are unique. Emit errors about duplicate items. Returns the number of duplicates. */
static size_t
check_unique(const NodeQuerySynthesizedAttributeType &nodes, const std::string &title)
{
std::set<SgNode*> set;
std::vector<SgNode*> dups;
for (NodeQuerySynthesizedAttributeType::const_iterator ni=nodes.begin(); ni!=nodes.end(); ++ni) {
if (!set.insert(*ni).second)
dups.push_back(*ni);
}
if (!dups.empty()) {
std::cerr <<"Duplicate nodes returned for the \"" <<title <<"\" test:\n";
for (std::vector<SgNode*>::const_iterator di=dups.begin(); di!=dups.end(); ++di)
emit_node_mesg(*di, "appears multiple times in list");
}
return dups.size();
}
示例13: querySolverAccessFunctions
// Function querySolverAccessFunctions()
// find access functions (function name starts with "get_" or "set_")
NodeQuerySynthesizedAttributeType
querySolverAccessFunctions (SgNode * astNode)
{
ROSE_ASSERT (astNode != 0);
NodeQuerySynthesizedAttributeType returnNodeList;
SgFunctionDeclaration* funcDecl = isSgFunctionDeclaration(astNode);
if (funcDecl != NULL)
{
string functionName = funcDecl->get_name().str();
if ( (functionName.length() >= 4) && ((functionName.substr(0,4) == "get_") || (functionName.substr(0,4) == "set_")) )
returnNodeList.push_back (astNode);
}
return returnNodeList;
}
示例14: queryNodeClassDeclarationFromTypedefName
NodeQuerySynthesizedAttributeType
queryNodeClassDeclarationFromTypedefName (SgNode * astNode,
SgNode * nameNode)
{
NodeQuerySynthesizedAttributeType returnList;
ROSE_ASSERT (nameNode != NULL);
ROSE_ASSERT (nameNode != NULL);
//finds the name which should be matched to
SgName *sageName = isSgName (nameNode);
ROSE_ASSERT (sageName != NULL);
string nameToMatch = sageName->str ();
ROSE_ASSERT (nameToMatch.length () > 0);
if (isSgType (astNode) != NULL)
{
/*SgTypedefType* sageTypedefType = isSgTypedefType(astNode);
string name = TransformationSupport::getTypeName(sageTypedefType);
ROSE_ASSERT( nameToMatch.length() > 0 );
cout << nameToMatch << endl; */
#ifdef DEBUG_CGRAPHPP
cout << TransformationSupport::getTypeName (isSgType (astNode)) << endl;
#endif
if (TransformationSupport::getTypeName (isSgType (astNode)) ==
nameToMatch)
{
returnList.push_back (astNode);
}
/*
if(nameToMatch == name){
SgClassDeclaration *sageClassDeclaration = isSgClassDeclaration (sageTypedefType->get_declaration());
ROSE_ASSERT( sageClassDeclaration != NULL );
returnList.push_back(sageClassDeclaration);
}*/
}
return returnList;
}
示例15: getSymbolFromName
SgVariableSymbol* MintArrayInterface::getSymbolFromName(SgBasicBlock* block, string varStr)
{
NodeQuerySynthesizedAttributeType vars = NodeQuery::querySubTree(block, V_SgScopeStatement);
NodeQuerySynthesizedAttributeType::const_iterator it = vars.begin();
for(it= vars.begin(); it != vars.end(); it++)
{
SgScopeStatement* outer_scope = isSgScopeStatement(*(it));
SgVariableSymbol* sym = outer_scope->lookup_var_symbol(varStr);
if(sym!= NULL)
return sym;
}
return NULL;
}