[all-commits] [llvm/llvm-project] d931ac: [clang][dataflow] Generalise match switch utility ...

weiyi via All-commits all-commits at lists.llvm.org
Thu Sep 1 03:17:06 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: d931ac9e27cab964c65078c80e4488185c62b3d8
      https://github.com/llvm/llvm-project/commit/d931ac9e27cab964c65078c80e4488185c62b3d8
  Author: Wei Yi Tee <wyt at google.com>
  Date:   2022-09-01 (Thu, 01 Sep 2022)

  Changed paths:
    A clang/include/clang/Analysis/FlowSensitive/CFGMatchSwitch.h
    M clang/include/clang/Analysis/FlowSensitive/MatchSwitch.h
    A clang/unittests/Analysis/FlowSensitive/CFGMatchSwitchTest.cpp
    M clang/unittests/Analysis/FlowSensitive/CMakeLists.txt
    M clang/unittests/Analysis/FlowSensitive/MatchSwitchTest.cpp

  Log Message:
  -----------
  [clang][dataflow] Generalise match switch utility to other AST types and add a `CFGMatchSwitch` which currently handles `CFGStmt` and `CFGInitializer`.

`MatchSwitch` currently takes in matchers and functions for the `Stmt` class.

This patch generalises the match switch utility (renamed to `ASTMatchSwitch`) to work for different AST node types by introducing a template argument which is the base type for the AST nodes that the match switch will handle.

A `CFGMatchSwitch` is introduced as a wrapper around multiple `ASTMatchSwitch`s for different base types. It works by unwrapping `CFGElement`s into their contained AST nodes and passing the nodes to the relevant `ASTMatchSwitch`. The `CFGMatchSwitch` currently only handles `CFGStmt` and `CFGInitializer`.

Reviewed By: gribozavr2, sgatev

Differential Revision: https://reviews.llvm.org/D131616




More information about the All-commits mailing list