[PATCH] D127646: [analyzer][NFC][test] Add new RUN lint with support-symbolic-integer-casts=true to svalbuilder-rearrange-comparisons.c

Gabor Marton via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 15 05:02:15 PDT 2022


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
martong marked an inline comment as done.
Closed by commit rG3605ebca32fc: [analyzer][NFC][test] Add new RUN lint with support-symbolic-integer-casts=true… (authored by martong).

Changed prior to commit:
  https://reviews.llvm.org/D127646?vs=436397&id=437113#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D127646/new/

https://reviews.llvm.org/D127646

Files:
  clang/test/Analysis/svalbuilder-rearrange-comparisons.c
  clang/test/Analysis/svalbuilder-rearrange-comparisons.cpp


Index: clang/test/Analysis/svalbuilder-rearrange-comparisons.cpp
===================================================================
--- clang/test/Analysis/svalbuilder-rearrange-comparisons.cpp
+++ clang/test/Analysis/svalbuilder-rearrange-comparisons.cpp
@@ -1,8 +1,23 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=debug.ExprInspection,core.builtin -analyzer-config aggressive-binary-operation-simplification=true -verify -analyzer-config eagerly-assume=false %s
-
-void clang_analyzer_eval(int x);
-void clang_analyzer_denote(int x, const char *literal);
-void clang_analyzer_express(int x);
+// RUN: %clang_analyze_cc1 \
+// RUN:    -analyzer-checker=debug.ExprInspection,core.builtin \
+// RUN:    -analyzer-config aggressive-binary-operation-simplification=true \
+// RUN:    -analyzer-config support-symbolic-integer-casts=false \
+// RUN:    -analyzer-config eagerly-assume=false \
+// RUN:    -verify %s
+
+// RUN: %clang_analyze_cc1 \
+// RUN:    -analyzer-checker=debug.ExprInspection,core.builtin \
+// RUN:    -analyzer-config aggressive-binary-operation-simplification=true \
+// RUN:    -analyzer-config support-symbolic-integer-casts=true \
+// RUN:    -DSUPPORT_SYMBOLIC_INTEGER_CASTS \
+// RUN:    -analyzer-config eagerly-assume=false \
+// RUN:    -verify %s
+
+void clang_analyzer_eval(bool x);
+template <typename T>
+void clang_analyzer_denote(T x, const char *literal);
+template <typename T>
+void clang_analyzer_express(T x);
 
 void exit(int);
 
@@ -510,6 +525,17 @@
   clang_analyzer_eval(x < y); // expected-warning {{FALSE}}
 }
 
+// Rearrange should happen on signed types only (tryRearrange):
+//
+//  // Rearrange signed symbolic expressions only
+//  if (!SingleTy->isSignedIntegerOrEnumerationType())
+//    return None;
+//
+// Without the symbolic casts, the SVal for `x` in `unsigned x = f()` will be
+// the signed `int`. However, with the symbolic casts it will be `unsigned`.
+// Thus, these tests are meaningful only if the cast is not emitted.
+#ifndef SUPPORT_SYMBOLIC_INTEGER_CASTS
+
 void compare_different_symbol_equal_unsigned(void) {
   unsigned x = f(), y = f();
   clang_analyzer_denote(x, "$x");
@@ -894,6 +920,10 @@
   clang_analyzer_express(x < y); // expected-warning {{$x - $y < 1}}
 }
 
+#endif
+
+// These pass even with aggressive-binary-operation-simplification=false
+
 void compare_same_symbol_less_unsigned(void) {
   unsigned x = f(), y = x;
   clang_analyzer_denote(x, "$x");


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127646.437113.patch
Type: text/x-patch
Size: 2444 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220615/03f2b59b/attachment-0001.bin>


More information about the cfe-commits mailing list