r196648 - Changed ConditionValue argument to PPCallbacks If and Elif callbacks to be a 3-state enum.

John Thompson John.Thompson.JTSoftware at gmail.com
Sat Dec 7 00:41:15 PST 2013


Author: jtsoftware
Date: Sat Dec  7 02:41:15 2013
New Revision: 196648

URL: http://llvm.org/viewvc/llvm-project?rev=196648&view=rev
Log:
Changed ConditionValue argument to PPCallbacks If and Elif callbacks to be a 3-state enum.

Modified:
    cfe/trunk/include/clang/Lex/PPCallbacks.h
    cfe/trunk/include/clang/Lex/PPConditionalDirectiveRecord.h
    cfe/trunk/lib/Lex/PPConditionalDirectiveRecord.cpp
    cfe/trunk/lib/Lex/PPDirectives.cpp

Modified: cfe/trunk/include/clang/Lex/PPCallbacks.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PPCallbacks.h?rev=196648&r1=196647&r2=196648&view=diff
==============================================================================
--- cfe/trunk/include/clang/Lex/PPCallbacks.h (original)
+++ cfe/trunk/include/clang/Lex/PPCallbacks.h Sat Dec  7 02:41:15 2013
@@ -267,6 +267,10 @@ public:
   virtual void SourceRangeSkipped(SourceRange Range) {
   }
 
+  enum ConditionValueKind {
+    CVK_NotEvaluated, CVK_False, CVK_True
+  };
+
   /// \brief Hook called whenever an \#if is seen.
   /// \param Loc the source location of the directive.
   /// \param ConditionRange The SourceRange of the expression being tested.
@@ -274,7 +278,7 @@ public:
   ///
   // FIXME: better to pass in a list (or tree!) of Tokens.
   virtual void If(SourceLocation Loc, SourceRange ConditionRange,
-                  bool ConditionValue) {
+                  ConditionValueKind ConditionValue) {
   }
 
   /// \brief Hook called whenever an \#elif is seen.
@@ -284,7 +288,7 @@ public:
   /// \param IfLoc the source location of the \#if/\#ifdef/\#ifndef directive.
   // FIXME: better to pass in a list (or tree!) of Tokens.
   virtual void Elif(SourceLocation Loc, SourceRange ConditionRange,
-                    bool ConditionValue, SourceLocation IfLoc) {
+                    ConditionValueKind ConditionValue, SourceLocation IfLoc) {
   }
 
   /// \brief Hook called whenever an \#ifdef is seen.
@@ -473,14 +477,14 @@ public:
 
   /// \brief Hook called whenever an \#if is seen.
   virtual void If(SourceLocation Loc, SourceRange ConditionRange,
-                  bool ConditionValue) {
+                  ConditionValueKind ConditionValue) {
     First->If(Loc, ConditionRange, ConditionValue);
     Second->If(Loc, ConditionRange, ConditionValue);
   }
 
   /// \brief Hook called whenever an \#elif is seen.
   virtual void Elif(SourceLocation Loc, SourceRange ConditionRange,
-                    bool ConditionValue, SourceLocation IfLoc) {
+                    ConditionValueKind ConditionValue, SourceLocation IfLoc) {
     First->Elif(Loc, ConditionRange, ConditionValue, IfLoc);
     Second->Elif(Loc, ConditionRange, ConditionValue, IfLoc);
   }

Modified: cfe/trunk/include/clang/Lex/PPConditionalDirectiveRecord.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PPConditionalDirectiveRecord.h?rev=196648&r1=196647&r2=196648&view=diff
==============================================================================
--- cfe/trunk/include/clang/Lex/PPConditionalDirectiveRecord.h (original)
+++ cfe/trunk/include/clang/Lex/PPConditionalDirectiveRecord.h Sat Dec  7 02:41:15 2013
@@ -87,9 +87,9 @@ public:
 
 private:
   virtual void If(SourceLocation Loc, SourceRange ConditionRange,
-                  bool ConditionValue);
+                  ConditionValueKind ConditionValue);
   virtual void Elif(SourceLocation Loc, SourceRange ConditionRange,
-                    bool ConditionValue, SourceLocation IfLoc);
+                    ConditionValueKind ConditionValue, SourceLocation IfLoc);
   virtual void Ifdef(SourceLocation Loc, const Token &MacroNameTok,
                      const MacroDirective *MD);
   virtual void Ifndef(SourceLocation Loc, const Token &MacroNameTok,

Modified: cfe/trunk/lib/Lex/PPConditionalDirectiveRecord.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPConditionalDirectiveRecord.cpp?rev=196648&r1=196647&r2=196648&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PPConditionalDirectiveRecord.cpp (original)
+++ cfe/trunk/lib/Lex/PPConditionalDirectiveRecord.cpp Sat Dec  7 02:41:15 2013
@@ -77,7 +77,7 @@ void PPConditionalDirectiveRecord::addCo
 
 void PPConditionalDirectiveRecord::If(SourceLocation Loc,
                                       SourceRange ConditionRange,
-                                      bool ConditionValue) {
+                                      ConditionValueKind ConditionValue) {
   addCondDirectiveLoc(CondDirectiveLoc(Loc, CondDirectiveStack.back()));
   CondDirectiveStack.push_back(Loc);
 }
@@ -98,7 +98,7 @@ void PPConditionalDirectiveRecord::Ifnde
 
 void PPConditionalDirectiveRecord::Elif(SourceLocation Loc,
                                         SourceRange ConditionRange,
-                                        bool ConditionValue,
+                                        ConditionValueKind ConditionValue,
                                         SourceLocation IfLoc) {
   addCondDirectiveLoc(CondDirectiveLoc(Loc, CondDirectiveStack.back()));
   CondDirectiveStack.back() = Loc;

Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=196648&r1=196647&r2=196648&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
+++ cfe/trunk/lib/Lex/PPDirectives.cpp Sat Dec  7 02:41:15 2013
@@ -424,7 +424,7 @@ void Preprocessor::SkipExcludedCondition
             const SourceLocation CondEnd = CurPPLexer->getSourceLocation();
             Callbacks->Elif(Tok.getLocation(),
                             SourceRange(CondBegin, CondEnd),
-                            CondValue, CondInfo.IfLoc);
+                            (CondValue ? PPCallbacks::CVK_True : PPCallbacks::CVK_False), CondInfo.IfLoc);
           }
           // If this condition is true, enter it!
           if (CondValue) {
@@ -2280,7 +2280,7 @@ void Preprocessor::HandleIfDirective(Tok
   if (Callbacks)
     Callbacks->If(IfToken.getLocation(),
                   SourceRange(ConditionalBegin, ConditionalEnd),
-                  ConditionalTrue);
+                  (ConditionalTrue ? PPCallbacks::CVK_True : PPCallbacks::CVK_False));
 
   // Should we include the stuff contained by this directive?
   if (ConditionalTrue) {
@@ -2377,7 +2377,7 @@ void Preprocessor::HandleElifDirective(T
   if (Callbacks)
     Callbacks->Elif(ElifToken.getLocation(),
                     SourceRange(ConditionalBegin, ConditionalEnd),
-                    true, CI.IfLoc);
+                    PPCallbacks::CVK_NotEvaluated, CI.IfLoc);
 
   // Finally, skip the rest of the contents of this block.
   SkipExcludedConditionalBlock(CI.IfLoc, /*Foundnonskip*/true,





More information about the cfe-commits mailing list