This is an archive of the discontinued LLVM Phabricator instance.

[clang-query] continue querying even if files are skipped
AbandonedPublic

Authored by Lekensteyn on Nov 5 2018, 8:39 AM.

Details

Reviewers
cfe-commits
pcc
Summary

Like clang-check, continue even if some source files were not found in
the compilation database. This makes it possible to do search for
matching sources and query files that exist in the compilation db:

clang-query -c 'm callExpr(callee(functionDecl(hasName("function_name"))))' $(grep -rl ^function_name)

Note: buildASTs calls ClangTool::run which returns 1 if any of the
commands failed and 2 otherwise if any of the files were missing.

Diff Detail

Event Timeline

Lekensteyn created this revision.Nov 5 2018, 8:39 AM
Lekensteyn added inline comments.
test/clang-query/database-missing-entry.c
9

On trunk this fails tests because of https://reviews.llvm.org/D51729. Reverting that patch will properly ignore the missing file.

Lekensteyn updated this revision to Diff 172747.Nov 6 2018, 5:59 AM
Lekensteyn retitled this revision from [clang-query] continue even if files are skipped to [clang-query] continue querying even if files are skipped.

Changes:

  • Return 1 (instead of 0) if none of the files could be parsed (and add a test for it)
  • Propagate any error code (like 2 in case of some missing files) from Tool.buildASTs instead of returning 0.
  • Change test to accomodate the change in behavior/output due to https://reviews.llvm.org/D51729 (Thanks to Sam McCall for feedback.)
Lekensteyn abandoned this revision.Dec 9 2018, 9:12 AM

This was addressed by https://reviews.llvm.org/D51183 (without new tests though).