当前位置: 首页>>代码示例>>C++>>正文


C++ NodeQuerySynthesizedAttributeType::end方法代码示例

本文整理汇总了C++中NodeQuerySynthesizedAttributeType::end方法的典型用法代码示例。如果您正苦于以下问题:C++ NodeQuerySynthesizedAttributeType::end方法的具体用法?C++ NodeQuerySynthesizedAttributeType::end怎么用?C++ NodeQuerySynthesizedAttributeType::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NodeQuerySynthesizedAttributeType的用法示例。


在下文中一共展示了NodeQuerySynthesizedAttributeType::end方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

NodeQuerySynthesizedAttributeType NodeQuery::queryNodeList ( NodeQuerySynthesizedAttributeType nodeList, VariantVector targetVariantVector)
   {
     NodeQuerySynthesizedAttributeType returnList;

     AstQueryNamespace::queryRange(nodeList.begin(), nodeList.end(), boost::bind(querySolverGrammarElementFromVariantVector, _1,targetVariantVector,&returnList));

     return returnList;
   }
开发者ID:LindaLovelace,项目名称:rose,代码行数:8,代码来源:nodeQuery.C

示例2: 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;
}
开发者ID:LindaLovelace,项目名称:rose,代码行数:55,代码来源:runTest.C

示例3: 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;
}
开发者ID:billhoffman,项目名称:rose-develop,代码行数:11,代码来源:testVirtualCFG.C

示例4:

