Add option set match-scope (include-headers|main-file-only) to control only printing matches from the main file.
This can be set once and then avoids the need to pollute all your match expressions with isExpansionInMainFile()
By default it is enabled to only show match results from the main file.
Details
- Reviewers
aaron.ballman steveire
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang-tools-extra/clang-query/Query.cpp | ||
---|---|---|
58–59 | 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? |
clang-tools-extra/clang-query/Query.cpp | ||
---|---|---|
58–59 | 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. |
Change default match mode to include all files.
Update so the prompt to switch match mode is only displayed once.