[PATCH] D45557: [Analyzer] Fix for SValBuilder expressions rearrangement

Balogh, Ádám via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 13 02:41:39 PDT 2018


baloghadamsoftware updated this revision to Diff 142365.
baloghadamsoftware added a comment.

Updated according to the comments.


https://reviews.llvm.org/D45557

Files:
  lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  test/Analysis/svalbuilder-rearrange-comparisons.c


Index: test/Analysis/svalbuilder-rearrange-comparisons.c
===================================================================
--- test/Analysis/svalbuilder-rearrange-comparisons.c
+++ test/Analysis/svalbuilder-rearrange-comparisons.c
@@ -929,3 +929,8 @@
     clang_analyzer_eval(n - 126 == m + 3); // expected-warning{{UNKNOWN}}
   }
 }
+
+int mixed_integer_types(int x, int y) {
+  short a = x - 1U;
+  return a - y;
+}
Index: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===================================================================
--- lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -469,6 +469,8 @@
     // Initialize SingleTy later with a symbol's type.
   } else if (BinaryOperator::isAdditiveOp(Op)) {
     SingleTy = ResultTy;
+    if (LSym->getType() != SingleTy)
+      return None;
     // Substracting unsigned integers is a nightmare.
     if (!SingleTy->isSignedIntegerOrEnumerationType())
       return None;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45557.142365.patch
Type: text/x-patch
Size: 982 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180413/a801e8bc/attachment.bin>


More information about the cfe-commits mailing list