[cfe-commits] r38541 - in /cfe/cfe/trunk: Lex/PPExpressions.cpp Lex/Preprocessor.cpp include/clang/Lex/Preprocessor.h

sabre at cs.uiuc.edu sabre at cs.uiuc.edu
Wed Jul 11 09:22:22 PDT 2007


Author: sabre
Date: Wed Jul 11 11:22:21 2007
New Revision: 38541

URL: http://llvm.org/viewvc/llvm-project?rev=38541&view=rev
Log:
Simplify an API

Modified:
    cfe/cfe/trunk/Lex/PPExpressions.cpp
    cfe/cfe/trunk/Lex/Preprocessor.cpp
    cfe/cfe/trunk/include/clang/Lex/Preprocessor.h

Modified: cfe/cfe/trunk/Lex/PPExpressions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Lex/PPExpressions.cpp?rev=38541&r1=38540&r2=38541&view=diff

==============================================================================
--- cfe/cfe/trunk/Lex/PPExpressions.cpp (original)
+++ cfe/cfe/trunk/Lex/PPExpressions.cpp Wed Jul 11 11:22:21 2007
@@ -30,21 +30,18 @@
 ///
 /// MinPrec is the minimum precedence that this range of the expression is
 /// allowed to include.
-void Preprocessor::EvaluateDirectiveExpression(bool &Result) {
+bool Preprocessor::EvaluateDirectiveExpression() {
   // Peek ahead one token.
   LexerToken Tok;
   Lex(Tok);
 
-  // In error cases, bail out with false value.
-  Result = false;
-  
   int ResVal = 0;
   if (EvaluateValue(ResVal, Tok) ||
       EvaluateDirectiveSubExpr(ResVal, 1, Tok)) {
     // Skip the rest of the macro line.
     if (Tok.getKind() != tok::eom)
       DiscardUntilEndOfDirective();
-    return;
+    return false;
   }
   
   // If we aren't at the tok::eom token, something bad happened, like an extra
@@ -54,7 +51,7 @@
     DiscardUntilEndOfDirective();
   }
   
-  Result = ResVal != 0;
+  return ResVal != 0;
 }
 
 /// EvaluateValue - Evaluate the token PeekTok (and any others needed) and

Modified: cfe/cfe/trunk/Lex/Preprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Lex/Preprocessor.cpp?rev=38541&r1=38540&r2=38541&view=diff

==============================================================================
--- cfe/cfe/trunk/Lex/Preprocessor.cpp (original)
+++ cfe/cfe/trunk/Lex/Preprocessor.cpp Wed Jul 11 11:22:21 2007
@@ -621,7 +621,7 @@
           // looked up, etc, inside the #elif expression.
           assert(SkippingContents && "We have to be skipping here!");
           SkippingContents = false;
-          EvaluateDirectiveExpression(ShouldEnter);
+          ShouldEnter = EvaluateDirectiveExpression();
           SkippingContents = true;
         }
         
@@ -1011,8 +1011,7 @@
   ++NumIf;
   const char *Start = CurLexer->BufferPtr;
 
-  bool ConditionalTrue = false;
-  EvaluateDirectiveExpression(ConditionalTrue);
+  bool ConditionalTrue = EvaluateDirectiveExpression();
   
   // Should we include the stuff contained by this directive?
   if (ConditionalTrue) {

Modified: cfe/cfe/trunk/include/clang/Lex/Preprocessor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=38541&r1=38540&r2=38541&view=diff

==============================================================================
--- cfe/cfe/trunk/include/clang/Lex/Preprocessor.h (original)
+++ cfe/cfe/trunk/include/clang/Lex/Preprocessor.h Wed Jul 11 11:22:21 2007
@@ -332,12 +332,10 @@
   /// EvaluateDirectiveExpression - Evaluate an integer constant expression that
   /// may occur after a #if or #elif directive.  Sets Result to the result of
   /// the expression.
-  void EvaluateDirectiveExpression(bool &Result);
-  /// EvaluateValue - Used to implement EvaluateDirectiveExpression,
-  /// see PPExpressions.cpp.
+  bool EvaluateDirectiveExpression();
+  /// EvaluateValue/EvaluateDirectiveSubExpr - Used to implement
+  /// EvaluateDirectiveExpression, see PPExpressions.cpp.
   bool EvaluateValue(int &Result, LexerToken &PeekTok);
-  /// EvaluateDirectiveSubExpr - Used to implement EvaluateDirectiveExpression,
-  /// see PPExpressions.cpp.
   bool EvaluateDirectiveSubExpr(int &LHS, unsigned MinPrec,
                                 LexerToken &PeekTok);
   





More information about the cfe-commits mailing list