class MatchSwitchBuilder

Declaration

template <typename State, typename Result = void>
class MatchSwitchBuilder { /* full declaration omitted */ };

Description

Collects cases of a "match switch": a collection of matchers paired with callbacks, which together define a switch that can be applied to a `Stmt`. 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 `MatchSwitch` once, in the constructor of the analysis, and then reuse it each time that `transfer` is called, with a fresh state value.

Declared at: clang/include/clang/Analysis/FlowSensitive/MatchSwitch.h:71

Templates

State
Result = void

Member Variables

private std::vector< ast_matchers::internal::DynTypedMatcher> Matchers
private std::vector<std::function<Result( const Stmt*, const ast_matchers::MatchFinder::MatchResult&, State&)>> Actions

Method Overview

  • public MatchSwitch<State, Result> Build() &&
  • private ast_matchers::internal::DynTypedMatcher BuildMatcher()
  • public template <typename Node>MatchSwitchBuilder<State, Result> && CaseOf(ast_matchers::internal::Matcher<Stmt> M, std::function<Result (const Node *, const ast_matchers::MatchFinder::MatchResult &, State &)> A) &&

Methods

MatchSwitch<State, Result> Build() &&

Declared at: clang/include/clang/Analysis/FlowSensitive/MatchSwitch.h:94

ast_matchers::internal::DynTypedMatcher
BuildMatcher()

Declared at: clang/include/clang/Analysis/FlowSensitive/MatchSwitch.h:117

template <typename Node>
MatchSwitchBuilder<State, Result>&& CaseOf(
    ast_matchers::internal::Matcher<Stmt> M,
    std::function<
        Result(const Node*,
               const ast_matchers::MatchFinder::
                   MatchResult&,
               State&)> A) &&

Description

Registers an action that will be triggered by the match of a pattern against the input statement. Requirements: `Node` should be a subclass of `Stmt`.

Declared at: clang/include/clang/Analysis/FlowSensitive/MatchSwitch.h:81

Templates

Node

Parameters

ast_matchers::internal::Matcher<Stmt> M
std::function<Result( const Node*, const ast_matchers::MatchFinder::MatchResult&, State&)> A