<div dir="ltr">Hi Richard,<div><br></div><div>Looks like this broke down ASan bootstrap:Â <a href="http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/3434/steps/check-clang%20asan/logs/stdio">http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/3434/steps/check-clang%20asan/logs/stdio</a></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Apr 27, 2015 at 4:21 PM, Richard Smith <span dir="ltr"><<a href="mailto:richard-llvm@metafoo.co.uk" target="_blank">richard-llvm@metafoo.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: rsmith<br>
Date: Mon Apr 27 18:21:38 2015<br>
New Revision: 235941<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=235941&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=235941&view=rev</a><br>
Log:<br>
[modules] Incrementally compute the list of overridden module macros based on<br>
the active module macros at the point of definition, rather than reconstructing<br>
it from the macro history. No functionality change intended.<br>
<br>
Modified:<br>
  cfe/trunk/include/clang/Lex/Preprocessor.h<br>
  cfe/trunk/lib/Lex/PPDirectives.cpp<br>
  cfe/trunk/lib/Lex/PPLexerChange.cpp<br>
  cfe/trunk/lib/Lex/PPMacroExpansion.cpp<br>
  cfe/trunk/lib/Lex/Preprocessor.cpp<br>
<br>
Modified: cfe/trunk/include/clang/Lex/Preprocessor.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=235941&r1=235940&r2=235941&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=235941&r1=235940&r2=235941&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Lex/Preprocessor.h (original)<br>
+++ cfe/trunk/include/clang/Lex/Preprocessor.h Mon Apr 27 18:21:38 2015<br>
@@ -364,57 +364,104 @@ class Preprocessor : public RefCountedBa<br>
  };<br>
  SmallVector<MacroExpandsInfo, 2> DelayedMacroExpandsCallbacks;<br>
