diff options
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Frontend/CompilerInstance.cpp | 21 | ||||
-rw-r--r-- | clang/lib/Lex/PPDirectives.cpp | 10 |
2 files changed, 22 insertions, 9 deletions
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp index d314f6d18a6..991e9ef990a 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; } diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp index 7fc008274bd..85504de3d15 100644 --- a/clang/lib/Lex/PPDirectives.cpp +++ b/clang/lib/Lex/PPDirectives.cpp @@ -1866,10 +1866,7 @@ void Preprocessor::HandleIncludeDirective(SourceLocation HashLoc, // unavailable, diagnose the situation and bail out. // FIXME: Remove this; loadModule does the same check (but produces // slightly worse diagnostics). - if (!SuggestedModule.getModule()->isAvailable() && - !SuggestedModule.getModule() - ->getTopLevelModule() - ->HasIncompatibleModuleFile) { + if (!SuggestedModule.getModule()->isAvailable()) { Module::Requirement Requirement; Module::UnresolvedHeaderDirective MissingHeader; Module *M = SuggestedModule.getModule(); @@ -1918,9 +1915,12 @@ void Preprocessor::HandleIncludeDirective(SourceLocation HashLoc, else if (Imported.isMissingExpected()) { // We failed to find a submodule that we assumed would exist (because it // was in the directory of an umbrella header, for instance), but no - // actual module exists for it (because the umbrella header is + // actual module containing it exists (because the umbrella header is // incomplete). Treat this as a textual inclusion. SuggestedModule = ModuleMap::KnownHeader(); + } else if (Imported.isConfigMismatch()) { + // On a configuration mismatch, enter the header textually. We still know + // that it's part of the corresponding module. } else { // We hit an error processing the import. Bail out. if (hadModuleLoaderFatalFailure()) { |