[clang] [clang][dataflow] Merge `RecordValue`s with different locations correctly. (PR #65319)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 11 00:25:41 PDT 2023
================
@@ -121,18 +121,18 @@ static Value *mergeDistinctValues(QualType Type, Value &Val1,
Value *MergedVal = nullptr;
if (auto *RecordVal1 = dyn_cast<RecordValue>(&Val1)) {
- [[maybe_unused]] auto *RecordVal2 = cast<RecordValue>(&Val2);
-
- // Values to be merged are always associated with the same location in
- // `LocToVal`. The location stored in `RecordVal` should therefore also
- // be the same.
- assert(&RecordVal1->getLoc() == &RecordVal2->getLoc());
-
- // `RecordVal1` and `RecordVal2` may have different properties associated
- // with them. Create a new `RecordValue` without any properties so that we
- // soundly approximate both values. If a particular analysis needs to merge
- // properties, it should do so in `DataflowAnalysis::merge()`.
- MergedVal = &MergedEnv.create<RecordValue>(RecordVal1->getLoc());
+ auto *RecordVal2 = cast<RecordValue>(&Val2);
+
+ if (&RecordVal1->getLoc() == &RecordVal2->getLoc())
+ // `RecordVal1` and `RecordVal2` may have different properties associated
+ // with them. Create a new `RecordValue` without any properties so that we
+ // soundly approximate both values. If a particular analysis needs to
+ // merge properties, it should do so in `DataflowAnalysis::merge()`.
----------------
martinboehme wrote:
I like the suggestion -- done!
https://github.com/llvm/llvm-project/pull/65319
More information about the cfe-commits
mailing list