aboutsummaryrefslogtreecommitdiff
path: root/lib/Lex/Lexer.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-03-18 20:58:27 +0000
committerChris Lattner <sabre@nondot.org>2009-03-18 20:58:27 +0000
commite91e93225db2e66906878513c6ef4dd6a7ee2b6a (patch)
treeda319fe4288f38028ae7086ddc27ad4b3fd88e92 /lib/Lex/Lexer.cpp
parent5f607c4b75abeedded11eff079dee73561d98203 (diff)
properly form a full token for # before calling HandleDirective.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67235 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/Lexer.cpp')
-rw-r--r--lib/Lex/Lexer.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/Lex/Lexer.cpp b/lib/Lex/Lexer.cpp
index c68d21c7e7..0478eebb62 100644
--- a/lib/Lex/Lexer.cpp
+++ b/lib/Lex/Lexer.cpp
@@ -1595,15 +1595,13 @@ LexNextToken:
if (!isLexingRawMode())
Diag(BufferPtr, diag::charize_microsoft_ext);
Kind = tok::hashat;
- } else {
- Kind = tok::hash; // '%:' -> '#'
-
+ } else { // '%:' -> '#'
// We parsed a # character. If this occurs at the start of the line,
// it's actually the start of a preprocessing directive. Callback to
// the preprocessor to handle it.
// FIXME: -fpreprocessed mode??
if (Result.isAtStartOfLine() && !LexingRawMode) {
- BufferPtr = CurPtr;
+ FormTokenWithChars(Result, CurPtr, tok::hash);
PP->HandleDirective(Result);
// As an optimization, if the preprocessor didn't switch lexers, tail
@@ -1621,6 +1619,8 @@ LexNextToken:
return PP->Lex(Result);
}
+
+ Kind = tok::hash;
}
} else {
Kind = tok::percent;
@@ -1727,13 +1727,12 @@ LexNextToken:
Diag(BufferPtr, diag::charize_microsoft_ext);
CurPtr = ConsumeChar(CurPtr, SizeTmp, Result);
} else {
- Kind = tok::hash;
// We parsed a # character. If this occurs at the start of the line,
// it's actually the start of a preprocessing directive. Callback to
// the preprocessor to handle it.
// FIXME: -fpreprocessed mode??
if (Result.isAtStartOfLine() && !LexingRawMode) {
- BufferPtr = CurPtr;
+ FormTokenWithChars(Result, CurPtr, tok::hash);
PP->HandleDirective(Result);
// As an optimization, if the preprocessor didn't switch lexers, tail
@@ -1750,6 +1749,8 @@ LexNextToken:
}
return PP->Lex(Result);
}
+
+ Kind = tok::hash;
}
break;