aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/CompilerInstance.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2016-12-02 01:52:28 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2016-12-02 01:52:28 +0000
commit444e6f3d8203f197b430d4b649f0981ec1653085 (patch)
treeb4065680559f0c59241b2285443da9a2333b1c4d /clang/lib/Frontend/CompilerInstance.cpp
parentc3e24403f0c933a9e3fac6689ea008c097f424e2 (diff)
downloadllvm-444e6f3d8203f197b430d4b649f0981ec1653085.zip
llvm-444e6f3d8203f197b430d4b649f0981ec1653085.tar.gz
llvm-444e6f3d8203f197b430d4b649f0981ec1653085.tar.bz2
Recover better from an incompatible .pcm file being provided by -fmodule-file=.
We try to include the headers of the module textually in this case, still enforcing the modules semantic rules. In order to make that work, we need to still track that we're entering and leaving the module. Also, if the module was also marked as unavailable (perhaps because it was missing a file), we shouldn't mark the module unavailable -- we don't need the module to be complete if we're going to enter it textually. llvm-svn: 288449
Diffstat (limited to 'clang/lib/Frontend/CompilerInstance.cpp')
-rw-r--r--clang/lib/Frontend/CompilerInstance.cpp21
1 files changed, 17 insertions, 4 deletions
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp
index d314f6d..991e9ef 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -1393,8 +1393,21 @@ bool CompilerInstance::loadModuleFile(StringRef FileName) {
if (Module *M = CI.getPreprocessor()
.getHeaderSearchInfo()
.getModuleMap()
- .findModule(II->getName()))
+ .findModule(II->getName())) {
M->HasIncompatibleModuleFile = true;
+
+ // Mark module as available if the only reason it was unavailable
+ // was missing headers.
+ SmallVector<Module *, 2> Stack;
+ Stack.push_back(M);
+ while (!Stack.empty()) {
+ Module *Current = Stack.pop_back_val();
+ if (Current->IsMissingRequirement) continue;
+ Current->IsAvailable = true;
+ Stack.insert(Stack.end(),
+ Current->submodule_begin(), Current->submodule_end());
+ }
+ }
}
LoadedModules.clear();
}
@@ -1498,7 +1511,7 @@ CompilerInstance::loadModule(SourceLocation ImportLoc,
if (Module && Module->HasIncompatibleModuleFile) {
// We tried and failed to load a module file for this module. Fall
// back to textual inclusion for its headers.
- return ModuleLoadResult(nullptr, /*missingExpected*/true);
+ return ModuleLoadResult::ConfigMismatch;
}
getDiagnostics().Report(ModuleNameLoc, diag::err_module_build_disabled)
@@ -1705,7 +1718,7 @@ CompilerInstance::loadModule(SourceLocation ImportLoc,
<< Module->getFullModuleName()
<< SourceRange(Path.front().second, Path.back().second);
- return ModuleLoadResult(nullptr, true);
+ return ModuleLoadResult::MissingExpected;
}
// Check whether this module is available.
@@ -1739,7 +1752,7 @@ CompilerInstance::loadModule(SourceLocation ImportLoc,
}
LastModuleImportLoc = ImportLoc;
- LastModuleImportResult = ModuleLoadResult(Module, false);
+ LastModuleImportResult = ModuleLoadResult(Module);
return LastModuleImportResult;
}