On Sep 15, 2015 6:28 PM, "Sean Silva" <chisophu...@gmail.com> wrote: > > > > On Tue, Sep 15, 2015 at 5:55 PM, Richard Smith via cfe-commits < cfe-commits@lists.llvm.org> wrote: >> >> Author: rsmith >> Date: Tue Sep 15 19:55:50 2015 >> New Revision: 247765 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=247765&view=rev >> Log: >> [modules] Fix a corner case in the macro override rules: properly handle overridden leaf module macros. > > > What exactly is a "leaf module macro"?
This is a module macro that is not overridden by any other module macro. We were sometimes not doing the right thing if such a module macro is overridden by a local macro (one not imported from any module). > -- Sean Silva > >> >> >> Modified: >> cfe/trunk/lib/Lex/PPMacroExpansion.cpp >> cfe/trunk/test/Modules/macros.c >> >> Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp >> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=247765&r1=247764&r2=247765&view=diff >> ============================================================================== >> --- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original) >> +++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Tue Sep 15 19:55:50 2015 >> @@ -145,8 +145,12 @@ void Preprocessor::updateModuleMacroInfo >> NumHiddenOverrides[O] = -1; >> >> // Collect all macros that are not overridden by a visible macro. >> - llvm::SmallVector<ModuleMacro *, 16> Worklist(Leaf->second.begin(), >> - Leaf->second.end()); >> + llvm::SmallVector<ModuleMacro *, 16> Worklist; >> + for (auto *LeafMM : Leaf->second) { >> + assert(LeafMM->getNumOverridingMacros() == 0 && "leaf macro overridden"); >> + if (NumHiddenOverrides.lookup(LeafMM) == 0) >> + Worklist.push_back(LeafMM); >> + } >> while (!Worklist.empty()) { >> auto *MM = Worklist.pop_back_val(); >> if (CurSubmoduleState->VisibleModules.isVisible(MM->getOwningModule())) { >> >> Modified: cfe/trunk/test/Modules/macros.c >> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/macros.c?rev=247765&r1=247764&r2=247765&view=diff >> ============================================================================== >> --- cfe/trunk/test/Modules/macros.c (original) >> +++ cfe/trunk/test/Modules/macros.c Tue Sep 15 19:55:50 2015 >> @@ -18,7 +18,6 @@ >> // expected-note@Inputs/macros_right.h:12{{expanding this definition of 'LEFT_RIGHT_DIFFERENT'}} >> // expected-note@Inputs/macros_right.h:13{{expanding this definition of 'LEFT_RIGHT_DIFFERENT2'}} >> // expected-note@Inputs/macros_left.h:14{{other definition of 'LEFT_RIGHT_DIFFERENT'}} >> -// expected-note@Inputs/macros_left.h:11{{other definition of 'LEFT_RIGHT_DIFFERENT2'}} >> >> @import macros; >> >> @@ -72,9 +71,14 @@ void f() { >> # error TOP should not be visible >> #endif >> >> +#undef INTEGER >> +#define INTEGER int >> + >> // Import left module (which also imports top) >> @import macros_left; >> >> +INTEGER my_integer = 0; >> + >> #ifndef LEFT >> # error LEFT should be visible >> #endif >> >> >> _______________________________________________ >> cfe-commits mailing list >> cfe-commits@lists.llvm.org >> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits > >
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits