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


C++ SgScopeStatement::get_endOfConstruct方法代码示例

本文整理汇总了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 );
  }
}
开发者ID:jacob-lidman,项目名称:rose,代码行数:55,代码来源:RtedTransf_returnStmt.cpp


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