本文整理汇总了C++中NodeQuerySynthesizedAttributeType::size方法的典型用法代码示例。如果您正苦于以下问题:C++ NodeQuerySynthesizedAttributeType::size方法的具体用法?C++ NodeQuerySynthesizedAttributeType::size怎么用?C++ NodeQuerySynthesizedAttributeType::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NodeQuerySynthesizedAttributeType
的用法示例。
在下文中一共展示了NodeQuerySynthesizedAttributeType::size方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
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);
}
示例2: frontend
int
main(int argc, char *argv[])
{
SgProject* project = frontend(argc,argv);
AstTests::runAllTests(project); // run internal consistency tests on the AST
size_t nerrors = 0;
std::string separator = std::string(80, '-') + "\n";
std::cerr <<separator <<"Testing NodeQuery::querySubTree for all SgFunctionDeclaration nodes\n";
NodeQuerySynthesizedAttributeType funcDecls = NodeQuery::querySubTree(project, V_SgFunctionDeclaration);
std::cerr <<"found " <<funcDecls.size() <<" function declaration nodes\n";
nerrors += check_unique(funcDecls, "querySubTree SgFunctionDeclaration");
for (NodeQuerySynthesizedAttributeType::const_iterator ni=funcDecls.begin(); ni!=funcDecls.end(); ++ni) {
if (!isSgFunctionDeclaration(*ni)) {
emit_node_mesg(*ni, "not a function declaration");
++nerrors;
}
}
ROSE_ASSERT(0==nerrors); // optional, to exit early
std::cerr <<separator <<"Testing NodeQuery::queryNodeList for all SgFunctionDeclaration nodes\n";
NodeQuerySynthesizedAttributeType funcDecls2 = NodeQuery::queryNodeList(funcDecls, V_SgFunctionDeclaration);
std::cerr <<"found " <<funcDecls2.size() <<" function declaration nodes\n";
nerrors += check_unique(funcDecls2, "queryNodeList SgFunctionDeclaration");
for (NodeQuerySynthesizedAttributeType::const_iterator ni=funcDecls2.begin(); ni!=funcDecls2.end(); ++ni) {
if (!isSgFunctionDeclaration(*ni)) {
emit_node_mesg(*ni, "not a function declaration");
++nerrors;
}
}
ROSE_ASSERT(0==nerrors); // optional, to exit early
std::cerr <<separator <<"Testing NameQuery::querySubTree for FunctionDeclarationNames\n";
NameQuerySynthesizedAttributeType funcNames = NameQuery::querySubTree(project, NameQuery::FunctionDeclarationNames);
std::cerr <<"found " <<funcNames.size() <<" function declaration names\n";
if (funcNames.size() != funcDecls.size()) {
std::cerr <<"number of function declaration names (" <<funcNames.size() <<")"
<<" does not match number of function declaration nodes (" <<funcDecls.size() <<")\n";
++nerrors;
}
ROSE_ASSERT(0==nerrors); // optional, to exit early
std::cerr <<separator <<"Testing NameQuery::queryNodeList for FunctionDeclarationNames\n";
NameQuerySynthesizedAttributeType funcNames2 = NameQuery::queryNodeList(funcDecls, NameQuery::FunctionDeclarationNames);
std::cerr <<"found " <<funcNames2.size() <<" function declaration names\n";
if (funcNames2.size() != funcDecls.size()) {
std::cerr <<"number of function declaration names (" <<funcNames2.size() <<")"
<<" does not match number of function declaration nodes (" <<funcDecls.size() <<")\n";
++nerrors;
}
ROSE_ASSERT(0==nerrors); // optional, to exit early
std::cerr <<separator <<"Testing NumberQuery::querySubTree for NumberOfArgsInConstructor\n";
NumberQuerySynthesizedAttributeType ctorArgCounts = NumberQuery::querySubTree(project,
NumberQuery::NumberOfArgsInConstructor);
std::cerr <<"found " <<ctorArgCounts.size() <<" results\n";
if (ctorArgCounts.size() != 1) {
std::cerr <<"should have found only one result\n";
++nerrors;
}
ROSE_ASSERT(0==nerrors); // optional, to exit early
// It is not necessary to call backend for this test; that functionality is tested elsewhere.
return nerrors ? 1 : 0;
}
示例3: main
int main(int argc, char *argv[])
{
std::string filename;
SgProject *project = frontend(argc, argv);
std::vector<InterproceduralInfo*> ip;
#ifdef NEWDU
// Create the global def-use analysis
DFAnalysis *defUseAnalysis=new DefUseAnalysis(project);
if (defUseAnalysis->run(false)==0)
{
std::cerr<<"DFAnalysis failed!"<<endl;
}
#endif
string outputFileName=project->get_fileList().front()->get_sourceFileNameWithoutPath ();
SystemDependenceGraph *sdg = new SystemDependenceGraph;
// for all function-declarations in the AST
NodeQuerySynthesizedAttributeType functionDeclarations = NodeQuery::querySubTree(project, V_SgFunctionDeclaration);
for (NodeQuerySynthesizedAttributeType::iterator i = functionDeclarations.begin(); i != functionDeclarations.end(); i++)
{
ControlDependenceGraph *cdg;
DataDependenceGraph *ddg;
// FunctionDependenceGraph * pdg;
InterproceduralInfo *ipi;
SgFunctionDeclaration *fDec = isSgFunctionDeclaration(*i);
ROSE_ASSERT(fDec != 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 (fDec->get_definition() == NULL)
{
// if (fDec->get_file_info()->isCompilerGenerated()) continue;
// treat librarycall -> iterprocedualInfo must be created...
// make all call-parameters used and create a function stub for
// the graph
ipi=new InterproceduralInfo(fDec);
ipi->addExitNode(fDec);
sdg->addInterproceduralInformation(ipi);
if (sdg->isKnownLibraryFunction(fDec))
{
sdg->createConnectionsForLibaryFunction(fDec);
}
else
{
sdg->createSafeConfiguration(fDec);
}
ip.push_back(ipi);
// This is somewhat a waste of memory and a more efficient approach might generate this when needed, but at the momenent everything is created...
}
else
{
// get the control depenence for this function
ipi=new InterproceduralInfo(fDec);
ROSE_ASSERT(ipi != NULL);
// get control dependence for this function defintion
cdg = new ControlDependenceGraph(fDec->get_definition(), ipi);
cdg->computeInterproceduralInformation(ipi);
// get the data dependence for this function
#ifdef NEWDU
ddg = new DataDependenceGraph(fDec->get_definition(), defUseAnalysis,ipi);
#else
ddg = new DataDependenceGraph(fDec->get_definition(), ipi);
#endif
sdg->addFunction(cdg,ddg);
sdg->addInterproceduralInformation(ipi);
ip.push_back(ipi);
}
// else if (fD->get_definition() == NULL)
}
// now all function-declarations have been process as well have all function-definitions
filename = (outputFileName) + ".no_ii.sdg.dot";
sdg->writeDot((char *)filename.c_str());
// perform interproceduralAnalysys
sdg->performInterproceduralAnalysis();
filename = (outputFileName)+".deadEnds.sdg.dot";
sdg->writeDot((char *)filename.c_str());
sdg->cleanUp();
filename = (outputFileName)+".final.sdg.dot";
sdg->writeDot((char *)filename.c_str());
//get SlicingInfo
//.........这里部分代码省略.........
示例4: testOneFunction
void testOneFunction( std::string funcParamName,
vector<string> argvList,
bool debug, int nrOfNodes,
multimap <int, vector<string> > resultsIn,
multimap <int, vector<string> > resultsOut) {
cout << " \n\n------------------------------------------\nrunning (variable)... " << argvList[1] << endl;
// Build the AST used by ROSE
SgProject* project = frontend(argvList);
// Call the Def-Use Analysis
DFAnalysis* defuse = new DefUseAnalysis(project);
int val = defuse->run(debug);
if (debug)
std::cerr << ">Analysis run is : " << (val ? "failure" : "success" ) << " " << val << std::endl;
if (val==1) exit(1);
if (debug==false)
defuse->dfaToDOT();
LivenessAnalysis* liv = new LivenessAnalysis(debug,(DefUseAnalysis*)defuse);
std::vector <FilteredCFGNode < IsDFAFilter > > dfaFunctions;
NodeQuerySynthesizedAttributeType vars = NodeQuery::querySubTree(project, V_SgFunctionDefinition);
NodeQuerySynthesizedAttributeType::const_iterator i = vars.begin();
bool abortme=false;
int hitIn=0;
int hitOut=0;
for (; i!=vars.end();++i) {
SgFunctionDefinition* func = isSgFunctionDefinition(*i);
std::string name = func->class_name();
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 (abortme)
break;
if (funcName!=funcParamName) {
if (debug)
cerr << " .. skipping live analysis check for func : " << funcName << endl;
continue;
}
if (rem_source.getNode()!=NULL)
dfaFunctions.push_back(rem_source);
NodeQuerySynthesizedAttributeType nodes = NodeQuery::querySubTree(func, V_SgNode);
// Edg3 mistakenly adds SgType nodes to the AST; Edg4 adds some also, but fewer. So we just remove them all. They
// make no difference in the variable-liveness analysis anyway.
nodes.erase(std::remove_if(nodes.begin(), nodes.end(), is_type_node), nodes.end());
SgFunctionDeclaration* decl = isSgFunctionDeclaration(func->get_declaration());
ROSE_ASSERT(decl);
Rose_STL_Container<SgInitializedName*> args = decl->get_parameterList()->get_args();
if (debug)
cerr <<"Found args : " << args.size() << endl;
Rose_STL_Container<SgInitializedName*>::const_iterator it = args.begin();
for (;it!=args.end();++it) {
nodes.push_back(*it);
}
if((int)nodes.size()-1!=nrOfNodes) {
cerr << "Error :: Number of nodes = " << nodes.size()-1 << " should be : " << nrOfNodes << endl;
exit(1);
} else {
if (debug)
cerr << "Investigating nodes : " << nodes.size() << endl;
}
NodeQuerySynthesizedAttributeType::const_iterator nodesIt = nodes.begin();
for (; nodesIt!=nodes.end();++nodesIt) {
SgNode* node = *nodesIt;
ROSE_ASSERT(node);
int tableNr = defuse->getIntForSgNode(node);
std::vector<SgInitializedName*> in = liv->getIn(node);
std::vector<SgInitializedName*> out = liv->getOut(node);
std::vector<string> inName;
std::vector<string> outName;
std::vector<SgInitializedName*>::const_iterator itv = in.begin();
for (;itv!=in.end();++itv) {
SgInitializedName* init = *itv;
string name = init->get_name();
inName.push_back(name);
}
itv = out.begin();
for (;itv!=out.end();++itv) {
SgInitializedName* init = *itv;
string name = init->get_name();
outName.push_back(name);
}
std::sort(inName.begin(), inName.end());
std::sort(outName.begin(), outName.end());
multimap <int, vector<string> >::const_iterator k =resultsIn.begin();
for (;k!=resultsIn.end();++k) {
int resNr = k->first;
vector<string> results = k->second;
if (debug)
cerr << " ... containing nodes : " << results.size() << " node: " << node->class_name()
<< " tableNr : " << tableNr
<< " resNr : " << resNr << endl;
//.........这里部分代码省略.........