Adds MatchSwitch, a library for simplifying implementation of transfer
functions. MatchSwitch supports constructing a "switch" statement, where each
case of the switch is defined by an AST matcher. The cases are considered in
order, like pattern matching in functional languages.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang/include/clang/Analysis/FlowSensitive/MatchSwitch.h | ||
---|---|---|
51 | When we instantiate this with TransferState we have ASTContext both as an argument and as a member of State. Is this intentional? | |
110 | This does not need to be addressed here but it looks like it could be a useful feature to be able to tag nodes with integer identifiers. |
Thanks for the fast review!
clang/include/clang/Analysis/FlowSensitive/MatchSwitch.h | ||
---|---|---|
51 | Yes, but... But, we could reorganize a bit. Either: I'm inclined towards the first option, since it seems "right" to give full access to the MatchResult. WDYT? | |
110 | Great point. I'm not sure that would work here, fwiw, because we prefix with "Tag" here to protect against interfering with any IDs in the matcher. I suppose we could "reserve" a portion of the ID space. But, in general, integers would make more sense in other situations that deal w/ matchers. The problem is that, unless we encode them as strings, the implementation inside the matchers could be kind of messy. |
clang/include/clang/Analysis/FlowSensitive/MatchSwitch.h | ||
---|---|---|
51 | Option a) sounds good to me, thanks! |
When we instantiate this with TransferState we have ASTContext both as an argument and as a member of State. Is this intentional?