clang 20.0.0git
Public Member Functions | List of all members
clang::dataflow::ASTMatchSwitchBuilder< BaseT, State, Result > Class Template Reference

Collects cases of a "match switch": a collection of matchers paired with callbacks, which together define a switch that can be applied to a node whose type derives from BaseT. More...

#include "clang/Analysis/FlowSensitive/MatchSwitch.h"

Inheritance diagram for clang::dataflow::ASTMatchSwitchBuilder< BaseT, State, Result >:
Inheritance graph
[legend]

Public Member Functions

template<typename NodeT >
ASTMatchSwitchBuilder && CaseOf (MatchSwitchMatcher< BaseT > M, MatchSwitchAction< NodeT, State, Result > A) &&
 Registers an action that will be triggered by the match of a pattern against the input statement.
 
ASTMatchSwitch< BaseT, State, ResultBuild () &&
 

Detailed Description

template<typename BaseT, typename State, typename Result = void>
class clang::dataflow::ASTMatchSwitchBuilder< BaseT, State, Result >

Collects cases of a "match switch": a collection of matchers paired with callbacks, which together define a switch that can be applied to a node whose type derives from BaseT.

This structure can simplify the definition of transfer functions that rely on pattern-matching.

For example, consider an analysis that handles particular function calls. It can define the ASTMatchSwitch once, in the constructor of the analysis, and then reuse it each time that transfer is called, with a fresh state value.

.CaseOf(callExpr(callee(functionDecl(hasName("foo")))), TransferFooCall)
.CaseOf(callExpr(argumentCountIs(2),
callee(functionDecl(hasName("bar")))),
TransferBarCall)
.Build();
}
Collects cases of a "match switch": a collection of matchers paired with callbacks,...
Definition: MatchSwitch.h:96
ASTMatchSwitchBuilder && CaseOf(MatchSwitchMatcher< BaseT > M, MatchSwitchAction< NodeT, State, Result > A) &&
Registers an action that will be triggered by the match of a pattern against the input statement.
Definition: MatchSwitch.h:105
ASTMatchSwitch< BaseT, State, Result > Build() &&
Definition: MatchSwitch.h:117
internal::Matcher< NamedDecl > hasName(StringRef Name)
Matches NamedDecl nodes that have the specified name.
Definition: ASTMatchers.h:3079
const internal::VariadicDynCastAllOfMatcher< Stmt, CallExpr > callExpr
Matches call expressions.
const internal::VariadicDynCastAllOfMatcher< Decl, FunctionDecl > functionDecl
Matches function declarations.
std::function< Result(const BaseT &, ASTContext &, State &)> ASTMatchSwitch
Definition: MatchSwitch.h:73

Definition at line 96 of file MatchSwitch.h.

Member Function Documentation

◆ Build()

template<typename BaseT , typename State , typename Result = void>
ASTMatchSwitch< BaseT, State, Result > clang::dataflow::ASTMatchSwitchBuilder< BaseT, State, Result >::Build ( ) &&
inline

Definition at line 117 of file MatchSwitch.h.

References ID, clang::ast_matchers::matchDynamic(), Node, and clang::Result.

◆ CaseOf()

template<typename BaseT , typename State , typename Result = void>
template<typename NodeT >
ASTMatchSwitchBuilder && clang::dataflow::ASTMatchSwitchBuilder< BaseT, State, Result >::CaseOf ( MatchSwitchMatcher< BaseT >  M,
MatchSwitchAction< NodeT, State, Result A 
) &&
inline

Registers an action that will be triggered by the match of a pattern against the input statement.

Requirements:

NodeT should be derived from BaseT.

Definition at line 105 of file MatchSwitch.h.

References Node.


The documentation for this class was generated from the following file: