[Modules] Allow @import to reach submodules in private module maps
authorBruno Cardoso Lopes <bruno.cardoso@gmail.com>
Wed, 2 May 2018 02:25:03 +0000 (02:25 +0000)
committerBruno Cardoso Lopes <bruno.cardoso@gmail.com>
Wed, 2 May 2018 02:25:03 +0000 (02:25 +0000)
commit22d97065d358d977eab163c6e07540072eea2642
tree2d4adec73c8c98cb5ee04a975c81d6a7cd2ed52d
parenta0e3ae4ce01d07e575d1ab8966f78c835039ef09
[Modules] Allow @import to reach submodules in private module maps

A @import targeting a top level module from a private module map file
(@import Foo_Private), would fail if there's any submodule declaration
around (module Foo.SomeSub) in the same private module map.

This happens because compileModuleImpl, when building Foo_Private, will
start with the private module map and will not parse the public one,
which leads to unsuccessful parsing of Foo.SomeSub, since top level Foo
was never parsed.

Declaring other submodules in the private module map is not common and
should usually be avoided, but it shouldn't fail to build. Canonicalize
compileModuleImpl to always look at the public module first, so that all
necessary information is available when parsing the private one.

rdar://problem/39822328

llvm-svn: 331322
clang/lib/Frontend/CompilerInstance.cpp
clang/test/Modules/Inputs/submodule-in-private-mmap/A.framework/Headers/A.h [new file with mode: 0644]
clang/test/Modules/Inputs/submodule-in-private-mmap/A.framework/Headers/SomeSub.h [new file with mode: 0644]
clang/test/Modules/Inputs/submodule-in-private-mmap/A.framework/Modules/module.modulemap [new file with mode: 0644]
clang/test/Modules/Inputs/submodule-in-private-mmap/A.framework/Modules/module.private.modulemap [new file with mode: 0644]
clang/test/Modules/Inputs/submodule-in-private-mmap/A.framework/PrivateHeaders/APrivate.h [new file with mode: 0644]
clang/test/Modules/submodule-in-private-mmap.m [new file with mode: 0644]