diff options
author | dim <dim@FreeBSD.org> | 2015-07-05 14:23:59 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2015-07-05 14:23:59 +0000 |
commit | e7bcad327814a78ecb8d5f5545d2e3df84c67a5c (patch) | |
tree | ac719b5984165053bf83d71142e4d96b609b9784 /lib/Lex/PPLexerChange.cpp | |
parent | 9dd834653b811ad20382e98a87dff824980c9916 (diff) | |
download | FreeBSD-src-e7bcad327814a78ecb8d5f5545d2e3df84c67a5c.zip FreeBSD-src-e7bcad327814a78ecb8d5f5545d2e3df84c67a5c.tar.gz |
Vendor import of clang trunk r241361:
https://llvm.org/svn/llvm-project/cfe/trunk@241361
Diffstat (limited to 'lib/Lex/PPLexerChange.cpp')
-rw-r--r-- | lib/Lex/PPLexerChange.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/Lex/PPLexerChange.cpp b/lib/Lex/PPLexerChange.cpp index 1a35d32..c231e18 100644 --- a/lib/Lex/PPLexerChange.cpp +++ b/lib/Lex/PPLexerChange.cpp @@ -644,11 +644,20 @@ void Preprocessor::EnterSubmodule(Module *M, SourceLocation ImportLoc) { if (FirstTime) { // Determine the set of starting macros for this submodule; take these // from the "null" module (the predefines buffer). + // + // FIXME: If we have local visibility but not modules enabled, the + // NullSubmoduleState is polluted by #defines in the top-level source + // file. auto &StartingMacros = NullSubmoduleState.Macros; // Restore to the starting state. // FIXME: Do this lazily, when each macro name is first referenced. for (auto &Macro : StartingMacros) { + // Skip uninteresting macros. + if (!Macro.second.getLatest() && + Macro.second.getOverriddenMacros().empty()) + continue; + MacroState MS(Macro.second.getLatest()); MS.setOverriddenMacros(*this, Macro.second.getOverriddenMacros()); State.Macros.insert(std::make_pair(Macro.first, std::move(MS))); @@ -732,6 +741,11 @@ void Preprocessor::LeaveSubmodule() { } } + // FIXME: Before we leave this submodule, we should parse all the other + // headers within it. Otherwise, we're left with an inconsistent state + // where we've made the module visible but don't yet have its complete + // contents. + // Put back the outer module's state, if we're tracking it. if (getLangOpts().ModulesLocalVisibility) CurSubmoduleState = Info.OuterSubmoduleState; @@ -739,6 +753,5 @@ void Preprocessor::LeaveSubmodule() { BuildingSubmoduleStack.pop_back(); // A nested #include makes the included submodule visible. - if (!BuildingSubmoduleStack.empty() || !getLangOpts().ModulesLocalVisibility) - makeModuleVisible(LeavingMod, ImportLoc); + makeModuleVisible(LeavingMod, ImportLoc); } |