[PATCH] D97805: [clang-query] Add option to enable only displaying main file matches

Nathan James via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 3 07:12:23 PST 2021


njames93 added inline comments.


================
Comment at: clang-tools-extra/clang-query/Query.cpp:60-61
+        "    main-file-only                  "
+        "Only match nodes from the main source file. This mode is the "
+        "default.\n"
         "  set output <feature>              "
----------------
aaron.ballman wrote:
> I'm not super keen on this being the default behavior. One of the big uses for clang-query is to experiment with matchers and I think ignoring nodes by default makes it harder to know whether you've written the matcher correctly or not. e.g., you write the matcher, run it over a source file, don't get any results -- is that because the matcher was nonsense or because the mode excluded matching on nodes in headers by default?
> 
> The fact that we print how many nodes were skipped does help (so it's not a silent when you match only in headers), but I think the default behavior should be to match on what's in the source code (which includes header contents) and users should have to opt into getting less results. WDYT?
I thought of making main-file-only the default as its the behaviour that clang-tidy exhibits by default. That's also the reason I included printing details of skipped matching nodes. But you're right there's definitely a compelling argument to leave the default as matching from header files as well.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97805/new/

https://reviews.llvm.org/D97805



More information about the cfe-commits mailing list