[clang] [clang] fix wrong result of pointers comparison between unknown and stack (PR #122404)

via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 10 23:57:07 PST 2025


================
@@ -952,6 +952,12 @@ SVal SimpleSValBuilder::evalBinOpLL(ProgramStateRef state,
     const MemSpaceRegion *RightMS = RightBase->getMemorySpace();
     const MemSpaceRegion *UnknownMS = MemMgr.getUnknownRegion();
 
+    if (LeftMS != RightMS &&
+        ((isa<UnknownSpaceRegion>(LeftMS) && isa<StackSpaceRegion>(RightMS)) ||
+         (isa<StackSpaceRegion>(LeftMS) && isa<UnknownSpaceRegion>(RightMS)))) {
+      return UnknownVal();
+    }
+
----------------
mzyKi wrote:

Thanks for your suggestions!

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


More information about the cfe-commits mailing list