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 ); } }
string Doxygen::getProtoName(SgDeclarationStatement *st) { SgScopeStatement *scope; if (SgVariableDeclaration* varDeclSt = isSgVariableDeclaration(st)) { // TODO: uncomment SgVariableDeclaration::get_scope removing need for this code scope = varDeclSt->get_variables().front()->get_scope(); } else { scope = st->get_scope(); } if (isSgGlobal(scope)) { return getDeclStmtName(st); } else { SgUnparse_Info info; info.set_SkipSemiColon(); info.set_SkipFunctionDefinition(); info.set_forceQualifiedNames(); info.set_skipCheckAccess(); info.set_SkipInitializer(); info.set_SkipClassSpecifier(); //AS(091507) In the new version of ROSE global qualifiers are paret of the qualified name of //a scope statement. For the documentation work we do not want that and we therefore use string::substr() //to trim of "::" from the front of the qualified name. if( scope->get_qualified_name().getString().length() > 2 ) { return scope->get_qualified_name().getString().substr(2)+("::"+getDeclStmtName(st)); } else { return getDeclStmtName(st); } //return scope->get_qualified_name().str()+("::"+getDeclStmtName(st)); } }