forked from OSchip/llvm-project
[clang-query] Continue if compilation command not found for some files
When searching for a code pattern in an entire project with a compilation database it's tempting to run ``` clang-query **.cpp ``` And yet, that often breaks because some files are just not in the compilation database: tests, sample code, etc.. clang-query should not stop when encountering such cases. Differential Revision: https://reviews.llvm.org/D51183 llvm-svn: 348328
This commit is contained in:
parent
8076c57fd2
commit
d499725b8f
|
@ -100,8 +100,19 @@ int main(int argc, const char **argv) {
|
|||
ClangTool Tool(OptionsParser.getCompilations(),
|
||||
OptionsParser.getSourcePathList());
|
||||
std::vector<std::unique_ptr<ASTUnit>> ASTs;
|
||||
if (Tool.buildASTs(ASTs) != 0)
|
||||
int Status = Tool.buildASTs(ASTs);
|
||||
int ASTStatus = 0;
|
||||
if (Status == 1) {
|
||||
// Building ASTs failed.
|
||||
return 1;
|
||||
} else if (Status == 2) {
|
||||
ASTStatus |= 1;
|
||||
llvm::errs() << "Failed to build AST for some of the files, "
|
||||
<< "results may be incomplete."
|
||||
<< "\n";
|
||||
} else {
|
||||
assert(Status == 0 && "Unexpected status returned");
|
||||
}
|
||||
|
||||
QuerySession QS(ASTs);
|
||||
|
||||
|
@ -134,5 +145,5 @@ int main(int argc, const char **argv) {
|
|||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return ASTStatus;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue