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

weiyi via All-commits all-commits at lists.llvm.org
Wed Aug 31 10:02:58 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: c9033eeb2e59c0157b84adfc6b0fe345f6f03113
      https://github.com/llvm/llvm-project/commit/c9033eeb2e59c0157b84adfc6b0fe345f6f03113
  Author: Wei Yi Tee <wyt at google.com>
  Date:   2022-08-31 (Wed, 31 Aug 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