[cfe-commits] [PATCH] Only report first error when no compilation database is found.
Daniel Jasper
djasper at google.com
Mon Oct 15 06:00:31 PDT 2012
Hi klimek,
Currently, tools such as clang check report the absence of a compilation database quite verbosely, e.g.:
LLVM ERROR: Could not auto-detect compilation database for file "lib/Tooling/Tooling.cpp"
No compilation database found in /usr/local/home/djasper/clang/llvm/tools/clang/lib/Tooling
json-compilation-database: Error while opening JSON database: No such file or directory
No compilation database found in /usr/local/home/djasper/clang/llvm/tools/clang/lib
json-compilation-database: Error while opening JSON database: No such file or directory
No compilation database found in /usr/local/home/djasper/clang/llvm/tools/clang
json-compilation-database: Error while opening JSON database: No such file or directory
No compilation database found in /usr/local/home/djasper/clang/llvm/tools
json-compilation-database: Error while opening JSON database: No such file or directory
No compilation database found in /usr/local/home/djasper/clang/llvm
json-compilation-database: Error while opening JSON database: No such file or directory
No compilation database found in /usr/local/home/djasper/clang
json-compilation-database: Error while opening JSON database: No such file or directory
No compilation database found in /usr/local/home/djasper
json-compilation-database: Error while opening JSON database: No such file or directory
No compilation database found in /usr/local/home
json-compilation-database: Error while opening JSON database: No such file or directory
No compilation database found in /usr/local
json-compilation-database: Error while opening JSON database: No such file or directory
No compilation database found in /usr/local
json-compilation-database: Error while opening JSON database: No such file or directory
No compilation database found in /usr
json-compilation-database: Error while opening JSON database: No such file or directory
No compilation database found in /
json-compilation-database: Error while opening JSON database: No such file or directory
While this is the complete truth, a shortened error message seems to be nicer. With this patch, it turns into:
LLVM ERROR: Could not auto-detect compilation database for file "lib/Tooling/Tooling.cpp"
No compilation database found in /usr/local/home/djasper/clang/llvm/tools/clang/lib/Tooling or any parent directory
json-compilation-database: Error while opening JSON database: No such file or directory
http://llvm-reviews.chandlerc.com/D62
Files:
lib/Tooling/CompilationDatabase.cpp
Index: lib/Tooling/CompilationDatabase.cpp
===================================================================
--- lib/Tooling/CompilationDatabase.cpp
+++ lib/Tooling/CompilationDatabase.cpp
@@ -49,14 +49,19 @@
findCompilationDatabaseFromDirectory(StringRef Directory,
std::string &ErrorMessage) {
std::stringstream ErrorStream;
+ bool HasErrorMessage = false;
while (!Directory.empty()) {
std::string LoadErrorMessage;
if (CompilationDatabase *DB =
CompilationDatabase::loadFromDirectory(Directory, LoadErrorMessage))
return DB;
- ErrorStream << "No compilation database found in " << Directory.str()
- << "\n" << LoadErrorMessage;
+
+ if (!HasErrorMessage) {
+ ErrorStream << "No compilation database found in " << Directory.str()
+ << " or any parent directory\n" << LoadErrorMessage;
+ HasErrorMessage = true;
+ }
Directory = llvm::sys::path::parent_path(Directory);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62.1.patch
Type: text/x-patch
Size: 1011 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20121015/09453dc4/attachment.bin>
More information about the cfe-commits
mailing list