summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2015-02-28 03:09:52 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2015-02-28 03:09:52 +0000
commit37bd29a5e6b031b0b10ac41c52b7737d0b69db83 (patch)
tree55aae05a6bf64b466c0c6eb965b5dec121fabfab /clang/lib
parent9ef0d1c145504da23797bf0b758ffb9d2c1bf4e9 (diff)
downloadbcm5719-llvm-37bd29a5e6b031b0b10ac41c52b7737d0b69db83.tar.gz
bcm5719-llvm-37bd29a5e6b031b0b10ac41c52b7737d0b69db83.zip
Give better diagnostics when -fmodule-file= finds a bad file: if the file is
found indirectly, explain how we got there, and distinguish between 'file not found' and 'file found but invalid'. llvm-svn: 230839
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Frontend/CompilerInstance.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp
index 07812bdc839..2dac20bcb0f 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -1279,6 +1279,7 @@ bool CompilerInstance::loadModuleFile(StringRef FileName) {
struct ReadModuleNames : ASTReaderListener {
CompilerInstance &CI;
std::vector<StringRef> ModuleFileStack;
+ std::vector<StringRef> ModuleNameStack;
bool Failed;
bool TopFileIsModule;
@@ -1295,20 +1296,29 @@ bool CompilerInstance::loadModuleFile(StringRef FileName) {
}
ModuleFileStack.push_back(FileName);
+ ModuleNameStack.push_back(StringRef());
if (ASTReader::readASTFileControlBlock(FileName, CI.getFileManager(),
*this)) {
- CI.getDiagnostics().Report(SourceLocation(),
- diag::err_module_file_not_found)
+ CI.getDiagnostics().Report(
+ SourceLocation(), CI.getFileManager().getBufferForFile(FileName)
+ ? diag::err_module_file_invalid
+ : diag::err_module_file_not_found)
<< FileName;
- // FIXME: Produce a note stack explaining how we got here.
+ for (int I = ModuleFileStack.size() - 2; I >= 0; --I)
+ CI.getDiagnostics().Report(SourceLocation(),
+ diag::note_module_file_imported_by)
+ << ModuleFileStack[I]
+ << !ModuleNameStack[I].empty() << ModuleNameStack[I];
Failed = true;
}
+ ModuleNameStack.pop_back();
ModuleFileStack.pop_back();
}
void ReadModuleName(StringRef ModuleName) override {
if (ModuleFileStack.size() == 1)
TopFileIsModule = true;
+ ModuleNameStack.back() = ModuleName;
auto &ModuleFile = CI.ModuleFileOverrides[ModuleName];
if (!ModuleFile.empty() &&
OpenPOWER on IntegriCloud