[clang] [clang][dataflow] Fully support Environment construction for Stmt analysis. (PR #91616)

via cfe-commits cfe-commits at lists.llvm.org
Wed May 15 01:07:35 PDT 2024


================
@@ -641,23 +656,20 @@ class Environment {
   /// (or the flow condition is overly constraining) or if the solver times out.
   bool allows(const Formula &) const;
 
-  /// Returns the `DeclContext` of the block being analysed, if any. Otherwise,
-  /// returns null.
-  const DeclContext *getDeclCtx() const { return CallStack.back(); }
-
   /// Returns the function currently being analyzed, or null if the code being
   /// analyzed isn't part of a function.
   const FunctionDecl *getCurrentFunc() const {
-    return dyn_cast<FunctionDecl>(getDeclCtx());
+    return CallStack.empty() ? InitialTargetFunc : CallStack.back();
   }
 
   /// Returns the size of the call stack.
----------------
martinboehme wrote:

Can we make this more precise, particularly given that this PR actually changes what this function returns? See suggestion.

```suggestion
  /// Returns the size of the call stack, not counting the initial analysis target.
```

https://github.com/llvm/llvm-project/pull/91616


More information about the cfe-commits mailing list