[clang] [clang][analyzer] Stabilize path-constraint order by using alloc IDs (PR #121347)

Balazs Benics via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 31 00:30:56 PST 2024


================
@@ -401,7 +401,22 @@ class RangeSet {
   friend class Factory;
 };
 
-using ConstraintMap = llvm::ImmutableMap<SymbolRef, RangeSet>;
+struct ConstraintKVInfo : llvm::ImutKeyValueInfo<SymbolRef, RangeSet> {
+  static inline bool isEqual(key_type_ref L, key_type_ref R) {
+    return L->getAllocID() == R->getAllocID();
+  }
+
+  static inline bool isLess(key_type_ref L, key_type_ref R) {
+    return L->getAllocID() < R->getAllocID();
+  }
+
+  static inline void Profile(llvm::FoldingSetNodeID &ID, value_type_ref V) {
+    ID.AddInteger(V.first->getAllocID());
+    ID.Add(V.second);
+  }
+};
+
+using ConstraintMap = llvm::ImmutableMap<SymbolRef, RangeSet, ConstraintKVInfo>;
----------------
steakhal wrote:

Shouldn't this ordering be a more sensible ordering for all containers where SymbolRefs are the keys?

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


More information about the cfe-commits mailing list