diff options
author | Douglas Gregor <dgregor@apple.com> | 2012-01-04 06:20:15 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2012-01-04 06:20:15 +0000 |
commit | 8d76cca3a261d0496395e18ef92cae46683618a0 (patch) | |
tree | 05852966bfe4d718e1d27bf0b8449a353d5c2067 /clang/lib/Lex/Preprocessor.cpp | |
parent | 2aa7acfadbfb840091e0cb49c0c704e5873a6647 (diff) | |
download | bcm5719-llvm-8d76cca3a261d0496395e18ef92cae46683618a0.tar.gz bcm5719-llvm-8d76cca3a261d0496395e18ef92cae46683618a0.zip |
Don't treat 'import' as a contextual keyword when we're in a caching lexer, or when modules are disabled.
llvm-svn: 147524
Diffstat (limited to 'clang/lib/Lex/Preprocessor.cpp')
-rw-r--r-- | clang/lib/Lex/Preprocessor.cpp | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp index 046b0dfb01a..cfa9e23e60f 100644 --- a/clang/lib/Lex/Preprocessor.cpp +++ b/clang/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); |