changeset 47:5b813d18f000

replace __environment with &__CbC_environment in a code segment's arguments
author Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
date Thu, 02 Jan 2014 01:28:55 +0900
parents ced88226fdc5
children 4b59af982ef3
files tools/clang/include/clang/Parse/Parser.h tools/clang/lib/Parse/ParseCbC.cpp tools/clang/lib/Parse/ParseExpr.cpp tools/clang/lib/Parse/Parser.cpp
diffstat 4 files changed, 26 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/tools/clang/include/clang/Parse/Parser.h	Wed Jan 01 22:30:48 2014 +0900
+++ b/tools/clang/include/clang/Parse/Parser.h	Thu Jan 02 01:28:55 2014 +0900
@@ -1505,6 +1505,7 @@
 #ifndef noCbC // for CbC
   StmtVector* Stmtsp;
   IdentifierInfo *bufII, *retvalII;
+  bool preparedGotoWithTheEnv;
 #endif
 
   StmtResult ParseStatement(SourceLocation *TrailingElseLoc = 0);
@@ -1703,7 +1704,7 @@
   void ParseStructDeclaration(ParsingDeclSpec &DS, FieldCallback &Callback);
 
 #ifndef noCbC
-  void PrepareForContinuationWithTheEnv();
+  void PrepareForGotoWithTheEnv();
   void Create__CbC_envStruct(SourceLocation Loc, AccessSpecifier AS);
   IdentifierInfo* CreateIdentifierInfo(const char* Name, int NameLen, SourceLocation Loc);
   Decl* Create__CbC_envBody(Decl* TagDecl, DeclSpec::TST T, SourceLocation Loc, const char* Name, int NameLen);
--- a/tools/clang/lib/Parse/ParseCbC.cpp	Wed Jan 01 22:30:48 2014 +0900
+++ b/tools/clang/lib/Parse/ParseCbC.cpp	Thu Jan 02 01:28:55 2014 +0900
@@ -111,7 +111,7 @@
 }
 
 
-void Parser::PrepareForContinuationWithTheEnv(){
+void Parser::PrepareForGotoWithTheEnv(){
   StmtResult Res;
   SourceLocation Loc = Tok.getLocation();
 
--- a/tools/clang/lib/Parse/ParseExpr.cpp	Wed Jan 01 22:30:48 2014 +0900
+++ b/tools/clang/lib/Parse/ParseExpr.cpp	Thu Jan 02 01:28:55 2014 +0900
@@ -2427,20 +2427,32 @@
       Expr = ParseBraceInitializer();
     } 
 #ifndef noCbC
-    else if (Tok.is(tok::kw___return)){
+    else if (Tok.is(tok::kw___return) || Tok.is(tok::kw___environment)){
+      bool isKw__env = Tok.is(tok::kw___environment);
       IdentifierInfo *II;
-      PrepareForContinuationWithTheEnv();
-      II = CreateIdentifierInfo(__CBC_RETURN_NAME, __CBC_RETURN_LENGTH, Tok.getLocation());
+      if (!preparedGotoWithTheEnv) {
+	PrepareForGotoWithTheEnv();
+	preparedGotoWithTheEnv = true;
+      }
+      else
+	preparedGotoWithTheEnv = false;
+
+      if (isKw__env)
+	II = CreateIdentifierInfo(__CBC_ENVIRONMENT_NAME, __CBC_ENVIRONMENT_LENGTH, Tok.getLocation());
+      else
+	II = CreateIdentifierInfo(__CBC_RETURN_NAME, __CBC_RETURN_LENGTH, Tok.getLocation());
+	
       SourceLocation ILoc = ConsumeToken();
       UnqualifiedId Name;
       Name.setIdentifier(II, ILoc);
       CXXScopeSpec SS;
       SourceLocation TemplateKWLoc;
-
       CastExpressionIdValidator Validator(false, true);
-      Expr = ParseRHSOfBinaryExpression(ParsePostfixExpressionSuffix(Actions.ActOnIdExpression(getCurScope(), SS, TemplateKWLoc, Name,
-											       Tok.is(tok::l_paren), false, &Validator)),prec::Assignment);
-      
+      Expr = ParsePostfixExpressionSuffix(Actions.ActOnIdExpression(getCurScope(), SS, TemplateKWLoc, Name, 
+								    Tok.is(tok::l_paren), isKw__env, &Validator));
+      if (isKw__env)
+	Expr = Actions.ActOnUnaryOp(getCurScope(), ILoc, tok::amp, Expr.get());
+      Expr = ParseRHSOfBinaryExpression(Expr, prec::Assignment);
     }
 #endif
     else
--- a/tools/clang/lib/Parse/Parser.cpp	Wed Jan 01 22:30:48 2014 +0900
+++ b/tools/clang/lib/Parse/Parser.cpp	Thu Jan 02 01:28:55 2014 +0900
@@ -61,6 +61,10 @@
   ParenCount = BracketCount = BraceCount = 0;
   CurParsedObjCImpl = 0;
 
+#ifndef noCbC
+  preparedGotoWithTheEnv = false;
+#endif
+
   // Add #pragma handlers. These are removed and destroyed in the
   // destructor.
   AlignHandler.reset(new PragmaAlignHandler());