[clang-tools-extra] r348328 - [clang-query] Continue if compilation command not found for some files
George Karpenkov via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 4 18:02:40 PST 2018
Author: george.karpenkov
Date: Tue Dec 4 18:02:40 2018
New Revision: 348328
URL: http://llvm.org/viewvc/llvm-project?rev=348328&view=rev
Log:
[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
Modified:
clang-tools-extra/trunk/clang-query/tool/ClangQuery.cpp
Modified: clang-tools-extra/trunk/clang-query/tool/ClangQuery.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-query/tool/ClangQuery.cpp?rev=348328&r1=348327&r2=348328&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-query/tool/ClangQuery.cpp (original)
+++ clang-tools-extra/trunk/clang-query/tool/ClangQuery.cpp Tue Dec 4 18:02:40 2018
@@ -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;
}
More information about the cfe-commits
mailing list