r240350 - [modules] When building a module, if there are multiple matches for a header

Sean Silva chisophugis at gmail.com
Mon Jun 22 16:55:34 PDT 2015


What exactly does -emit-module do here? Is it basically like a PCH build
step, but where the passed-in module map drives what clang does?

-- Sean Silva

On Mon, Jun 22, 2015 at 3:20 PM, Richard Smith <richard-llvm at metafoo.co.uk>
wrote:

> Author: rsmith
> Date: Mon Jun 22 17:20:47 2015
> New Revision: 240350
>
> URL: http://llvm.org/viewvc/llvm-project?rev=240350&view=rev
> Log:
> [modules] When building a module, if there are multiple matches for a
> header
> file in the loaded module maps and one of them is from the current module,
> that's the right match.
>
> Added:
>     cfe/trunk/test/Modules/Inputs/explicit-build-prefer-self/
>     cfe/trunk/test/Modules/Inputs/explicit-build-prefer-self/a.h
>     cfe/trunk/test/Modules/Inputs/explicit-build-prefer-self/b.h
>     cfe/trunk/test/Modules/Inputs/explicit-build-prefer-self/map
>     cfe/trunk/test/Modules/Inputs/explicit-build-prefer-self/x.h
>     cfe/trunk/test/Modules/explicit-build-prefer-self.cpp
> Modified:
>     cfe/trunk/lib/Lex/ModuleMap.cpp
>
> Modified: cfe/trunk/lib/Lex/ModuleMap.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/ModuleMap.cpp?rev=240350&r1=240349&r2=240350&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Lex/ModuleMap.cpp (original)
> +++ cfe/trunk/lib/Lex/ModuleMap.cpp Mon Jun 22 17:20:47 2015
> @@ -346,6 +346,9 @@ ModuleMap::KnownHeader ModuleMap::findMo
>      ModuleMap::KnownHeader Result;
>      // Iterate over all modules that 'File' is part of to find the best
> fit.
>      for (KnownHeader &H : Known->second) {
> +      // Prefer a header from the current module over all others.
> +      if (H.getModule() == CompilingModule)
> +        return MakeResult(H);
>        // Cannot use a module if it is unavailable.
>        if (!H.getModule()->isAvailable())
>          continue;
>
> Added: cfe/trunk/test/Modules/Inputs/explicit-build-prefer-self/a.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/explicit-build-prefer-self/a.h?rev=240350&view=auto
>
> ==============================================================================
> --- cfe/trunk/test/Modules/Inputs/explicit-build-prefer-self/a.h (added)
> +++ cfe/trunk/test/Modules/Inputs/explicit-build-prefer-self/a.h Mon Jun
> 22 17:20:47 2015
> @@ -0,0 +1,2 @@
> +// a
> +#include "x.h"
>
> Added: cfe/trunk/test/Modules/Inputs/explicit-build-prefer-self/b.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/explicit-build-prefer-self/b.h?rev=240350&view=auto
>
> ==============================================================================
> --- cfe/trunk/test/Modules/Inputs/explicit-build-prefer-self/b.h (added)
> +++ cfe/trunk/test/Modules/Inputs/explicit-build-prefer-self/b.h Mon Jun
> 22 17:20:47 2015
> @@ -0,0 +1,2 @@
> +// b
> +#include "x.h"
>
> Added: cfe/trunk/test/Modules/Inputs/explicit-build-prefer-self/map
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/explicit-build-prefer-self/map?rev=240350&view=auto
>
> ==============================================================================
> --- cfe/trunk/test/Modules/Inputs/explicit-build-prefer-self/map (added)
> +++ cfe/trunk/test/Modules/Inputs/explicit-build-prefer-self/map Mon Jun
> 22 17:20:47 2015
> @@ -0,0 +1,2 @@
> +module a { header "a.h" header "x.h" }
> +module b { header "b.h" header "x.h" }
>
> Added: cfe/trunk/test/Modules/Inputs/explicit-build-prefer-self/x.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/explicit-build-prefer-self/x.h?rev=240350&view=auto
>
> ==============================================================================
>     (empty)
>
> Added: cfe/trunk/test/Modules/explicit-build-prefer-self.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/explicit-build-prefer-self.cpp?rev=240350&view=auto
>
> ==============================================================================
> --- cfe/trunk/test/Modules/explicit-build-prefer-self.cpp (added)
> +++ cfe/trunk/test/Modules/explicit-build-prefer-self.cpp Mon Jun 22
> 17:20:47 2015
> @@ -0,0 +1,3 @@
> +// RUN: rm -rf %t
> +// RUN: %clang_cc1 -fmodules -fno-implicit-modules -emit-module
> -fmodule-name=a %S/Inputs/explicit-build-prefer-self/map -o a.pcm
> +// RUN: %clang_cc1 -fmodules -fno-implicit-modules -emit-module
> -fmodule-name=b %S/Inputs/explicit-build-prefer-self/map -o b.pcm
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150622/396e6a9c/attachment.html>


More information about the cfe-commits mailing list