aboutsummaryrefslogtreecommitdiff
path: root/lib/Lex/Preprocessor.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2012-01-04 06:20:15 +0000
committerDouglas Gregor <dgregor@apple.com>2012-01-04 06:20:15 +0000
commitd6aba06861c41ccbc4926e5fe3cecd97b20410c0 (patch)
tree236d9d107a013eced1887f36af86fbdecc04f2d2 /lib/Lex/Preprocessor.cpp
parent256fc4d0743d520a2535d6de003aa828f5de8b27 (diff)
Don't treat 'import' as a contextual keyword when we're in a caching lexer, or when modules are disabled.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147524 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/Preprocessor.cpp')
-rw-r--r--lib/Lex/Preprocessor.cpp27
1 files changed, 18 insertions, 9 deletions
diff --git a/lib/Lex/Preprocessor.cpp b/lib/Lex/Preprocessor.cpp
index 046b0dfb01..cfa9e23e60 100644
--- a/lib/Lex/Preprocessor.cpp
+++ b/lib/Lex/Preprocessor.cpp
@@ -266,6 +266,17 @@ Preprocessor::macro_end(bool IncludeExternalMacros) const {
return Macros.end();
}
+void Preprocessor::recomputeCurLexerKind() {
+ if (CurLexer)
+ CurLexerKind = CLK_Lexer;
+ else if (CurPTHLexer)
+ CurLexerKind = CLK_PTHLexer;
+ else if (CurTokenLexer)
+ CurLexerKind = CLK_TokenLexer;
+ else
+ CurLexerKind = CLK_CachingLexer;
+}
+
bool Preprocessor::SetCodeCompletionPoint(const FileEntry *File,
unsigned CompleteLine,
unsigned CompleteColumn) {
@@ -550,7 +561,12 @@ void Preprocessor::HandleIdentifier(Token &Identifier) {
// If this is the 'import' contextual keyword, note that the next token
// indicates a module name.
- if (II.isImport() && !InMacroArgs && !DisableMacroExpansion) {
+ //
+ // Note that we do not treat 'import' as a contextual keyword when we're
+ // in a caching lexer, because caching lexers only get used in contexts where
+ // import declarations are disallowed.
+ if (II.isImport() && !InMacroArgs && !DisableMacroExpansion &&
+ getLangOptions().Modules && CurLexerKind != CLK_CachingLexer) {
ModuleImportLoc = Identifier.getLocation();
ModuleImportPath.clear();
ModuleImportExpectsIdentifier = true;
@@ -562,14 +578,7 @@ void Preprocessor::HandleIdentifier(Token &Identifier) {
///
void Preprocessor::LexAfterModuleImport(Token &Result) {
// Figure out what kind of lexer we actually have.
- if (CurLexer)
- CurLexerKind = CLK_Lexer;
- else if (CurPTHLexer)
- CurLexerKind = CLK_PTHLexer;
- else if (CurTokenLexer)
- CurLexerKind = CLK_TokenLexer;
- else
- CurLexerKind = CLK_CachingLexer;
+ recomputeCurLexerKind();
// Lex the next token.
Lex(Result);