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


C++ LabelSet::toString方法代码示例

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


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

示例1: finalLabels

LabelSet CFAnalyzer::finalLabels(SgNode* node) {
  assert(node);
  assert(labeler->isLabelRelevantNode(node));
  LabelSet finalSet;

  // special case of incExpr in SgForStatement
  if(SgNodeHelper::isForIncExpr(node)) {
	finalSet.insert(labeler->getLabel(node));
	return finalSet;
  }

  // special case of function call
  if(SgNodeHelper::Pattern::matchFunctionCall(node)) {
	if(SgNodeHelper::Pattern::matchReturnStmtFunctionCallExp(node)) {
	  finalSet.insert(labeler->functionCallReturnLabel(node)+1); // special case of function call in return-stmt
	} else {
	  finalSet.insert(labeler->functionCallReturnLabel(node));
	}
	return finalSet;
  }

  switch (node->variantT()) {
  // function declarations inside basic block
  case V_SgFunctionDeclaration:
	  finalSet.insert(labeler->getLabel(node));
	  return finalSet;
  case V_SgFunctionDefinition: {
	SgBasicBlock* body=isSgFunctionDefinition(node)->get_body();
	return finalLabels(body);
  }
  case V_SgBreakStmt:
	return finalSet;
  case V_SgReturnStmt:
	return finalSet;
  case V_SgNullStatement:
  case V_SgLabelStatement:
  case V_SgInitializedName:
  case V_SgVariableDeclaration:
	  finalSet.insert(labeler->getLabel(node));
	  return finalSet;
  case V_SgExprStatement: {
	finalSet.insert(labeler->getLabel(node));
	return finalSet;
  }

  case V_SgIfStmt: {
	SgNode* nodeTB=SgNodeHelper::getTrueBranch(node);
	LabelSet finalSetTB=finalLabels(nodeTB);
	finalSet+=finalSetTB;
	if(SgNode* nodeFB=SgNodeHelper::getFalseBranch(node)) {
	  LabelSet finalSetFB=finalLabels(nodeFB);
	  finalSet+=finalSetFB;
	} else {
	  // in case of an empty else branch the cond node becomes the final node
	  SgNode* condNode=SgNodeHelper::getCond(node);
	  finalSet.insert(labeler->getLabel(condNode));
	}
	return finalSet;
  }
  case V_SgForStatement:
  case V_SgDoWhileStmt:
  case V_SgWhileStmt: {
	SgNode* condNode=SgNodeHelper::getCond(node);
	finalSet.insert(labeler->getLabel(condNode));
    set<SgNode*> breakNodes=SgNodeHelper::LoopRelevantBreakStmtNodes(node);
	LabelSet lset=labeler->getLabelSet(breakNodes);
	finalSet+=lset;
	cout << finalSet.toString() << endl;
	return finalSet;
  }
  case V_SgBasicBlock: {
	if(SgNodeHelper::numChildren(node)>0) {
	  SgNode* lastNode=SgNodeHelper::getLastOfBlock(node);
	  LabelSet s=finalLabels(lastNode);
	  finalSet+=s;
	} else {
	  // empty basic block
	  finalSet.insert(initialLabel(node));
	}
	return finalSet;
  }
  case V_SgFunctionCallExp:
	finalSet.insert(labeler->functionCallReturnLabel(node));
	return finalSet;

  default:
	cerr << "Error: Unknown node in CodeThorn::CFAnalyzer::finalLabels: "<<node->sage_class_name()<<endl; exit(1);
   }
}
开发者ID:adrian-prantl,项目名称:rose,代码行数:89,代码来源:CFAnalyzer.C


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