# HG changeset patch # User Shinji KONO # Date 1591006100 -32400 # Node ID 2ba137afec0fef085560890fe39eb12863076ef6 # Parent 0f533c0a1429d61ee07fb8c86b60f9d6a641b57c add RAII on Action diff -r 0f533c0a1429 -r 2ba137afec0f clang/lib/Parse/ParseCbC.cpp --- a/clang/lib/Parse/ParseCbC.cpp Sun May 31 19:50:32 2020 +0900 +++ b/clang/lib/Parse/ParseCbC.cpp Mon Jun 01 19:08:20 2020 +0900 @@ -804,6 +804,7 @@ innerR = Actions.ActOnExprStmt(ljExpr); if(innerR.isUsable()) FnStmts.push_back(innerR.get()); + Sema::CompoundScopeRAII CompoundScope(Actions); FnBody = Actions.ActOnCompoundStmt(Loc, Loc, FnStmts, false); BodyScope.Exit(); TheDecl = Actions.ActOnFinishFunctionBody(BodyRes, FnBody.get()); @@ -852,7 +853,8 @@ NamedDecl *ND = getNonTypeAnnotation(IITok); ExprResult E; E = Actions.ActOnNameClassifiedAsNonType(getCurScope(), SS, ND, Loc, IITok); - return E; + setExprAnnotation(IITok, E); + return getExprAnnotation(IITok); } /// CreateComplexStmtRet - Create return value for complex statements. @@ -1123,4 +1125,28 @@ } } +std::string get_string(const Expr *expr, const ASTContext &Context) { + PrintingPolicy print_policy(Context.getLangOpts()); + print_policy.FullyQualifiedName = 1; + print_policy.SuppressScope = 0; + print_policy.SuppressUnwrittenScope = 0; + std::string expr_string; + llvm::raw_string_ostream stream(expr_string); + expr->printPretty(stream, nullptr, print_policy); + stream.flush(); + return expr_string; +} + +std::string get_string(const Stmt *expr, const ASTContext &Context) { + PrintingPolicy print_policy(Context.getLangOpts()); + print_policy.FullyQualifiedName = 1; + print_policy.SuppressScope = 0; + print_policy.SuppressUnwrittenScope = 0; + std::string expr_string; + llvm::raw_string_ostream stream(expr_string); + expr->printPretty(stream, nullptr, print_policy); + stream.flush(); + return expr_string; +} + #endif