summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2019-05-07 21:38:51 +0000
committerDavid Blaikie <dblaikie@gmail.com>2019-05-07 21:38:51 +0000
commit89e58ddb2868bfb84c082b1a7ac07faf8c3bbca7 (patch)
treeb832a5e0d53e45802b665598f215c8235caeab93 /clang/lib
parent2b09b25e486834634db5eb200fe48576525b4c7d (diff)
downloadbcm5719-llvm-89e58ddb2868bfb84c082b1a7ac07faf8c3bbca7.tar.gz
bcm5719-llvm-89e58ddb2868bfb84c082b1a7ac07faf8c3bbca7.zip
-frewrite-imports: Add support for wildcard rules in umbrella modules with
This trips over a few other limitations, but in the interests of incremental development I'm starting here & I'll look at the issues with -verify and filesystem checks (the fact that the behavior depends on the existence of a 'foo' directory even though it shouldn't need it), etc. Reviewers: rsmith Differential Revision: https://reviews.llvm.org/D61656 llvm-svn: 360195
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Basic/Module.cpp15
-rw-r--r--clang/lib/Lex/Pragma.cpp7
2 files changed, 18 insertions, 4 deletions
diff --git a/clang/lib/Basic/Module.cpp b/clang/lib/Basic/Module.cpp
index b405ab621d3..f394f26e550 100644
--- a/clang/lib/Basic/Module.cpp
+++ b/clang/lib/Basic/Module.cpp
@@ -321,6 +321,21 @@ Module *Module::findSubmodule(StringRef Name) const {
return SubModules[Pos->getValue()];
}
+Module *Module::findOrInferSubmodule(StringRef Name) {
+ llvm::StringMap<unsigned>::const_iterator Pos = SubModuleIndex.find(Name);
+ if (Pos != SubModuleIndex.end())
+ return SubModules[Pos->getValue()];
+ if (!InferSubmodules)
+ return nullptr;
+ Module *Result = new Module(Name, SourceLocation(), this, false, InferExplicitSubmodules, 0);
+ Result->InferExplicitSubmodules = InferExplicitSubmodules;
+ Result->InferSubmodules = InferSubmodules;
+ Result->InferExportWildcard = InferExportWildcard;
+ if (Result->InferExportWildcard)
+ Result->Exports.push_back(Module::ExportDecl(nullptr, true));
+ return Result;
+}
+
void Module::getExportedModules(SmallVectorImpl<Module *> &Exported) const {
// All non-explicit submodules are exported.
for (std::vector<Module *>::const_iterator I = SubModules.begin(),
diff --git a/clang/lib/Lex/Pragma.cpp b/clang/lib/Lex/Pragma.cpp
index ba1b73e7f4b..8aff163d798 100644
--- a/clang/lib/Lex/Pragma.cpp
+++ b/clang/lib/Lex/Pragma.cpp
@@ -1584,16 +1584,15 @@ struct PragmaModuleBeginHandler : public PragmaHandler {
// Find the module we're entering. We require that a module map for it
// be loaded or implicitly loadable.
- // FIXME: We could create the submodule here. We'd need to know whether
- // it's supposed to be explicit, but not much else.
- Module *M = PP.getHeaderSearchInfo().lookupModule(Current);
+ auto &HSI = PP.getHeaderSearchInfo();
+ Module *M = HSI.lookupModule(Current);
if (!M) {
PP.Diag(ModuleName.front().second,
diag::err_pp_module_begin_no_module_map) << Current;
return;
}
for (unsigned I = 1; I != ModuleName.size(); ++I) {
- auto *NewM = M->findSubmodule(ModuleName[I].first->getName());
+ auto *NewM = M->findOrInferSubmodule(ModuleName[I].first->getName());
if (!NewM) {
PP.Diag(ModuleName[I].second, diag::err_pp_module_begin_no_submodule)
<< M->getFullModuleName() << ModuleName[I].first;
OpenPOWER on IntegriCloud