[clang] [Clang] Force expressions with UO_Not to not be non-negative (PR #126846)

2025-03-27 Thread Richard Smith via cfe-commits
zygoloid wrote: > But still I feel generate a warning for this case went too far. Yeah, that's probably right. Maybe for `-` on a signed operand, we should just return the original range with the `NonNegative` flag cleared out, and shouldn't add the extra bit for the `-128 -> 128` edge case. T

[clang] [Clang] Force expressions with UO_Not to not be non-negative (PR #126846)

2025-03-20 Thread Richard Smith via cfe-commits
zygoloid wrote: > > But still I feel generate a warning for this case went too far. > > Yeah, that's probably right. Maybe for `-` on a signed operand, we should > just return the original range with the `NonNegative` flag cleared out, and > shouldn't add the extra bit for the `-128 -> 128` ed

[clang] [Clang] Force expressions with UO_Not to not be non-negative (PR #126846)

2025-03-19 Thread Richard Smith via cfe-commits
zygoloid wrote: > Would it be possible to provide better fine grained control over the > `-Wsign-compare` so the clang could still flag the the cases like the one in > the summary but ignore the cases where implicit conversion has no side > effects or UB? The warning being produced is a `-Wim

[clang] [Clang] Force expressions with UO_Not to not be non-negative (PR #126846)

2025-03-19 Thread Yutong Zhu via cfe-commits
YutongZhuu wrote: > I think this change might went too far. We are seeing this check flagging > code like this: > > ``` > error: implicit conversion loses integer precision: 'int' to 'int8_t' (aka > 'signed char') [-Werror,-Wimplicit-int-conversion]: > int8_t shift = ... > ... > shift = -shift

[clang] [Clang] Force expressions with UO_Not to not be non-negative (PR #126846)

2025-03-17 Thread Erich Keane via cfe-commits
erichkeane wrote: > > This had the side effect of adding implicit-int-conversion warnings on e.g. > > the following code: > > ``` > > unsigned char foo(unsigned char x) > > { > > return ~x; > > } > > ``` > > > > > > > > > > > > > > > > > > > > > > > >

[clang] [Clang] Force expressions with UO_Not to not be non-negative (PR #126846)

2025-03-15 Thread Yutong Zhu via cfe-commits
YutongZhuu wrote: > This had the side effect of adding implicit-int-conversion warnings on e.g. > the following code: > > ``` > unsigned char foo(unsigned char x) > { > return ~x; > } > ``` > > This seems correct, but this should probably be highlighted in the release > notes. > > Anothe

[clang] [Clang] Force expressions with UO_Not to not be non-negative (PR #126846)

2025-03-15 Thread Jan Patrick Lehr via cfe-commits
jplehr wrote: > Hi, I think this broke two of our buildbots -- for reasons I don't quite > understand, but reverting fixed the issue locally. Can you please take a look > at it? > > https://lab.llvm.org/buildbot/#/builders/10/builds/980 > https://lab.llvm.org/buildbot/#/builders/73/builds/143

[clang] [Clang] Force expressions with UO_Not to not be non-negative (PR #126846)

2025-03-13 Thread Mike Hommey via cfe-commits
glandium wrote: This had the side effect of adding implicit-int-conversion warnings on e.g. the following code: ``` unsigned char foo(unsigned char x) { return ~x; } ``` This seems correct, but this should probably be highlighted in the release notes. Another example is: ``` unsigned int f

[clang] [Clang] Force expressions with UO_Not to not be non-negative (PR #126846)

2025-03-11 Thread Jan Patrick Lehr via cfe-commits
jplehr wrote: Hi, I think this broke two of our buildbots -- for reasons I don't quite understand, but reverting fixed the issue locally. Can you please take a look at it? https://lab.llvm.org/buildbot/#/builders/10/builds/980 https://lab.llvm.org/buildbot/#/builders/73/builds/14304 https://gi

[clang] [Clang] Force expressions with UO_Not to not be non-negative (PR #126846)

2025-03-10 Thread via cfe-commits
https://github.com/cor3ntin closed https://github.com/llvm/llvm-project/pull/126846 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Force expressions with UO_Not to not be non-negative (PR #126846)

2025-03-09 Thread Yutong Zhu via cfe-commits
https://github.com/YutongZhuu edited https://github.com/llvm/llvm-project/pull/126846 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Force expressions with UO_Not to not be non-negative (PR #126846)

2025-03-09 Thread Yutong Zhu via cfe-commits
https://github.com/YutongZhuu edited https://github.com/llvm/llvm-project/pull/126846 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Force expressions with UO_Not to not be non-negative (PR #126846)

2025-03-09 Thread Yutong Zhu via cfe-commits
YutongZhuu wrote: > Can you update the first comment on this PR to reflect what you want to be in > the commit message? I notice that it doesn't describe what you're doing with > negation yet. Thanks! Hello, can you merge this or delete the review request I sent? This was due to an unsuccessf

[clang] [Clang] Force expressions with UO_Not to not be non-negative (PR #126846)

2025-03-09 Thread Yutong Zhu via cfe-commits
YutongZhuu wrote: > Can you update the first comment on this PR to reflect what you want to be in > the commit message? I notice that it doesn't describe what you're doing with > negation yet. Thanks! Addressed https://github.com/llvm/llvm-project/pull/126846 _

[clang] [Clang] Force expressions with UO_Not to not be non-negative (PR #126846)

2025-03-07 Thread Yutong Zhu via cfe-commits
https://github.com/YutongZhuu updated https://github.com/llvm/llvm-project/pull/126846 >From 106a982e3c6bcfa3ee7c26133f0919791699f31a Mon Sep 17 00:00:00 2001 From: Yutong Zhu Date: Sun, 23 Feb 2025 18:16:06 -0500 Subject: [PATCH 1/5] Fix signed-unsigned comparison with UO_Not and UO_Minus ---

[clang] [Clang] Force expressions with UO_Not to not be non-negative (PR #126846)

2025-03-07 Thread Yutong Zhu via cfe-commits
https://github.com/YutongZhuu updated https://github.com/llvm/llvm-project/pull/126846 >From 331ff18c3c3c3a16b7833e6c5299dc40cfacf694 Mon Sep 17 00:00:00 2001 From: Yutong Zhu Date: Sun, 23 Feb 2025 18:16:06 -0500 Subject: [PATCH] Fix signed-unsigned integer comparison diagnosis that contains

[clang] [Clang] Force expressions with UO_Not to not be non-negative (PR #126846)

2025-03-07 Thread Yutong Zhu via cfe-commits
https://github.com/YutongZhuu updated https://github.com/llvm/llvm-project/pull/126846 >From d7404029e8998c8c8945cfaa34cf99b743ec2b70 Mon Sep 17 00:00:00 2001 From: Yutong Zhu Date: Sun, 23 Feb 2025 18:16:06 -0500 Subject: [PATCH 1/4] Fix no warning for comparison of integers of different sign

[clang] [Clang] Force expressions with UO_Not to not be non-negative (PR #126846)

2025-03-07 Thread Richard Smith via cfe-commits
zygoloid wrote: Can you update the first comment on this PR to reflect what you want to be in the commit message? I notice that it doesn't describe what you're doing with negation yet. Thanks! https://github.com/llvm/llvm-project/pull/126846 ___ cfe-

[clang] [Clang] Force expressions with UO_Not to not be non-negative (PR #126846)

2025-03-07 Thread Yutong Zhu via cfe-commits
YutongZhuu wrote: > @YutongZhuu Will you need someone to merge this for you? I think so. I don't think I have the permission to merge. https://github.com/llvm/llvm-project/pull/126846 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lis

[clang] [Clang] Force expressions with UO_Not to not be non-negative (PR #126846)

2025-03-07 Thread Richard Smith via cfe-commits
https://github.com/zygoloid approved this pull request. https://github.com/llvm/llvm-project/pull/126846 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Force expressions with UO_Not to not be non-negative (PR #126846)

2025-03-06 Thread Yutong Zhu via cfe-commits
YutongZhuu wrote: Sorry, I accidentally requested for a review. Did not mean it. https://github.com/llvm/llvm-project/pull/126846 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Force expressions with UO_Not to not be non-negative (PR #126846)

2025-03-06 Thread via cfe-commits
cor3ntin wrote: @YutongZhuu Will you need someone to merge this for you? https://github.com/llvm/llvm-project/pull/126846 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Force expressions with UO_Not to not be non-negative (PR #126846)

2025-02-26 Thread Yutong Zhu via cfe-commits
https://github.com/YutongZhuu updated https://github.com/llvm/llvm-project/pull/126846 >From d7404029e8998c8c8945cfaa34cf99b743ec2b70 Mon Sep 17 00:00:00 2001 From: Yutong Zhu Date: Sun, 23 Feb 2025 18:16:06 -0500 Subject: [PATCH 1/2] Fix no warning for comparison of integers of different sign

[clang] [Clang] Force expressions with UO_Not to not be non-negative (PR #126846)

2025-02-26 Thread Yutong Zhu via cfe-commits
https://github.com/YutongZhuu updated https://github.com/llvm/llvm-project/pull/126846 >From d7404029e8998c8c8945cfaa34cf99b743ec2b70 Mon Sep 17 00:00:00 2001 From: Yutong Zhu Date: Sun, 23 Feb 2025 18:16:06 -0500 Subject: [PATCH] Fix no warning for comparison of integers of different signs --

[clang] [Clang] Force expressions with UO_Not to not be non-negative (PR #126846)

2025-02-23 Thread Yutong Zhu via cfe-commits
@@ -10069,6 +10069,17 @@ static std::optional TryGetExprRange(ASTContext &C, const Expr *E, case UO_AddrOf: // should be impossible return IntRange::forValueOfType(C, GetExprType(E)); +case UO_Not: { + std::optional SubRange = TryGetExprRange( + C,

[clang] [Clang] Force expressions with UO_Not to not be non-negative (PR #126846)

2025-02-23 Thread Yutong Zhu via cfe-commits
https://github.com/YutongZhuu updated https://github.com/llvm/llvm-project/pull/126846 >From d7404029e8998c8c8945cfaa34cf99b743ec2b70 Mon Sep 17 00:00:00 2001 From: Yutong Zhu Date: Sun, 23 Feb 2025 18:16:06 -0500 Subject: [PATCH] Fix no warning for comparison of integers of different signs --

[clang] [Clang] Force expressions with UO_Not to not be non-negative (PR #126846)

2025-02-18 Thread Richard Smith via cfe-commits
@@ -10069,6 +10069,17 @@ static std::optional TryGetExprRange(ASTContext &C, const Expr *E, case UO_AddrOf: // should be impossible return IntRange::forValueOfType(C, GetExprType(E)); +case UO_Not: { + std::optional SubRange = TryGetExprRange( + C,

[clang] [Clang] Force expressions with UO_Not to not be non-negative (PR #126846)

2025-02-13 Thread Yutong Zhu via cfe-commits
https://github.com/YutongZhuu updated https://github.com/llvm/llvm-project/pull/126846 >From 44673ebf7c3fa773ffc7c52141b889c9ea352a93 Mon Sep 17 00:00:00 2001 From: Yutong Zhu Date: Tue, 11 Feb 2025 22:49:40 -0500 Subject: [PATCH] Force expressions with UO_Not to not be non-negative --- clang

[clang] Force expressions with UO_Not to not be non-negative (PR #126846)

2025-02-12 Thread Yutong Zhu via cfe-commits
https://github.com/YutongZhuu edited https://github.com/llvm/llvm-project/pull/126846 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Force expressions with UO_Not to not be non-negative (PR #126846)

2025-02-11 Thread Yutong Zhu via cfe-commits
https://github.com/YutongZhuu created https://github.com/llvm/llvm-project/pull/126846 Fix to issue #18878 This PR issues the bug of not throwing warning for the following code: ```c++ int test13(unsigned a, int *b) { return a > ~(95 != *b); // expected-warning {{comparison of integers