[clang] [clang][dataflow] Add new `join` API and replace existing `merge` implementations. (PR #80361)

via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 6 11:25:46 PST 2024


================
@@ -105,6 +105,29 @@ class Environment {
       return true;
     }
 
+    /// Modifies `JoinedVal` to approximate both `Val1` and `Val2`. This should
+    /// obey the properties of a lattice join.
+    ///
+    /// `Env1` and `Env2` can be used to query child values and path condition
+    /// implications of `Val1` and `Val2` respectively.
+    ///
+    /// Requirements:
+    ///
+    ///  `Val1` and `Val2` must be distinct.
+    ///
+    ///  `Val1`, `Val2`, and `JoinedVal` must model values of type `Type`.
+    ///
+    ///  `Val1` and `Val2` must be assigned to the same storage location in
+    ///  `Env1` and `Env2` respectively.
+    virtual void join(QualType Type, const Value &Val1, const Environment &Env1,
+                      const Value &Val2, const Environment &Env2,
+                      Value &JoinedVal, Environment &JoinedEnv) {
+      bool ShouldKeep =
+          merge(Type, Val1, Env1, Val2, Env2, JoinedVal, JoinedEnv);
+      assert(ShouldKeep && "dropping merged value is unsupported");
+      (void)ShouldKeep;
----------------
martinboehme wrote:

```suggestion
      [[maybe_unused]] bool ShouldKeep =
          merge(Type, Val1, Env1, Val2, Env2, JoinedVal, JoinedEnv);
      assert(ShouldKeep && "dropping merged value is unsupported");
```

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


More information about the cfe-commits mailing list