================
@@ -164,23 +169,28 @@ class Environment {
   Environment &operator=(Environment &&Other) = default;
 
   /// Creates an environment that uses `DACtx` to store objects that encompass
-  /// the state of a program.
-  ///
-  /// If `DeclCtx` is a function, initializes the environment with symbolic
-  /// representations of the function parameters.
-  ///
-  /// If `DeclCtx` is a non-static member function, initializes the environment
-  /// with a symbolic representation of the `this` pointee.
-  Environment(DataflowAnalysisContext &DACtx, const DeclContext &DeclCtx);
+  /// the state of a program, with `S` as the initial analysis target.
+  Environment(DataflowAnalysisContext &DACtx, Stmt &S) : Environment(DACtx) {
+    InitialTargetStmt = &S;
+  }
 
-  /// Assigns storage locations and values to all parameters, captures, global
-  /// variables, fields and functions referenced in the function currently 
being
-  /// analyzed.
+  /// Creates an environment that uses `DACtx` to store objects that encompass
+  /// the state of a program, with `FD` as the initial analysis target.
   ///
   /// Requirements:
   ///
   ///  The function must have a body, i.e.
   ///  `FunctionDecl::doesThisDecalarationHaveABody()` must be true.
+  Environment(DataflowAnalysisContext &DACtx, const FunctionDecl &FD)
+      : Environment(DACtx, *FD.getBody()) {
+    InitialTargetFunc = &FD;
+  }
+
+  /// Assigns storage locations and values to all parameters, captures, global
+  /// variables, fields and functions referenced in the initial analysis 
target.
+  ///
+  /// If the target is a non-static member function, initializes the 
environment
+  /// with a symbolic representation of the `this` pointee.
   void initialize();
----------------
martinboehme wrote:

This now uses the member variables `InitiialTargetFunc` and 
`InitialTargetStmt`. It seems it would be an error to call this if the call 
stack is non-empty -- so should we add a precondition for this (both as an 
assertion and as documentation here)?

https://github.com/llvm/llvm-project/pull/91616
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to