[PATCH] D131616: [clang][dataflow] Generalise match switch utility to other AST types and add a `CFGMatchSwitch` which currently handles `CFGStmt` and `CFGInitializer`.
Dmitri Gribenko via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 16 08:45:30 PDT 2022
gribozavr2 accepted this revision.
gribozavr2 added inline comments.
This revision is now accepted and ready to land.
================
Comment at: clang/include/clang/Analysis/FlowSensitive/CFGMatchSwitch.h:53-54
+ template <typename NodeT>
+ CFGMatchSwitchBuilder CaseOfCFGStmt(MSMatcherT<Stmt> M,
+ MSActionT<NodeT, State, Result> A) {
+ StmtBuilder = StmtBuilder.template CaseOf<NodeT>(M, A);
----------------
================
Comment at: clang/include/clang/Analysis/FlowSensitive/CFGMatchSwitch.h:67-68
+ template <typename NodeT>
+ CFGMatchSwitchBuilder CaseOfCFGInit(MSMatcherT<CXXCtorInitializer> M,
+ MSActionT<NodeT, State, Result> A) {
+ InitBuilder = InitBuilder.template CaseOf<NodeT>(M, A);
----------------
================
Comment at: clang/include/clang/Analysis/FlowSensitive/MatchSwitch.h:92-93
+ template <typename NodeT>
+ ASTMatchSwitchBuilder CaseOf(MSMatcherT<BaseT> M,
+ MSActionT<NodeT, State, Result> A) {
Matchers.push_back(std::move(M));
----------------
Can we keep doing this?
================
Comment at: clang/include/clang/Analysis/FlowSensitive/MatchSwitch.h:102
- MatchSwitch<State, Result> Build() && {
+ ASTMatchSwitch<BaseT, State, Result> Build() {
return [Matcher = BuildMatcher(), Actions = std::move(Actions)](
----------------
Ditto.
================
Comment at: clang/unittests/Analysis/FlowSensitive/CFGMatchSwitchTest.cpp:34-35
+struct CFGElementMatches {
+ unsigned int StmtMatches = 0;
+ unsigned int InitializerMatches = 0;
+};
----------------
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D131616/new/
https://reviews.llvm.org/D131616
More information about the cfe-commits
mailing list