[clang] [clang][Sema] Warn consecutive builtin comparisons in an expression (PR #92200)

2024-05-17 Thread Shafik Yaghmour via cfe-commits
@@ -36,7 +36,7 @@ namespace InExpr { // These are valid expressions. foo(0); +foo(0); // expected-warning {{comparisons like 'X<=Y<=Z' don't have their mathematical meaning}} foo(false); shafik wrote: It is a shame we don't catch this one

[clang] [clang][Sema] Warn consecutive builtin comparisons in an expression (PR #92200)

2024-05-17 Thread Vlad Serebrennikov via cfe-commits
@@ -85,7 +85,7 @@ void f(int x, int y, int z) { if ((ayyhttps://github.com/llvm/llvm-project/pull/92200 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][Sema] Warn consecutive builtin comparisons in an expression (PR #92200)

2024-05-17 Thread Erich Keane via cfe-commits
@@ -85,7 +85,7 @@ void f(int x, int y, int z) { if ((ayy` or something). So something like: `comparison 'a>yhttps://github.com/llvm/llvm-project/pull/92200 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[clang] [clang][Sema] Warn consecutive builtin comparisons in an expression (PR #92200)

2024-05-17 Thread Youngsuk Kim via cfe-commits
https://github.com/JOE1994 closed https://github.com/llvm/llvm-project/pull/92200 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][Sema] Warn consecutive builtin comparisons in an expression (PR #92200)

2024-05-17 Thread Youngsuk Kim via cfe-commits
https://github.com/JOE1994 updated https://github.com/llvm/llvm-project/pull/92200 >From 2c7f9a083c129df70a79d019286b6a29643a8973 Mon Sep 17 00:00:00 2001 From: Youngsuk Kim Date: Tue, 14 May 2024 17:42:59 -0500 Subject: [PATCH 1/5] [clang][Sema] Warn consecutive builtin comparisons in an

[clang] [clang][Sema] Warn consecutive builtin comparisons in an expression (PR #92200)

2024-05-17 Thread Aaron Ballman via cfe-commits
@@ -487,6 +487,9 @@ Improvements to Clang's diagnostics } }; +- Clang emits a ``-Wparentheses`` warning for expressions with consecutive comparisons like ``x < y < z``. + It was made a ``-Wparentheses`` warning to be consistent with gcc.

[clang] [clang][Sema] Warn consecutive builtin comparisons in an expression (PR #92200)

2024-05-17 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman approved this pull request. LGTM aside from a small nit with the release notes. https://github.com/llvm/llvm-project/pull/92200 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[clang] [clang][Sema] Warn consecutive builtin comparisons in an expression (PR #92200)

2024-05-17 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman edited https://github.com/llvm/llvm-project/pull/92200 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][Sema] Warn consecutive builtin comparisons in an expression (PR #92200)

2024-05-17 Thread Aaron Ballman via cfe-commits
@@ -215,3 +215,10 @@ namespace PR20735 { // fix-it:"{{.*}}":{[[@LINE-9]]:20-[[@LINE-9]]:20}:")" } } + +void consecutive_builtin_compare(int x, int y, int z) { + (void)(x < y < z); // expected-warning {{comparisons like 'X<=Y<=Z' don't have their mathematical meaning}}

[clang] [clang][Sema] Warn consecutive builtin comparisons in an expression (PR #92200)

2024-05-16 Thread Youngsuk Kim via cfe-commits
https://github.com/JOE1994 edited https://github.com/llvm/llvm-project/pull/92200 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][Sema] Warn consecutive builtin comparisons in an expression (PR #92200)

2024-05-16 Thread Youngsuk Kim via cfe-commits
@@ -215,3 +215,10 @@ namespace PR20735 { // fix-it:"{{.*}}":{[[@LINE-9]]:20-[[@LINE-9]]:20}:")" } } + +void consecutive_builtin_compare(int x, int y, int z) { + (void)(x < y < z); // expected-warning {{comparisons like 'X<=Y<=Z' don't have their mathematical meaning}}

[clang] [clang][Sema] Warn consecutive builtin comparisons in an expression (PR #92200)

2024-05-16 Thread Youngsuk Kim via cfe-commits
https://github.com/JOE1994 updated https://github.com/llvm/llvm-project/pull/92200 >From 2c7f9a083c129df70a79d019286b6a29643a8973 Mon Sep 17 00:00:00 2001 From: Youngsuk Kim Date: Tue, 14 May 2024 17:42:59 -0500 Subject: [PATCH 1/4] [clang][Sema] Warn consecutive builtin comparisons in an

[clang] [clang][Sema] Warn consecutive builtin comparisons in an expression (PR #92200)

2024-05-15 Thread Youngsuk Kim via cfe-commits
https://github.com/JOE1994 edited https://github.com/llvm/llvm-project/pull/92200 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][Sema] Warn consecutive builtin comparisons in an expression (PR #92200)

2024-05-15 Thread Youngsuk Kim via cfe-commits
https://github.com/JOE1994 edited https://github.com/llvm/llvm-project/pull/92200 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][Sema] Warn consecutive builtin comparisons in an expression (PR #92200)

2024-05-15 Thread Youngsuk Kim via cfe-commits
https://github.com/JOE1994 updated https://github.com/llvm/llvm-project/pull/92200 >From 2c7f9a083c129df70a79d019286b6a29643a8973 Mon Sep 17 00:00:00 2001 From: Youngsuk Kim Date: Tue, 14 May 2024 17:42:59 -0500 Subject: [PATCH 1/3] [clang][Sema] Warn consecutive builtin comparisons in an

[clang] [clang][Sema] Warn consecutive builtin comparisons in an expression (PR #92200)

2024-05-15 Thread via cfe-commits
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff c5cd049566a795ba5de88dfbb2eb563cad4a9d8a b3cc457efc40a345d4b67c776edd470e35f73de2 --

[clang] [clang][Sema] Warn consecutive builtin comparisons in an expression (PR #92200)

2024-05-15 Thread Youngsuk Kim via cfe-commits
https://github.com/JOE1994 updated https://github.com/llvm/llvm-project/pull/92200 >From 2c7f9a083c129df70a79d019286b6a29643a8973 Mon Sep 17 00:00:00 2001 From: Youngsuk Kim Date: Tue, 14 May 2024 17:42:59 -0500 Subject: [PATCH 1/2] [clang][Sema] Warn consecutive builtin comparisons in an

[clang] [clang][Sema] Warn consecutive builtin comparisons in an expression (PR #92200)

2024-05-15 Thread Aaron Ballman via cfe-commits
@@ -215,3 +215,10 @@ namespace PR20735 { // fix-it:"{{.*}}":{[[@LINE-9]]:20-[[@LINE-9]]:20}:")" } } + +void consecutive_builtin_compare(int x, int y, int z) { + (void)(x < y < z); // expected-warning {{comparisons like 'X<=Y<=Z' don't have their mathematical meaning}}

[clang] [clang][Sema] Warn consecutive builtin comparisons in an expression (PR #92200)

2024-05-15 Thread Aaron Ballman via cfe-commits
@@ -14878,6 +14878,11 @@ ExprResult Sema::CreateBuiltinBinOp(SourceLocation OpLoc, case BO_GT: ConvertHalfVec = true; ResultTy = CheckCompareOperands(LHS, RHS, OpLoc, Opc); + +if (const auto *BI = dyn_cast(LHSExpr)) + if (BI->isComparisonOp()) +

[clang] [clang][Sema] Warn consecutive builtin comparisons in an expression (PR #92200)

2024-05-15 Thread Youngsuk Kim via cfe-commits
JOE1994 wrote: > Do we know why GCC elected to go that route? This seems like something that > should be enabled by default because the false positive rate should be quite > low. It seems like `gcc` doesn't enable `-Wparentheses` by default, while `clang` enables it by default. I will add a

[clang] [clang][Sema] Warn consecutive builtin comparisons in an expression (PR #92200)

2024-05-15 Thread Aaron Ballman via cfe-commits
AaronBallman wrote: > Set the warning to DefaultIgnore, although -Wparentheses is enabled by > default Do we know why GCC elected to go that route? This seems like something that should be enabled by default because the false positive rate should be quite low.

[clang] [clang][Sema] Warn consecutive builtin comparisons in an expression (PR #92200)

2024-05-14 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-clang Author: Youngsuk Kim (JOE1994) Changes Made the following decisions for consistency with `gcc 14.1`: * Add warning under -Wparentheses * Set the warning to DefaultIgnore, although -Wparentheses is enabled by default * This warning is only issued

[clang] [clang][Sema] Warn consecutive builtin comparisons in an expression (PR #92200)

2024-05-14 Thread Youngsuk Kim via cfe-commits
https://github.com/JOE1994 created https://github.com/llvm/llvm-project/pull/92200 Made the following decisions for consistency with `gcc 14.1`: * Add warning under -Wparentheses * Set the warning to DefaultIgnore, although -Wparentheses is enabled by default * This warning is only issued