Author: Gabor Marton Date: 2022-06-15T13:52:18+02:00 New Revision: 3605ebca32fc42d01a54eea00bb4bf8049dca214
URL: https://github.com/llvm/llvm-project/commit/3605ebca32fc42d01a54eea00bb4bf8049dca214 DIFF: https://github.com/llvm/llvm-project/commit/3605ebca32fc42d01a54eea00bb4bf8049dca214.diff LOG: [analyzer][NFC][test] Add new RUN lint with support-symbolic-integer-casts=true to svalbuilder-rearrange-comparisons.c Added a new run line to bolster gradual transition of handling cast operations, see https://discourse.llvm.org/t/roadmap-of-modeling-symbolic-cast-operations/63107 Differential Revision: https://reviews.llvm.org/D127646 Added: clang/test/Analysis/svalbuilder-rearrange-comparisons.cpp Modified: Removed: clang/test/Analysis/svalbuilder-rearrange-comparisons.c ################################################################################ diff --git a/clang/test/Analysis/svalbuilder-rearrange-comparisons.c b/clang/test/Analysis/svalbuilder-rearrange-comparisons.cpp similarity index 96% rename from clang/test/Analysis/svalbuilder-rearrange-comparisons.c rename to clang/test/Analysis/svalbuilder-rearrange-comparisons.cpp index 32af8dde71c92..06a5c7c41169b 100644 --- a/clang/test/Analysis/svalbuilder-rearrange-comparisons.c +++ b/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 @@ void compare_same_symbol_minus_left_minus_right_int_less(void) { 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_ diff erent_symbol_equal_unsigned(void) { unsigned x = f(), y = f(); clang_analyzer_denote(x, "$x"); @@ -894,6 +920,10 @@ void compare_ diff erent_symbol_minus_left_minus_right_int_less_unsigned(void) { 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"); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits