aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-10-12 03:22:02 +0000
committerChris Lattner <sabre@nondot.org>2008-10-12 03:22:02 +0000
commitfa95a019da00b926d64ff83358ba73bbc6ae1e37 (patch)
tree7f2abebe71246ec4f3e22cac176ec054b280fe0e
parenta2c7ad9c7312df162300ba95828ed3b6c3b38131 (diff)
add a new inKeepCommentMode() accessor to abstract the KeepCommentMode
ivar. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57397 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Lex/Lexer.h7
-rw-r--r--lib/Lex/Lexer.cpp8
2 files changed, 11 insertions, 4 deletions
diff --git a/include/clang/Lex/Lexer.h b/include/clang/Lex/Lexer.h
index a3668dfd08..24189dfe54 100644
--- a/include/clang/Lex/Lexer.h
+++ b/include/clang/Lex/Lexer.h
@@ -158,6 +158,13 @@ public:
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();
diff --git a/lib/Lex/Lexer.cpp b/lib/Lex/Lexer.cpp
index a259b2aacf..23afa323f8 100644
--- a/lib/Lex/Lexer.cpp
+++ b/lib/Lex/Lexer.cpp
@@ -804,7 +804,7 @@ bool Lexer::SkipBCPLComment(Token &Result, const char *CurPtr) {
// 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 @@ bool Lexer::SkipBlockComment(Token &Result, const char *CurPtr) {
}
// 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 @@ LexNextToken:
// 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)) {