[clang][dataflow] Convert nonnull pointer parameter to a reference.
authorYitzhak Mandelbaum <yitzhakm@google.com>
Fri, 10 Feb 2023 15:02:44 +0000 (15:02 +0000)
committerYitzhak Mandelbaum <yitzhakm@google.com>
Fri, 10 Feb 2023 15:53:28 +0000 (15:53 +0000)
The parameter in question belongs to a function that is only called once. This patch updates the API to use a reference and changes the caller accordingly.

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

clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h
clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp

index 517dd3c..d7ca721 100644 (file)
@@ -119,10 +119,11 @@ public:
     return L1 == L2;
   }
 
-  void transferTypeErased(const CFGElement *Element, TypeErasedLattice &E,
+  void transferTypeErased(const CFGElement &Element, TypeErasedLattice &E,
                           Environment &Env) final {
     Lattice &L = llvm::any_cast<Lattice &>(E.Value);
-    static_cast<Derived *>(this)->transfer(Element, L, Env);
+    // FIXME: change the contract of `transfer` to take a reference.
+    static_cast<Derived *>(this)->transfer(&Element, L, Env);
   }
 
   void transferBranchTypeErased(bool Branch, const Stmt *Stmt,
index 1d7962e..d69adfa 100644 (file)
@@ -96,7 +96,7 @@ public:
 
   /// Applies the analysis transfer function for a given control flow graph
   /// element and type-erased lattice element.
-  virtual void transferTypeErased(const CFGElement *, TypeErasedLattice &,
+  virtual void transferTypeErased(const CFGElement &, TypeErasedLattice &,
                                   Environment &) = 0;
 
   /// Applies the analysis transfer function for a given edge from a CFG block
index b125701..fe00d76 100644 (file)
@@ -374,7 +374,7 @@ transferCFGBlock(const CFGBlock &Block, AnalysisContext &AC,
     }
 
     // User-provided analysis
-    AC.Analysis.transferTypeErased(&Element, State.Lattice, State.Env);
+    AC.Analysis.transferTypeErased(Element, State.Lattice, State.Env);
 
     // Post processing
     if (PostVisitCFG) {