r247765 - [modules] Fix a corner case in the macro override rules: properly handle overridden leaf module macros.

Sean Silva via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 15 18:28:43 PDT 2015


On Tue, Sep 15, 2015 at 5:55 PM, Richard Smith via cfe-commits <
cfe-commits at 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"?

-- 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 at Inputs/macros_right.h:12{{expanding this definition of
> 'LEFT_RIGHT_DIFFERENT'}}
>  // expected-note at Inputs/macros_right.h:13{{expanding this definition of
> 'LEFT_RIGHT_DIFFERENT2'}}
>  // expected-note at Inputs/macros_left.h:14{{other definition of
> 'LEFT_RIGHT_DIFFERENT'}}
> -// expected-note at 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 at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150915/405b3074/attachment.html>


More information about the cfe-commits mailing list