summaryrefslogtreecommitdiffstats
path: root/lib/Lex
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2017-05-12 20:42:54 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2017-05-12 20:42:54 +0000
commit2dac30a6d7668a1de94f2509b6e533e16b3117a7 (patch)
treef9b72ec44caf89d26d3bfce3964fae48c282956c /lib/Lex
parent3d3b0295de7324f79875f59a95f5a93952d0e6ce (diff)
Revert r302932, as it appears to be breaking stage2 for some of our modules-enabled buildbots.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@302947 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex')
-rw-r--r--lib/Lex/PPLexerChange.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/lib/Lex/PPLexerChange.cpp b/lib/Lex/PPLexerChange.cpp
index a3c537a43b..1938328c90 100644
--- a/lib/Lex/PPLexerChange.cpp
+++ b/lib/Lex/PPLexerChange.cpp
@@ -731,7 +731,7 @@ Module *Preprocessor::LeaveSubmodule(bool ForPragma) {
Module *LeavingMod = Info.M;
SourceLocation ImportLoc = Info.ImportLoc;
- if (!needModuleMacros() ||
+ if (!needModuleMacros() ||
(!getLangOpts().ModulesLocalVisibility &&
LeavingMod->getTopLevelModuleName() != getLangOpts().CurrentModule)) {
// If we don't need module macros, or this is not a module for which we
@@ -777,6 +777,17 @@ Module *Preprocessor::LeaveSubmodule(bool ForPragma) {
for (auto *MD = Macro.getLatest(); MD != OldMD; MD = MD->getPrevious()) {
assert(MD && "broken macro directive chain");
+ // Stop on macros defined in other submodules of this module that we
+ // #included along the way. There's no point doing this if we're
+ // tracking local submodule visibility, since there can be no such
+ // directives in our list.
+ if (!getLangOpts().ModulesLocalVisibility) {
+ Module *Mod = getModuleContainingLocation(MD->getLocation());
+ if (Mod != LeavingMod &&
+ Mod->getTopLevelModule() == LeavingMod->getTopLevelModule())
+ break;
+ }
+
if (auto *VisMD = dyn_cast<VisibilityMacroDirective>(MD)) {
// The latest visibility directive for a name in a submodule affects
// all the directives that come before it.
@@ -798,12 +809,6 @@ Module *Preprocessor::LeaveSubmodule(bool ForPragma) {
if (Def || !Macro.getOverriddenMacros().empty())
addModuleMacro(LeavingMod, II, Def,
Macro.getOverriddenMacros(), IsNew);
-
- if (!getLangOpts().ModulesLocalVisibility) {
- // This macro is exposed to the rest of this compilation as a
- // ModuleMacro; we don't need to track its MacroDirective any more.
- Macro.setLatest(nullptr);
- }
break;
}
}