diff options
author | Chris Lattner <sabre@nondot.org> | 2010-02-03 21:06:21 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-02-03 21:06:21 +0000 |
commit | 3d0ad58b28e0d50fca7f21c6a078b05370510288 (patch) | |
tree | 3643e07089df7540c766af7694d3039efe407348 /lib/Lex/Lexer.cpp | |
parent | 0e709abafbd939326850501f795cc7a92c88a354 (diff) |
don't inform comment handlers about comments in #if 0 blocks,
doing so invalidates the file guard optimization and is not
in the spirit of "#if 0" because it is supposed to completely
skip everything, even if it isn't lexically valid. Patch by
Abramo Bagnara!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95253 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/Lexer.cpp')
-rw-r--r-- | lib/Lex/Lexer.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/Lex/Lexer.cpp b/lib/Lex/Lexer.cpp index afd1ba8851..3207062cca 100644 --- a/lib/Lex/Lexer.cpp +++ b/lib/Lex/Lexer.cpp @@ -985,10 +985,11 @@ bool Lexer::SkipBCPLComment(Token &Result, const char *CurPtr) { if (CurPtr == BufferEnd+1) { --CurPtr; break; } } while (C != '\n' && C != '\r'); - // Found but did not consume the newline. - if (PP && PP->HandleComment(Result, - SourceRange(getSourceLocation(BufferPtr), - getSourceLocation(CurPtr)))) { + // Found but did not consume the newline. Notify comment handlers about the + // comment unless we're in a #if 0 block. + if (PP && !isLexingRawMode() && + PP->HandleComment(Result, SourceRange(getSourceLocation(BufferPtr), + getSourceLocation(CurPtr)))) { BufferPtr = CurPtr; return true; // A token has to be returned. } @@ -1235,9 +1236,10 @@ bool Lexer::SkipBlockComment(Token &Result, const char *CurPtr) { C = *CurPtr++; } - if (PP && PP->HandleComment(Result, - SourceRange(getSourceLocation(BufferPtr), - getSourceLocation(CurPtr)))) { + // Notify comment handlers about the comment unless we're in a #if 0 block. + if (PP && !isLexingRawMode() && + PP->HandleComment(Result, SourceRange(getSourceLocation(BufferPtr), + getSourceLocation(CurPtr)))) { BufferPtr = CurPtr; return true; // A token has to be returned. } |