diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2015-04-27 23:21:38 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2015-04-27 23:21:38 +0000 |
commit | 753e007091a7e70029750e68bcd5b82ab886830a (patch) | |
tree | 84e8c0923a5aef434f29428b1292c93226af69d2 /clang/lib/Lex/PPLexerChange.cpp | |
parent | 368c9f6e9b050897dcae4cb84e1cd54e91287a24 (diff) | |
download | bcm5719-llvm-753e007091a7e70029750e68bcd5b82ab886830a.tar.gz bcm5719-llvm-753e007091a7e70029750e68bcd5b82ab886830a.zip |
[modules] Incrementally compute the list of overridden module macros based on
the active module macros at the point of definition, rather than reconstructing
it from the macro history. No functionality change intended.
llvm-svn: 235941
Diffstat (limited to 'clang/lib/Lex/PPLexerChange.cpp')
-rw-r--r-- | clang/lib/Lex/PPLexerChange.cpp | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/clang/lib/Lex/PPLexerChange.cpp b/clang/lib/Lex/PPLexerChange.cpp index a57cba41835..57110aa246f 100644 --- a/clang/lib/Lex/PPLexerChange.cpp +++ b/clang/lib/Lex/PPLexerChange.cpp @@ -616,7 +616,13 @@ void Preprocessor::EnterSubmodule(Module *M, SourceLocation ImportLoc) { auto &Info = BuildingSubmoduleStack.back(); // Copy across our macros and start the submodule with the current state. // FIXME: We should start each submodule with just the predefined macros. - Info.Macros = Macros; + for (auto &M : Macros) { + BuildingSubmoduleInfo::SavedMacroInfo SMI; + SMI.Latest = M.second.getLatest(); + auto O = M.second.getOverriddenMacros(); + SMI.Overridden.insert(SMI.Overridden.end(), O.begin(), O.end()); + Info.Macros.insert(std::make_pair(M.first, SMI)); + } } void Preprocessor::LeaveSubmodule() { @@ -625,12 +631,12 @@ void Preprocessor::LeaveSubmodule() { // Create ModuleMacros for any macros defined in this submodule. for (auto &Macro : Macros) { auto *II = const_cast<IdentifierInfo*>(Macro.first); - MacroState State = Info.Macros.lookup(II); + auto SavedInfo = Info.Macros.lookup(II); // This module may have exported a new macro. If so, create a ModuleMacro // representing that fact. bool ExplicitlyPublic = false; - for (auto *MD = Macro.second.getLatest(); MD != State.getLatest(); + for (auto *MD = Macro.second.getLatest(); MD != SavedInfo.Latest; MD = MD->getPrevious()) { // Skip macros defined in other submodules we #included along the way. Module *Mod = getModuleContainingLocation(MD->getLocation()); @@ -659,11 +665,15 @@ void Preprocessor::LeaveSubmodule() { } } - // Update the macro to refer to the latest directive in the chain. - State.setLatest(Macro.second.getLatest()); + // Restore the macro's overrides list. + Macro.second.setOverriddenMacros(SavedInfo.Overridden); + } - // Restore the old macro state. - Macro.second = State; + if (Info.M->NameVisibility < Module::MacrosVisible) { + Info.M->NameVisibility = Module::MacrosVisible; + Info.M->MacroVisibilityLoc = Info.ImportLoc; + ++MacroVisibilityGeneration; + // FIXME: Also mark any exported macros as visible, and check for conflicts. } BuildingSubmoduleStack.pop_back(); |