This adds a utility matcher (which is placed in util/Matchers.h, because it uses functions from ASTMatchFinder.h which cannot be used from ASTMatchers.h) used by D37014).
This matcher matches the next statement in a statement sequence (such as CompoundStatement). It handles switch statements gracefully.
Details
- Reviewers
alexfh aaron.ballman
Diff Detail
Event Timeline
clang-tidy/utils/Matchers.h | ||
---|---|---|
16 | This will require linking in the clangAnalysis library as well; are we sure we want to take on this dependency here for all matchers? | |
58–60 | Why does it cause the crash? Should that crash not be fixed instead of applying this workaround? | |
70 | No need for the parenthetical. It's generally understood what a CFG is, so you can just use the acronym. | |
74–75 | Elide braces (here and elsewhere). | |
81 | Formatting (here and elsewhere): you should run the patch through clang-format. |
clang-tidy/utils/Matchers.h | ||
---|---|---|
16 | Do you have a specific solution in mind? We could make the matcher local to the check it is being used in (see D37014), but I think it could prove useful for other checks... | |
58–60 | I'm not entirely sure if this is expected behavior or not. In terms of AST, switch statements are a bit special in terms of how they are represented (each case contains all the subsequent cases as its children IIRC). |
clang-tidy/utils/Matchers.h | ||
---|---|---|
16 | No solution in mind -- I was mostly wondering if @alexfh was okay picking up this dependency or not, because it will impact all the clang-tidy modules. | |
58–60 | I'm uncomfortable simply working around known crashes rather than fixing them, even with FIXME comments, because that just means we accrue more technical debt with no plan in place to pay it down in the future. However, I'll let @alexfh make the final call on it. |
I'm fine with the dependency, and I'd probably make the matcher local to the check until there is at least one more use case for it in the codebase.
This will require linking in the clangAnalysis library as well; are we sure we want to take on this dependency here for all matchers?