/** 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();
}
开发者ID:Federico2014,项目名称:edg4x-rose,代码行数:17,代码来源:testQuery.C

示例5: 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;
}
开发者ID:8l,项目名称:rose,代码行数:20,代码来源:MintArrayInterface.C

示例6: main

int main(int argc, char *argv[]) {

	struct timespec ts_now;
	long mtime_0, mtime_1, mtime_2, mtime_3;

	SgProject* sageProject = frontend(argc,argv);

	clock_gettime(CLOCK_MONOTONIC, &ts_now)    ;
	mtime_0 = ts_now.tv_sec * 1000000 + ts_now.tv_nsec/1000;

	AstTests::runAllTests(sageProject);

	clock_gettime(CLOCK_MONOTONIC, &ts_now)    ;
	mtime_1 = ts_now.tv_sec * 1000000 + ts_now.tv_nsec/1000;

	NodeQuerySynthesizedAttributeType functions = NodeQuery::querySubTree(sageProject, V_SgFunctionDefinition);

	clock_gettime(CLOCK_MONOTONIC, &ts_now)    ;
	mtime_2 = ts_now.tv_sec * 1000000 + ts_now.tv_nsec/1000;

	for (NodeQuerySynthesizedAttributeType::const_iterator i = functions.begin(); i != functions.end(); ++i) {
		SgFunctionDefinition* proc = isSgFunctionDefinition(*i);
		ROSE_ASSERT (proc);
		testCFG(proc);
	}

	clock_gettime(CLOCK_MONOTONIC, &ts_now)    ;
	mtime_3 = ts_now.tv_sec * 1000000 + ts_now.tv_nsec/1000;


	cout << "--------------------------------------------------" << endl;
	cout << "runAllTests: " << mtime_1 - mtime_0 << endl;
	cout << "pre-process: " << mtime_2 - mtime_1  << endl;
	cout << "cfg: " << mtime_3 - mtime_2  << endl;
	cout << "--------------------------------------------------" << endl;
	return 0;
}
开发者ID:ian-bertolacci,项目名称:rose-develop,代码行数:37,代码来源:testStaticCFG.C

示例7: 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
	EDefUse *defUseAnalysis=new EDefUse(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->computeAdditionalFunctioncallDepencencies();
			cdg->computeInterproceduralInformation(ipi);

			// get the data dependence for this function
			ddg = new DataDependenceGraph(fDec->get_definition(), defUseAnalysis,ipi);
			
			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());			
	set<SgNode*> preserve;
	if (sdg->getMainFunction()!=NULL) {
	preserve.insert(sdg->getMainFunction());
	sdg->cleanUp(preserve);
	}
	filename = (outputFileName)+".final.sdg.dot";
	sdg->writeDot((char *)filename.c_str());			
}
开发者ID:Federico2014,项目名称:edg4x-rose,代码行数:98,代码来源:generateSDG.C

示例8: 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;
}
开发者ID:Federico2014,项目名称:edg4x-rose,代码行数:66,代码来源:testQuery.C

示例9: 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();
  
  //example usage
  // testing
  NodeQuerySynthesizedAttributeType vars = NodeQuery::querySubTree(project, V_SgInitializedName); 
  NodeQuerySynthesizedAttributeType::const_iterator i = vars.begin();
  for (; i!=vars.end();++i) {
    SgInitializedName* initName = isSgInitializedName(*i);
    std::string name = initName->get_qualified_name().str();
  
    vector<SgNode* > vec = defuse->getDefFor(initName, initName);
    if (vec.size()>0)
      if (debug)
	std::cout << "  DEF>> Vector entries for " << name <<  " ( " << 
	  initName << " ) : " << vec.size() << std::endl;

  }

  // testing
  vars = NodeQuery::querySubTree(project, V_SgReturnStmt); 
  i = vars.begin();
  typedef std::vector <std::pair <SgInitializedName*, SgNode* > > maptype; 
  for (; i!=vars.end();++i) {
    SgReturnStmt* ret = isSgReturnStmt(*i);
    ROSE_ASSERT(ret);
    
    maptype map = defuse->getUseMultiMapFor(ret);    
    maptype::const_iterator j;
    j = map.begin();
    for (; j!=map.end();++j) {
      SgInitializedName* initName = isSgInitializedName(j->first);
      ROSE_ASSERT(initName);
      std::string name = initName->get_qualified_name().str();
      
      vector<SgNode* > vec = defuse->getUseFor(ret, initName);
      if (vec.size()>0)
	std::cout << "  USE>> Vector entries for " << name <<  " ( " << 
	  ret << " ) : " << vec.size() << std::endl;

    }
  }
  // print resulting table
  if (debug_map) {
      cout << "\nDEFMAP" << endl;
    defuse->printDefMap();
      cout << "\nUSEMAP" << endl;
    defuse->printUseMap();
  }
  delete project;
  delete defuse;
}
开发者ID:Federico2014,项目名称:edg4x-rose,代码行数:69,代码来源:runTest.C

示例10: testOneFunction

void testOneFunction( std::string funcParamName, 
		      vector<string> argvList,
		      bool debug, int nrOfNodes, 
		      multimap <string, int> results,
		      multimap <string, int> useresults) {
  if (debug)
    cout <<"\n\n------------------------------------------\ntesting ... " << 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::cout << "Analysis run is : " << (val ?  "failure" : "success" ) << " " << val << std::endl;
  if (val==1) exit(1);

  if (debug==false)
    defuse->dfaToDOT();

  //std::list<SgNode*> vars = NodeQuery::querySubTree(project, V_SgFunctionDefinition);
  //std::list<SgNode*>::const_iterator i = vars.begin();
  NodeQuerySynthesizedAttributeType vars = NodeQuery::querySubTree(project, V_SgFunctionDefinition);
  NodeQuerySynthesizedAttributeType::const_iterator i = vars.begin();
  for (; i!=vars.end();++i) {
    SgFunctionDefinition* func = isSgFunctionDefinition(*i);
    std::string name = func->class_name();
    string funcName = func->get_declaration()->get_qualified_name().str();
    int maxNodes = defuse->getDefSize();
    int nodeNr = defuse->getIntForSgNode(func);
    if (nodeNr == -1)
      continue;
    //cout << " checking function : " << funcName << endl;
    if (funcName!=funcParamName)
      continue;

    if (debug)
      cout << "\n------------------------\nchecking for " << name << " -- " << funcName << " -- " << nodeNr << endl;
    if (maxNodes!=nrOfNodes) {
	cerr << " Error: Test should have " << nrOfNodes << " nodes. found: " << maxNodes << endl;
      abort();
    }
    if (debug)
      cout << " Test has nodes:  " << nrOfNodes <<  endl;
    if (debug)
      cout <<"\nChecking all definitions ... " << endl;
    // check nodes in multimap
    std::vector <std::pair < SgInitializedName*, SgNode*> > map = defuse->getDefMultiMapFor(func);
    if (map.size()>0) {
      std::vector < std::pair <SgInitializedName*, SgNode*> >::const_iterator j = map.begin();
      unsigned int hit=0;
      SgNode* node = NULL;
      string name="";
      for (;j!=map.end();++j) {
	SgInitializedName* in_node = j->first;
	node = j->second;
	name= in_node->get_qualified_name().str();
	if (debug)
	  cout << " ... checking :  " << name << endl;
	multimap <string, int>::const_iterator k =results.begin();
	for (;k!=results.end();++k) {
	  string resName = k->first;
	  int resNr = k->second;
	  int tableNr = defuse->getIntForSgNode(node);
	  if (name==resName)
	    if (debug)
	      cout << " ... defNr: " << resNr << "  inTable: " << tableNr <<  endl; 
	  if (name==resName && tableNr==resNr) {
	    hit++;
	    if (debug)
	      cout << " Hit " << hit << "/" << results.size() << " - (" << name << "," << resNr << ")" << endl;
	  }
	}

      }
      if (hit!=results.size()) {
	cerr << " Error: No hit! ... DFA values of node " << nodeNr << " are not correct! " << endl;
	exit(1);
      }
    } else {
      if (results.size()!=0) {
	cerr << " Error: Test node " << defuse->getIntForSgNode(func) << " should have a multimap. " << endl;
	exit(1);
      }
    }
  
    if (debug)
      cout <<"\nChecking all uses ... " << endl;
    // check nodes in multimap
    map = defuse->getUseMultiMapFor(func);
    if (map.size()>0) {
      std::vector <std::pair <SgInitializedName*, SgNode*> >::const_iterator j = map.begin();
      size_t hit=0;
      for (;j!=map.end();++j) {
	SgInitializedName* in_node = j->first;
	SgNode* node = j->second;
	string name= in_node->get_qualified_name().str();
	if (debug)
	  cout << " ... checking :  " << name << endl;
	multimap <string, int>::const_iterator k =useresults.begin();
	for (;k!=useresults.end();++k) {
//.........这里部分代码省略.........
开发者ID:Federico2014,项目名称:edg4x-rose,代码行数:101,代码来源:runTest.C

示例11: 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());

        }
    }
}
开发者ID:billhoffman,项目名称:rose-develop,代码行数:53,代码来源:generateCDG.C

示例12: main

int main(int argc, char *argv[])
{
	std::string filename;

    SgProject *project = frontend(argc, argv);
#ifdef NEWDU
    EDefUse *edu=new EDefUse(project);
		// Create the global def-use analysis
		if (edu->run(false)==0)
		{
			std::cerr<<"DFAnalysis failed!"<<endl;
		}
#endif
		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++)
    {
        DataDependenceGraph *ddg;
        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 the data dependence for this function
#ifdef NEWDU
            ddg = new DataDependenceGraph(fD->get_definition(),edu);
#else
            ddg = new DataDependenceGraph(fD->get_definition());
#endif
						//printf("DDG for %s:\n", fD->get_name().str());
						
// Liao, Feb. 7/2008,
//strip off absolute path to avoid polluting the source tree with generated .dot files
            //filename = (fD->get_definition()->get_file_info()->get_filenameString ()) 
            filename = StringUtility::stripPathFromFileName((fD->get_definition()->get_file_info()->get_filenameString ()))
         + "." + (fD->get_name().getString()) + ".ddg.dot";
            ddg->writeDot((char *)filename.c_str());

        }   
    }
		return 0;
}
开发者ID:billhoffman,项目名称:rose-develop,代码行数:64,代码来源:generateDDG.C

示例13: 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;
//.........这里部分代码省略.........
开发者ID:LindaLovelace,项目名称:rose,代码行数:101,代码来源:runTest.C


注:本文中的NodeQuerySynthesizedAttributeType::end方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。