<br>
+Â /// Information about a name that has been used to define a module macro.<br>
+Â struct ModuleMacroInfo {<br>
+Â Â ModuleMacroInfo(MacroDirective *MD)<br>
+Â Â Â Â : MD(MD), ActiveModuleMacrosGeneration(0) {}<br>
+<br>
+Â Â /// The most recent macro directive for this identifier.<br>
+Â Â MacroDirective *MD;<br>
+Â Â /// The active module macros for this identifier.<br>
+Â Â llvm::TinyPtrVector<ModuleMacro*> ActiveModuleMacros;<br>
+Â Â /// The generation number at which we last updated ActiveModuleMacros.<br>
+Â Â /// \see Preprocessor::MacroVisibilityGeneration.<br>
+Â Â unsigned ActiveModuleMacrosGeneration;<br>
+Â Â /// Whether this macro name is ambiguous.<br>
+Â Â bool IsAmbiguous;<br>
+Â Â /// The module macros that are overridden by this macro.<br>
+Â Â llvm::TinyPtrVector<ModuleMacro*> OverriddenMacros;<br>
+Â };<br>
+<br>
  /// The state of a macro for an identifier.<br>
  class MacroState {<br>
-Â Â struct ExtInfo {<br>
-Â Â Â ExtInfo(MacroDirective *MD) : MD(MD) {}<br>
-<br>
-Â Â Â // The most recent macro directive for this identifier.<br>
-Â Â Â MacroDirective *MD;<br>
-Â Â Â // The module macros that are overridden by this macro.<br>
-Â Â Â SmallVector<ModuleMacro*, 4> OverriddenMacros;<br>
-Â Â };<br>
+Â Â mutable llvm::PointerUnion<MacroDirective *, ModuleMacroInfo *> State;<br>
<br>
-Â Â llvm::PointerUnion<MacroDirective *, ExtInfo *> State;<br>
-<br>
-Â Â ExtInfo &getExtInfo(Preprocessor &PP) {<br>
-Â Â Â auto *Ext = State.dyn_cast<ExtInfo*>();<br>
-Â Â Â if (!Ext) {<br>
-Â Â Â Â Ext = new (PP.getPreprocessorAllocator())<br>
-Â Â Â Â Â Â ExtInfo(State.get<MacroDirective *>());<br>
-Â Â Â Â State = Ext;<br>
+Â Â ModuleMacroInfo *getModuleInfo(Preprocessor &PP, IdentifierInfo *II) const {<br>
+Â Â Â // FIXME: Find a spare bit on IdentifierInfo and store a<br>
+Â Â Â //Â Â Â Â HasModuleMacros flag.<br>
+Â Â Â if (!II->hasMacroDefinition() || !PP.getLangOpts().Modules ||<br>
+Â Â Â Â Â !PP.MacroVisibilityGeneration)<br>
+Â Â Â Â return nullptr;<br>
+<br>
+Â Â Â auto *Info = State.dyn_cast<ModuleMacroInfo*>();<br>
+Â Â Â if (!Info) {<br>
+Â Â Â Â Info = new (PP.getPreprocessorAllocator())<br>
+Â Â Â Â Â Â ModuleMacroInfo(State.get<MacroDirective *>());<br>
+Â Â Â Â State = Info;<br>
    }<br>
-Â Â Â return *Ext;<br>
+<br>
+Â Â Â if (PP.MacroVisibilityGeneration != Info->ActiveModuleMacrosGeneration)<br>
+Â Â Â Â PP.updateModuleMacroInfo(II, *Info);<br>
+Â Â Â return Info;<br>
   }<br>
<br>
  public:<br>
   MacroState() : MacroState(nullptr) {}<br>
   MacroState(MacroDirective *MD) : State(MD) {}<br>
   MacroDirective *getLatest() const {<br>
-Â Â Â if (auto *Ext = State.dyn_cast<ExtInfo*>())<br>
-Â Â Â Â return Ext->MD;<br>
+Â Â Â if (auto *Info = State.dyn_cast<ModuleMacroInfo*>())<br>
+Â Â Â Â return Info->MD;<br>
    return State.get<MacroDirective*>();<br>
   }<br>
   void setLatest(MacroDirective *MD) {<br>
-Â Â Â if (auto *Ext = State.dyn_cast<ExtInfo*>())<br>
-Â Â Â Â Ext->MD = MD;<br>
+Â Â Â if (auto *Info = State.dyn_cast<ModuleMacroInfo*>())<br>
+Â Â Â Â Info->MD = MD;<br>
    else<br>
     State = MD;<br>
   }<br>
<br>
+Â Â bool isAmbiguous(Preprocessor &PP, IdentifierInfo *II) const {<br>
+Â Â Â auto *Info = getModuleInfo(PP, II);<br>
+Â Â Â return Info ? Info->IsAmbiguous : false;<br>
+Â Â }<br>
+Â Â ArrayRef<ModuleMacro *> getActiveModuleMacros(Preprocessor &PP,<br>
+Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â IdentifierInfo *II) const {<br>
+Â Â Â if (auto *Info = getModuleInfo(PP, II))<br>
+Â Â Â Â return Info->ActiveModuleMacros;<br>
+Â Â Â return None;<br>
+Â Â }<br>
+<br>
   MacroDirective::DefInfo findDirectiveAtLoc(SourceLocation Loc,<br>
                        SourceManager &SourceMgr) const {<br>
+Â Â Â // FIXME: Incorporate module macros into the result of this.<br>
    return getLatest()->findDirectiveAtLoc(Loc, SourceMgr);<br>
   }<br>
<br>
-Â Â void addOverriddenMacro(Preprocessor &PP, ModuleMacro *MM) {<br>
-Â Â Â getExtInfo(PP).OverriddenMacros.push_back(MM);<br>
+Â Â void overrideActiveModuleMacros(Preprocessor &PP, IdentifierInfo *II) {<br>
+Â Â Â if (auto *Info = getModuleInfo(PP, II)) {<br>
+Â Â Â Â for (auto *Active : Info->ActiveModuleMacros)<br>
+Â Â Â Â Â Info->OverriddenMacros.push_back(Active);<br>
+Â Â Â Â Info->ActiveModuleMacros.clear();<br>
+Â Â Â Â Info->IsAmbiguous = false;<br>
+Â Â Â }<br>
   }<br>
   ArrayRef<ModuleMacro*> getOverriddenMacros() const {<br>
-Â Â Â if (auto *Ext = State.dyn_cast<ExtInfo*>())<br>
-Â Â Â Â return Ext->OverriddenMacros;<br>
+Â Â Â if (auto *Info = State.dyn_cast<ModuleMacroInfo*>())<br>
+Â Â Â Â return Info->OverriddenMacros;<br>
    return None;<br>
   }<br>
+Â Â void setOverriddenMacros(ArrayRef<ModuleMacro*> Overrides) {<br>
+Â Â Â auto *Info = State.dyn_cast<ModuleMacroInfo*>();<br>
+Â Â Â if (!Info) {<br>
+Â Â Â Â assert(Overrides.empty() &&<br>
+Â Â Â Â Â Â Â Â "have overrides but never had module macro");<br>
+Â Â Â Â return;<br>
+Â Â Â }<br>
+Â Â Â Info->OverriddenMacros.clear();<br>
+Â Â Â Info->OverriddenMacros.insert(Info->OverriddenMacros.end(),<br>
+Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Overrides.begin(), Overrides.end());<br>
+Â Â Â Info->ActiveModuleMacrosGeneration = 0;<br>
+Â Â }<br>
  };<br>
<br>
  typedef llvm::DenseMap<const IdentifierInfo *, MacroState> MacroMap;<br>
@@ -435,8 +482,13 @@ class Preprocessor : public RefCountedBa<br>
   Module *M;<br>
   /// The location at which the module was included.<br>
   SourceLocation ImportLoc;<br>
+<br>
+Â Â struct SavedMacroInfo {<br>
+Â Â Â MacroDirective *Latest;<br>
+Â Â Â llvm::TinyPtrVector<ModuleMacro*> Overridden;<br>
+Â Â };<br>
   /// The macros that were visible before we entered the module.<br>
-Â Â MacroMap Macros;<br>
+Â Â llvm::DenseMap<const IdentifierInfo*, SavedMacroInfo> Macros;<br>
<br>
   // FIXME: VisibleModules?<br>
   // FIXME: CounterValue?<br>
@@ -447,6 +499,10 @@ class Preprocessor : public RefCountedBa<br>
  void EnterSubmodule(Module *M, SourceLocation ImportLoc);<br>
  void LeaveSubmodule();<br>
<br>
+Â /// Update the set of active module macros and ambiguity flag for a module<br>
+Â /// macro name.<br>
+Â void updateModuleMacroInfo(IdentifierInfo *II, ModuleMacroInfo &Info);<br>
+<br>
  /// The set of known macros exported from modules.<br>
  llvm::FoldingSet<ModuleMacro> ModuleMacros;<br>
<br>
@@ -455,6 +511,10 @@ class Preprocessor : public RefCountedBa<br>
  llvm::DenseMap<const IdentifierInfo *, llvm::TinyPtrVector<ModuleMacro*>><br>
    LeafModuleMacros;<br>
<br>
+Â /// The generation number for module macros. Incremented each time the set<br>
+Â /// of modules with visible macros changes.<br>
+Â unsigned MacroVisibilityGeneration;<br>
+<br>
  /// \brief Macros that we want to warn because they are not used at the end<br>
  /// of the translation unit.<br>
  ///<br>
<br>
Modified: cfe/trunk/lib/Lex/PPDirectives.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=235941&r1=235940&r2=235941&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=235941&r1=235940&r2=235941&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Lex/PPDirectives.cpp (original)<br>
+++ cfe/trunk/lib/Lex/PPDirectives.cpp Mon Apr 27 18:21:38 2015<br>
@@ -1693,6 +1693,7 @@ void Preprocessor::HandleIncludeDirectiv<br>
   ModuleLoadResult Imported<br>
    = TheModuleLoader.loadModule(IncludeTok.getLocation(), Path, Visibility,<br>
                  /*IsIncludeDirective=*/true);<br>
+Â Â ++MacroVisibilityGeneration;<br>
   assert((Imported == nullptr || Imported == SuggestedModule.getModule()) &&<br>
      "the imported module is different than the suggested one");<br>
<br>
<br>
Modified: cfe/trunk/lib/Lex/PPLexerChange.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPLexerChange.cpp?rev=235941&r1=235940&r2=235941&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPLexerChange.cpp?rev=235941&r1=235940&r2=235941&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Lex/PPLexerChange.cpp (original)<br>
+++ cfe/trunk/lib/Lex/PPLexerChange.cpp Mon Apr 27 18:21:38 2015<br>
@@ -616,7 +616,13 @@ void Preprocessor::EnterSubmodule(Module<br>
  auto &Info = BuildingSubmoduleStack.back();<br>
  // Copy across our macros and start the submodule with the current state.<br>
  // FIXME: We should start each submodule with just the predefined macros.<br>
-Â Info.Macros = Macros;<br>
+Â for (auto &M : Macros) {<br>
+Â Â BuildingSubmoduleInfo::SavedMacroInfo SMI;<br>
+Â Â SMI.Latest = M.second.getLatest();<br>
+Â Â auto O = M.second.getOverriddenMacros();<br>
+Â Â SMI.Overridden.insert(SMI.Overridden.end(), O.begin(), O.end());<br>
+Â Â Info.Macros.insert(std::make_pair(M.first, SMI));<br>
+Â }<br>
 }<br>
<br>
 void Preprocessor::LeaveSubmodule() {<br>
@@ -625,12 +631,12 @@ void Preprocessor::LeaveSubmodule() {<br>
  // Create ModuleMacros for any macros defined in this submodule.<br>
  for (auto &Macro : Macros) {<br>
   auto *II = const_cast<IdentifierInfo*>(Macro.first);<br>
-Â Â MacroState State = Info.Macros.lookup(II);<br>
+Â Â auto SavedInfo = Info.Macros.lookup(II);<br>
<br>
   // This module may have exported a new macro. If so, create a ModuleMacro<br>
   // representing that fact.<br>
   bool ExplicitlyPublic = false;<br>
-Â Â for (auto *MD = Macro.second.getLatest(); MD != State.getLatest();<br>
+Â Â for (auto *MD = Macro.second.getLatest(); MD != SavedInfo.Latest;<br>
     MD = MD->getPrevious()) {<br>
    // Skip macros defined in other submodules we #included along the way.<br>
    Module *Mod = getModuleContainingLocation(MD->getLocation());<br>
@@ -659,11 +665,15 @@ void Preprocessor::LeaveSubmodule() {<br>
    }<br>
   }<br>
<br>
-Â Â // Update the macro to refer to the latest directive in the chain.<br>
-Â Â State.setLatest(Macro.second.getLatest());<br>
+Â Â // Restore the macro's overrides list.<br>
+Â Â Macro.second.setOverriddenMacros(SavedInfo.Overridden);<br>
+Â }<br>
<br>
-Â Â // Restore the old macro state.<br>
-Â Â Macro.second = State;<br>
+Â if (Info.M->NameVisibility < Module::MacrosVisible) {<br>
+Â Â Info.M->NameVisibility = Module::MacrosVisible;<br>
+Â Â Info.M->MacroVisibilityLoc = Info.ImportLoc;<br>
+Â Â ++MacroVisibilityGeneration;<br>
+Â Â // FIXME: Also mark any exported macros as visible, and check for conflicts.<br>
  }<br>
<br>
  BuildingSubmoduleStack.pop_back();<br>
<br>
Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=235941&r1=235940&r2=235941&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=235941&r1=235940&r2=235941&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)<br>
+++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Mon Apr 27 18:21:38 2015<br>
@@ -50,6 +50,7 @@ void Preprocessor::appendMacroDirective(<br>
  auto *OldMD = StoredMD.getLatest();<br>
  MD->setPrevious(OldMD);<br>
  StoredMD.setLatest(MD);<br>
+Â StoredMD.overrideActiveModuleMacros(*this, II);<br>
<br>
  // Set up the identifier as having associated macro history.<br>
  II->setHasMacroDefinition(true);<br>
@@ -57,43 +58,6 @@ void Preprocessor::appendMacroDirective(<br>
   II->setHasMacroDefinition(false);<br>
  if (II->isFromAST() && !MD->isImported())<br>
   II->setChangedSinceDeserialization();<br>
-<br>
-Â // Accumulate any overridden imported macros.<br>
-Â if (!MD->isImported() && getCurrentModule()) {<br>
-Â Â Module *OwningMod = getModuleContainingLocation(MD->getLocation());<br>
-Â Â if (!OwningMod)<br>
-Â Â Â return;<br>
-<br>
-Â Â for (auto *PrevMD = OldMD; PrevMD; PrevMD = PrevMD->getPrevious()) {<br>
-Â Â Â Module *DirectiveMod = getModuleContainingLocation(PrevMD->getLocation());<br>
-Â Â Â if (ModuleMacro *PrevMM = PrevMD->getOwningModuleMacro())<br>
-Â Â Â Â StoredMD.addOverriddenMacro(*this, PrevMM);<br>
-Â Â Â else if (ModuleMacro *PrevMM = getModuleMacro(DirectiveMod, II))<br>
-Â Â Â Â // The previous macro was from another submodule that we #included.<br>
-Â Â Â Â // FIXME: Create an import directive when importing a macro from a local<br>
-Â Â Â Â // submodule.<br>
-Â Â Â Â StoredMD.addOverriddenMacro(*this, PrevMM);<br>
-Â Â Â else<br>
-Â Â Â Â // We're still within the module defining the previous macro. We don't<br>
-Â Â Â Â // override it.<br>
-Â Â Â Â break;<br>
-<br>
-Â Â Â // Stop once we leave the original macro's submodule.<br>
-Â Â Â //<br>
-Â Â Â // Either this submodule #included another submodule of the same<br>
-Â Â Â // module or it just happened to be built after the other module.<br>
-Â Â Â // In the former case, we override the submodule's macro.<br>
-Â Â Â //<br>
-Â Â Â // FIXME: In the latter case, we shouldn't do so, but we can't tell<br>
-Â Â Â // these cases apart.<br>
-Â Â Â //<br>
-Â Â Â // FIXME: We can leave this submodule and re-enter it if it #includes a<br>
-Â Â Â // header within a different submodule of the same module. In such cases<br>
-Â Â Â // the overrides list will be incomplete.<br>
-Â Â Â if (DirectiveMod != OwningMod || !PrevMD->isImported())<br>
-Â Â Â Â break;<br>
-Â Â }<br>
-Â }<br>
 }<br>
<br>
 void Preprocessor::setLoadedMacroDirective(IdentifierInfo *II,<br>
@@ -157,6 +121,71 @@ ModuleMacro *Preprocessor::getModuleMacr<br>
  return ModuleMacros.FindNodeOrInsertPos(ID, InsertPos);<br>
 }<br>
<br>
+void Preprocessor::updateModuleMacroInfo(IdentifierInfo *II,<br>
+Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ModuleMacroInfo &Info) {<br>
+Â assert(Info.ActiveModuleMacrosGeneration != MacroVisibilityGeneration &&<br>
+Â Â Â Â Â "don't need to update this macro name info");<br>
+Â Info.ActiveModuleMacrosGeneration = MacroVisibilityGeneration;<br>
+<br>
+Â auto Leaf = LeafModuleMacros.find(II);<br>
+Â if (Leaf == LeafModuleMacros.end()) {<br>
+Â Â // No imported macros at all: nothing to do.<br>
+Â Â return;<br>
+Â }<br>
+<br>
+Â Info.ActiveModuleMacros.clear();<br>
+<br>
+Â // Every macro that's locally overridden is overridden by a visible macro.<br>
+Â llvm::DenseMap<ModuleMacro *, int> NumHiddenOverrides;<br>
+Â for (auto *O : Info.OverriddenMacros)<br>
+Â Â NumHiddenOverrides[O] = -1;<br>
+<br>
+Â // Collect all macros that are not overridden by a visible macro.<br>
+Â llvm::SmallVector<ModuleMacro *, 16> Worklist(Leaf->second.begin(),<br>
+Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Leaf->second.end());<br>
+Â while (!Worklist.empty()) {<br>
+Â Â auto *MM = Worklist.pop_back_val();<br>
+Â Â if (MM->getOwningModule()->NameVisibility >= Module::MacrosVisible) {<br>
+Â Â Â // We only care about collecting definitions; undefinitions only act<br>
+Â Â Â // to override other definitions.<br>
+Â Â Â if (MM->getMacroInfo())<br>
+Â Â Â Â Info.ActiveModuleMacros.push_back(MM);<br>
+Â Â } else {<br>
+Â Â Â for (auto *O : MM->overrides())<br>
+Â Â Â Â if ((unsigned)++NumHiddenOverrides[O] == O->getNumOverridingMacros())<br>
+Â Â Â Â Â Worklist.push_back(O);<br>
+Â Â }<br>
+Â }<br>
+<br>
+Â // Determine whether the macro name is ambiguous.<br>
+Â Info.IsAmbiguous = false;<br>
+Â MacroInfo *MI = nullptr;<br>
+Â bool IsSystemMacro = false;<br>
+Â if (auto *DMD = dyn_cast<DefMacroDirective>(Info.MD)) {<br>
+Â Â MI = DMD->getInfo();<br>
+Â Â IsSystemMacro = SourceMgr.isInSystemHeader(DMD->getLocation());<br>
+Â }<br>
+Â for (auto *Active : Info.ActiveModuleMacros) {<br>
+Â Â auto *NewMI = Active->getMacroInfo();<br>
+<br>
+Â Â // Before marking the macro as ambiguous, check if this is a case where<br>
+Â Â // both macros are in system headers. If so, we trust that the system<br>
+Â Â // did not get it wrong. This also handles cases where Clang's own<br>
+Â Â // headers have a different spelling of certain system macros:<br>
+Â Â //Â Â #define LONG_MAX __LONG_MAX__ (clang's limits.h)<br>
+Â Â //Â Â #define LONG_MAX 0x7fffffffffffffffL (system's limits.h)<br>
+Â Â //<br>
+Â Â // FIXME: Remove the defined-in-system-headers check. clang's limits.h<br>
+Â Â // overrides the system limits.h's macros, so there's no conflict here.<br>
+Â Â IsSystemMacro &= Active->getOwningModule()->IsSystem;<br>
+Â Â if (MI && NewMI != MI && !IsSystemMacro &&<br>
+Â Â Â Â !MI->isIdenticalTo(*NewMI, *this, /*Syntactically=*/true)) {<br>
+Â Â Â Info.IsAmbiguous = true;<br>
+Â Â Â break;<br>
+Â Â }<br>
+Â }<br>
+}<br>
+<br>
 /// RegisterBuiltinMacro - Register the specified identifier in the identifier<br>
 /// table and mark it as a builtin macro to be expanded.<br>
 static IdentifierInfo *RegisterBuiltinMacro(Preprocessor &PP, const char *Name){<br>
<br>
Modified: cfe/trunk/lib/Lex/Preprocessor.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Preprocessor.cpp?rev=235941&r1=235940&r2=235941&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Preprocessor.cpp?rev=235941&r1=235940&r2=235941&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Lex/Preprocessor.cpp (original)<br>
+++ cfe/trunk/lib/Lex/Preprocessor.cpp Mon Apr 27 18:21:38 2015<br>
@@ -73,7 +73,8 @@ Preprocessor::Preprocessor(IntrusiveRefC<br>
    ModuleImportExpectsIdentifier(false), CodeCompletionReached(0),<br>
    MainFileDir(nullptr), SkipMainFilePreamble(0, true), CurPPLexer(nullptr),<br>
    CurDirLookup(nullptr), CurLexerKind(CLK_Lexer), CurSubmodule(nullptr),<br>
-Â Â Â Callbacks(nullptr), MacroArgCache(nullptr), Record(nullptr),<br>
+Â Â Â Callbacks(nullptr), MacroVisibilityGeneration(0),<br>
+Â Â Â MacroArgCache(nullptr), Record(nullptr),<br>
    MIChainHead(nullptr), DeserialMIChainHead(nullptr) {<br>
  OwnsHeaderSearch = OwnsHeaders;<br>
<br>
@@ -748,11 +749,13 @@ void Preprocessor::LexAfterModuleImport(<br>
  // If we have a non-empty module path, load the named module.<br>
  if (!ModuleImportPath.empty()) {<br>
   Module *Imported = nullptr;<br>
-Â Â if (getLangOpts().Modules)<br>
+Â Â if (getLangOpts().Modules) {<br>
    Imported = TheModuleLoader.loadModule(ModuleImportLoc,<br>
                       ModuleImportPath,<br>
                       Module::MacrosVisible,<br>
                       /*IsIncludeDirective=*/false);<br>
+Â Â Â ++MacroVisibilityGeneration;<br>
+Â Â }<br>
   if (Callbacks && (getLangOpts().Modules || getLangOpts().DebuggerSupport))<br>
    Callbacks->moduleImport(ModuleImportLoc, ModuleImportPath, Imported);<br>
  }<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr">Alexey Samsonov<br><a href="mailto:vonosmas@gmail.com" target="_blank">vonosmas@gmail.com</a></div></div>
</div>