diff options
author | George Karpenkov <ekarpenkov@apple.com> | 2018-12-05 02:02:40 +0000 |
---|---|---|
committer | George Karpenkov <ekarpenkov@apple.com> | 2018-12-05 02:02:40 +0000 |
commit | d499725b8ffa4826e1fb4f7d2a87f5bcf1540229 (patch) | |
tree | d1de0e609062924b64ec982cc93f5ee9b5c8720c /clang-tools-extra/clang-query | |
parent | 8076c57fd2f9ec89f2f64bc22abae96dec7c2e99 (diff) | |
download | llvm-d499725b8ffa4826e1fb4f7d2a87f5bcf1540229.zip llvm-d499725b8ffa4826e1fb4f7d2a87f5bcf1540229.tar.gz llvm-d499725b8ffa4826e1fb4f7d2a87f5bcf1540229.tar.bz2 |
[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
Diffstat (limited to 'clang-tools-extra/clang-query')
-rw-r--r-- | clang-tools-extra/clang-query/tool/ClangQuery.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/clang-tools-extra/clang-query/tool/ClangQuery.cpp b/clang-tools-extra/clang-query/tool/ClangQuery.cpp index 26a2ccf..59c49ba 100644 --- a/clang-tools-extra/clang-query/tool/ClangQuery.cpp +++ b/clang-tools-extra/clang-query/tool/ClangQuery.cpp @@ -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; } |