[PATCH] D121796: [clang][dataflow] Add an API for dataflow "models" -- reusable analysis components.

Yitzhak Mandelbaum via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 16 05:56:26 PDT 2022


ymandel created this revision.
ymandel added reviewers: sgatev, xazax.hun.
Herald added subscribers: tschuett, steakhal, rnkovacs.
Herald added a project: All.
ymandel requested review of this revision.
Herald added a project: clang.

This patch introduces `DataflowModel`, a virtual base class for dataflow
"models": reusable analysis components that model a particular aspect of program
semantics, with respect to a specific lattice.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121796

Files:
  clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h


Index: clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h
===================================================================
--- clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h
+++ clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h
@@ -136,6 +136,26 @@
   return BlockStates;
 }
 
+/// Virtual base class for "dataflow models": reusable analysis components that
+/// model a particular aspect of program semantics, with respect to a specific
+/// lattice. Models are very similar to analyses, except:
+///
+/// a) Models implement a typed dynamic (that is, virtual) interface (with
+///    respect to the lattice type), while analyses implement an untyped dynamic
+///    interface.
+///
+/// b) Models should focus on _modeling_ a particular aspect of program
+///    semantics -- for example, a type and its related functions, and should be
+///    composable with other models over the same lattice.
+///
+/// c) Models do not provide an initial element -- that is the responsibility of
+///    the analysis.
+template <typename Lattice>
+class DataflowModel : public Environment::ValueModel {
+public:
+  virtual void transfer(const Stmt *Stmt, Lattice &L, Environment &Env) = 0;
+};
+
 } // namespace dataflow
 } // namespace clang
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D121796.415794.patch
Type: text/x-patch
Size: 1276 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220316/39473574/attachment.bin>


More information about the cfe-commits mailing list