diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2018-05-24 20:03:51 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2018-05-24 20:03:51 +0000 |
commit | 7a985e1b9f62c695e5bafbe62fe5f0495964f18f (patch) | |
tree | 0015b1221f1167387189c8d7ee1965b26398d83c /clang/lib/Frontend/CompilerInstance.cpp | |
parent | c50150105536df8f83773af2596fc150daa7af3a (diff) | |
download | bcm5719-llvm-7a985e1b9f62c695e5bafbe62fe5f0495964f18f.tar.gz bcm5719-llvm-7a985e1b9f62c695e5bafbe62fe5f0495964f18f.zip |
Improve diagnostics for config mismatches with -fmodule-file.
Unless the user uses -Wno-module-file-config-mismatch (or -Wno-error=...),
allow the AST reader to produce errors describing the nature of the config
mismatch.
llvm-svn: 333220
Diffstat (limited to 'clang/lib/Frontend/CompilerInstance.cpp')
-rw-r--r-- | clang/lib/Frontend/CompilerInstance.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp index 859560d938f..d9900867d88 100644 --- a/clang/lib/Frontend/CompilerInstance.cpp +++ b/clang/lib/Frontend/CompilerInstance.cpp @@ -1602,15 +1602,22 @@ bool CompilerInstance::loadModuleFile(StringRef FileName) { if (!ModuleManager) createModuleManager(); + // If -Wmodule-file-config-mismatch is mapped as an error or worse, allow the + // ASTReader to diagnose it, since it can produce better errors that we can. + bool ConfigMismatchIsRecoverable = + getDiagnostics().getDiagnosticLevel(diag::warn_module_config_mismatch, + SourceLocation()) + <= DiagnosticsEngine::Warning; + auto Listener = llvm::make_unique<ReadModuleNames>(*this); auto &ListenerRef = *Listener; ASTReader::ListenerScope ReadModuleNamesListener(*ModuleManager, std::move(Listener)); // Try to load the module file. - switch (ModuleManager->ReadAST(FileName, serialization::MK_ExplicitModule, - SourceLocation(), - ASTReader::ARR_ConfigurationMismatch)) { + switch (ModuleManager->ReadAST( + FileName, serialization::MK_ExplicitModule, SourceLocation(), + ConfigMismatchIsRecoverable ? ASTReader::ARR_ConfigurationMismatch : 0)) { case ASTReader::Success: // We successfully loaded the module file; remember the set of provided // modules so that we don't try to load implicit modules for them. |