summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-02-03 21:06:21 +0000
committerChris Lattner <sabre@nondot.org>2010-02-03 21:06:21 +0000
commit93ddf80eb7fe73629aa9c0d7b26c6040a356bb08 (patch)
tree97a3f383b655df9d83909a2f1b63a7068ab0da29 /clang/lib/Lex
parent00f1e6c0300f140ec0f0bb8d46835b4b2de9ed4f (diff)
downloadbcm5719-llvm-93ddf80eb7fe73629aa9c0d7b26c6040a356bb08.tar.gz
bcm5719-llvm-93ddf80eb7fe73629aa9c0d7b26c6040a356bb08.zip
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! llvm-svn: 95253
Diffstat (limited to 'clang/lib/Lex')
-rw-r--r--clang/lib/Lex/Lexer.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp
index afd1ba88516..3207062ccad 100644
--- a/clang/lib/Lex/Lexer.cpp
+++ b/clang/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.
}
OpenPOWER on IntegriCloud