r302947 - Revert r302932, as it appears to be breaking stage2 for some of our modules-enabled buildbots.

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Fri May 12 13:42:54 PDT 2017


Author: rsmith
Date: Fri May 12 15:42:54 2017
New Revision: 302947

URL: http://llvm.org/viewvc/llvm-project?rev=302947&view=rev
Log:
Revert r302932, as it appears to be breaking stage2 for some of our modules-enabled buildbots.

Modified:
    cfe/trunk/lib/Lex/PPLexerChange.cpp

Modified: cfe/trunk/lib/Lex/PPLexerChange.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPLexerChange.cpp?rev=302947&r1=302946&r2=302947&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PPLexerChange.cpp (original)
+++ cfe/trunk/lib/Lex/PPLexerChange.cpp Fri May 12 15:42:54 2017
@@ -731,7 +731,7 @@ Module *Preprocessor::LeaveSubmodule(boo
   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(boo
     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(boo
         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;
       }
     }




More information about the cfe-commits mailing list