changeset 183:2ba137afec0f

add RAII on Action
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 01 Jun 2020 19:08:20 +0900
parents 0f533c0a1429
children 9b4cb9bbd23d
files clang/lib/Parse/ParseCbC.cpp
diffstat 1 files changed, 27 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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