[clang-tools-extra] [analyzer] Split alpha core Identical Expression tests (PR #119543)
Julian Schmidt via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 11 12:59:25 PST 2024
================
@@ -0,0 +1,772 @@
+// RUN: clang-tidy %s -checks="-*,bugprone-branch-clone" -- 2>&1 | FileCheck %s --check-prefix=CHECK-MESSAGES-BUGPRONEBRANCH
+
+/* Only one expected warning per function allowed at the very end. */
+
+int func(void)
+{
+ return 0;
+}
+
+int func2(void)
+{
+ return 0;
+}
+
+int funcParam(int a)
+{
+ return 0;
+}
+
+/* '!=' operator*/
+
+
+/* '!=' with int pointer */
+
+int checkNotEqualIntPointerLiteralCompare1(void) {
+ int* p = 0;
+ return (p != 0); // no warning
+}
+
+int checkNotEqualIntPointerLiteralCompare2(void) {
+ return (6 != 7); // no warning
+}
+
+int checkNotEqualIntPointerDeclCompare1(void) {
+ int k = 3;
+ int* f = &k;
+ int* g = &k;
+ return (f != g); // no warning
+}
+
+int checkNotEqualCastIntPointerDeclCompare11(void) {
+ int k = 7;
+ int* f = &k;
+ return ((int*)f != (int*)f);
+// CHECK-MESSAGES-IDENTEXPR: :[[@LINE-1]]:19: warning: both sides of operator are equivalent [misc-redundant-expression]
----------------
5chmidti wrote:
You left-in `IDENTEXPR`-suffix checks, which are confusing when this file is not for testing the redundant expression check.
https://github.com/llvm/llvm-project/pull/119543
More information about the cfe-commits
mailing list