Only report first error when no compilation database is found.

Review: http://llvm-reviews.chandlerc.com/D62
llvm-svn: 165933
This commit is contained in:
Daniel Jasper 2012-10-15 13:12:24 +00:00
parent 16205cd4fa
commit 74351ff4ac
1 changed files with 7 additions and 2 deletions

View File

@ -49,14 +49,19 @@ static CompilationDatabase *
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);
}