[cfe-commits] r57397 - in /cfe/trunk: include/clang/Lex/Lexer.h lib/Lex/Lexer.cpp

Chris Lattner sabre at nondot.org
Sat Oct 11 20:22:09 PDT 2008


Author: lattner
Date: Sat Oct 11 22:22:02 2008
New Revision: 57397

URL: http://llvm.org/viewvc/llvm-project?rev=57397&view=rev
Log:
add a new inKeepCommentMode() accessor to abstract the KeepCommentMode
ivar.

Modified:
    cfe/trunk/include/clang/Lex/Lexer.h
    cfe/trunk/lib/Lex/Lexer.cpp

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

==============================================================================
--- cfe/trunk/include/clang/Lex/Lexer.h (original)
+++ cfe/trunk/include/clang/Lex/Lexer.h Sat Oct 11 22:22:02 2008
@@ -158,6 +158,13 @@
     KeepCommentMode = Mode;
   }
   
+  /// inKeepCommentMode - Return true if the lexer should return comments as
+  /// tokens.
+  bool inKeepCommentMode() const {
+    return KeepCommentMode;
+  }
+  
+  
   /// ReadToEndOfLine - Read the rest of the current preprocessor line as an
   /// uninterpreted string.  This switches the lexer out of directive mode.
   std::string ReadToEndOfLine();

Modified: cfe/trunk/lib/Lex/Lexer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=57397&r1=57396&r2=57397&view=diff

==============================================================================
--- cfe/trunk/lib/Lex/Lexer.cpp (original)
+++ cfe/trunk/lib/Lex/Lexer.cpp Sat Oct 11 22:22:02 2008
@@ -804,7 +804,7 @@
   // Found but did not consume the newline.
     
   // If we are returning comments as tokens, return this comment as a token.
-  if (KeepCommentMode)
+  if (inKeepCommentMode())
     return SaveBCPLComment(Result, CurPtr);
 
   // If we are inside a preprocessor directive and we see the end of line,
@@ -1015,7 +1015,7 @@
   }
   
   // If we are returning comments as tokens, return this comment as a token.
-  if (KeepCommentMode) {
+  if (inKeepCommentMode()) {
     Result.setKind(tok::comment);
     FormTokenWithChars(Result, CurPtr);
     return false;
@@ -1263,10 +1263,10 @@
     
     // If the next token is obviously a // or /* */ comment, skip it efficiently
     // too (without going through the big switch stmt).
-    if (CurPtr[0] == '/' && CurPtr[1] == '/' && !KeepCommentMode) {
+    if (CurPtr[0] == '/' && CurPtr[1] == '/' && !inKeepCommentMode()) {
       SkipBCPLComment(Result, CurPtr+2);
       goto SkipIgnoredUnits;
-    } else if (CurPtr[0] == '/' && CurPtr[1] == '*' && !KeepCommentMode) {
+    } else if (CurPtr[0] == '/' && CurPtr[1] == '*' && !inKeepCommentMode()) {
       SkipBlockComment(Result, CurPtr+2);
       goto SkipIgnoredUnits;
     } else if (isHorizontalWhitespace(*CurPtr)) {





More information about the cfe-commits mailing list