本文整理汇总了C++中SgScopeStatement::get_endOfConstruct方法的典型用法代码示例。如果您正苦于以下问题:C++ SgScopeStatement::get_endOfConstruct方法的具体用法?C++ SgScopeStatement::get_endOfConstruct怎么用?C++ SgScopeStatement::get_endOfConstruct使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SgScopeStatement
的用法示例。
在下文中一共展示了SgScopeStatement::get_endOfConstruct方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
void
RtedTransformation::changeReturnStmt(ReturnInfo rinfo)
{
SgReturnStmt* const rstmt = rinfo.stmt;
SgExpression* const returnExpr = rstmt->get_expression();
requiresParentIsBasicBlock(*rstmt);
if (!returnExpr)
{
// function returns a value but return statement has no expression
insertErrorReport(*rstmt, "return statement is expected to return a value");
return;
}
// We need to build a new variable of type returnExpr
// \pp why do we have to do that?
// most likely b/c exitScope clears all local pointers ...
SgScopeStatement* scope = rstmt->get_scope();
SgType* const typeRet = returnExpr->get_type();
std::string name = "rstmt";
ROSE_ASSERT(scope);
name.append(scope->get_qualified_name().str());
SgName rName( name );
SgAssignInitializer* init = SB::buildAssignInitializer(returnExpr);
SgVariableDeclaration* resDecl = SB::buildVariableDeclaration( rName, typeRet, init, scope );
SgInitializedName& resVar = SI::getFirstVariable(*resDecl);
SgVarRefExp* const vexp = SB::buildVarRefExp(rName, scope);
SgStatement* const newRtnStmt = SB::buildReturnStmt( vexp );
SI::replaceStatement( rstmt, newRtnStmt );
SI::insertStatementBefore( newRtnStmt, resDecl );
Sg_File_Info* const fileinfo = scope->get_endOfConstruct();
// handle C++ only if the function returns a pointer
if (rinfo.filetype != ftCxx)
{
SgStatement* const exitStmt = (rinfo.expected_return == ReturnInfo::rtValue)
? buildExitBlockStmt(rinfo.open_blocks, *scope, fileinfo)
: buildDelayedLeakCheckExitStmt(rinfo.filetype, rinfo.open_blocks, *scope, resVar, fileinfo)
;
SI::insertStatementBefore( newRtnStmt, exitStmt );
}
else if (rinfo.expected_return == ReturnInfo::rtIndirection)
{
SgStatement* const exitStmt = buildDelayedLeakCheckExitStmt(rinfo.filetype, rinfo.open_blocks, *scope, resVar, fileinfo);
SI::insertStatementBefore( newRtnStmt, exitStmt );
}
}