diff options
author | Aaron Ballman <aaron@aaronballman.com> | 2018-04-16 21:07:08 +0000 |
---|---|---|
committer | Aaron Ballman <aaron@aaronballman.com> | 2018-04-16 21:07:08 +0000 |
commit | d742dc20d9809b36a7eec6a1f64c48755e2e5778 (patch) | |
tree | 0baae19648845980c797de4180103438c251459b /clang/lib/Lex | |
parent | 040888b6239358fa4abb495796e308d1d75c0e1d (diff) | |
download | bcm5719-llvm-d742dc20d9809b36a7eec6a1f64c48755e2e5778.tar.gz bcm5719-llvm-d742dc20d9809b36a7eec6a1f64c48755e2e5778.zip |
Defer adding keywords to the identifier table until after the language options have been loaded from the AST file.
This fixes issues with "class" being reported as an identifier in "enum class" because the construct is not present when using default language options.
Patch by Johann Klähn.
llvm-svn: 330159
Diffstat (limited to 'clang/lib/Lex')
-rw-r--r-- | clang/lib/Lex/Preprocessor.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp index 08469bc0253..4370bc10e34 100644 --- a/clang/lib/Lex/Preprocessor.cpp +++ b/clang/lib/Lex/Preprocessor.cpp @@ -85,12 +85,14 @@ Preprocessor::Preprocessor(std::shared_ptr<PreprocessorOptions> PPOpts, IdentifierInfoLookup *IILookup, bool OwnsHeaders, TranslationUnitKind TUKind) : PPOpts(std::move(PPOpts)), Diags(&diags), LangOpts(opts), - FileMgr(Headers.getFileMgr()), SourceMgr(SM), - PCMCache(PCMCache), ScratchBuf(new ScratchBuffer(SourceMgr)), - HeaderInfo(Headers), TheModuleLoader(TheModuleLoader), - ExternalSource(nullptr), Identifiers(opts, IILookup), - PragmaHandlers(new PragmaNamespace(StringRef())), TUKind(TUKind), - SkipMainFilePreamble(0, true), + FileMgr(Headers.getFileMgr()), SourceMgr(SM), PCMCache(PCMCache), + ScratchBuf(new ScratchBuffer(SourceMgr)), HeaderInfo(Headers), + TheModuleLoader(TheModuleLoader), ExternalSource(nullptr), + // As the language options may have not been loaded yet (when + // deserializing an ASTUnit), adding keywords to the identifier table is + // deferred to Preprocessor::Initialize(). + Identifiers(IILookup), PragmaHandlers(new PragmaNamespace(StringRef())), + TUKind(TUKind), SkipMainFilePreamble(0, true), CurSubmoduleState(&NullSubmoduleState) { OwnsHeaderSearch = OwnsHeaders; @@ -190,6 +192,9 @@ void Preprocessor::Initialize(const TargetInfo &Target, // Initialize information about built-ins. BuiltinInfo.InitializeTarget(Target, AuxTarget); HeaderInfo.setTarget(Target); + + // Populate the identifier table with info about keywords for the current language. + Identifiers.AddKeywords(LangOpts); } void Preprocessor::InitializeForModelFile() { |