summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex/Lexer.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-10-12 04:19:49 +0000
committerChris Lattner <sabre@nondot.org>2008-10-12 04:19:49 +0000
commit99e7d23455439dcf4aceada91513ef57b844190b (patch)
tree156ff778074f6be6c1392ccd08498d98a2f4a17e /clang/lib/Lex/Lexer.cpp
parente01e758e11e4a014bc58523a780ab43fdab5c78e (diff)
downloadbcm5719-llvm-99e7d23455439dcf4aceada91513ef57b844190b.tar.gz
bcm5719-llvm-99e7d23455439dcf4aceada91513ef57b844190b.zip
When in keep whitespace mode, make sure to return block comments that are
unterminated. llvm-svn: 57403
Diffstat (limited to 'clang/lib/Lex/Lexer.cpp')
-rw-r--r--clang/lib/Lex/Lexer.cpp24
1 files changed, 22 insertions, 2 deletions
diff --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp
index f112aad6d37..838addedfb2 100644
--- a/clang/lib/Lex/Lexer.cpp
+++ b/clang/lib/Lex/Lexer.cpp
@@ -956,7 +956,17 @@ bool Lexer::SkipBlockComment(Token &Result, const char *CurPtr) {
if (C == 0 && CurPtr == BufferEnd+1) {
if (!LexingRawMode)
Diag(BufferPtr, diag::err_unterminated_block_comment);
- BufferPtr = CurPtr-1;
+ --CurPtr;
+
+ // KeepWhitespaceMode should return this broken comment as a token. Since
+ // it isn't a well formed comment, just return it as an 'unknown' token.
+ if (isKeepWhitespaceMode()) {
+ Result.setKind(tok::unknown);
+ FormTokenWithChars(Result, CurPtr);
+ return true;
+ }
+
+ BufferPtr = CurPtr;
return false;
}
@@ -1031,7 +1041,17 @@ bool Lexer::SkipBlockComment(Token &Result, const char *CurPtr) {
// Note: the user probably forgot a */. We could continue immediately
// after the /*, but this would involve lexing a lot of what really is the
// comment, which surely would confuse the parser.
- BufferPtr = CurPtr-1;
+ --CurPtr;
+
+ // KeepWhitespaceMode should return this broken comment as a token. Since
+ // it isn't a well formed comment, just return it as an 'unknown' token.
+ if (isKeepWhitespaceMode()) {
+ Result.setKind(tok::unknown);
+ FormTokenWithChars(Result, CurPtr);
+ return true;
+ }
+
+ BufferPtr = CurPtr;
return false;
}
C = *CurPtr++;
OpenPOWER on IntegriCloud