[clang-tools-extra] Add clang-tidy check to suggest replacement of conditional statement with std::min/std::max (PR #77816)

2024-01-16 Thread Bhuminjay Soni via cfe-commits
@@ -0,0 +1,121 @@ +// RUN: %check_clang_tidy %s readability-use-std-min-max %t + +constexpr int myConstexprMin(int a, int b) { + return a < b ? a : b; +} + +constexpr int myConstexprMax(int a, int b) { + return a > b ? a : b; +} + +int bar(int x, int y) { + return x < y ? x : y

[clang-tools-extra] Add clang-tidy check to suggest replacement of conditional statement with std::min/std::max (PR #77816)

2024-01-16 Thread Bhuminjay Soni via cfe-commits
11happy wrote: Hello @PiotrZSL , @felix642 , @EugeneZelenko I am not able to get macro thing done, I request your guidance. Thank you https://github.com/llvm/llvm-project/pull/77816 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists

[clang-tools-extra] Add clang-tidy check to suggest replacement of conditional statement with std::min/std::max (PR #77816)

2024-01-17 Thread Bhuminjay Soni via cfe-commits
11happy wrote: **Here's the update for recent commit :** - Modified the RegisterMatcher to support the `If` statement with brackets by adding this ```compoundStmt(has(binaryOperator( hasOperatorName("="), hasLHS(expr().bind("lhsVar2")), hasRHS(expr

[clang-tools-extra] Add clang-tidy check to suggest replacement of conditional statement with std::min/std::max (PR #77816)

2024-01-17 Thread Bhuminjay Soni via cfe-commits
11happy wrote: > @11happy what are you trying to achieve exactly and what is not working ? Is > this related to the example that you provided above? > > > ``` > > auto lhsVar1Str = Lexer::getSourceText( > > >CharSourceRange::getTokenRange(Source.getSpellingLoc(lhsVar1->getBeginLoc()),Source.ge

[clang-tools-extra] [llvm] [clang] Add clang-tidy check to suggest replacement of conditional statement with std::min/std::max (PR #77816)

2024-01-18 Thread Bhuminjay Soni via cfe-commits
11happy wrote: A humble reminder. @PiotrZSL Can you please review this and suggest if any changes required?. Thank you https://github.com/llvm/llvm-project/pull/77816 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-b

[llvm] [clang-tools-extra] [clang] Add clang-tidy check to suggest replacement of conditional statement with std::min/std::max (PR #77816)

2024-01-18 Thread Bhuminjay Soni via cfe-commits
@@ -0,0 +1,149 @@ +// RUN: %check_clang_tidy %s readability-use-std-min-max %t + +#define MY_MACRO_MIN(a, b) ((a) < (b) ? (a) : (b)) + +constexpr int myConstexprMin(int a, int b) { + return a < b ? a : b; +} + +constexpr int myConstexprMax(int a, int b) { + return a > b ? a : b;

[llvm] [clang-tools-extra] [clang] Add clang-tidy check to suggest replacement of conditional statement with std::min/std::max (PR #77816)

2024-01-18 Thread Bhuminjay Soni via cfe-commits
@@ -0,0 +1,149 @@ +// RUN: %check_clang_tidy %s readability-use-std-min-max %t + +#define MY_MACRO_MIN(a, b) ((a) < (b) ? (a) : (b)) + +constexpr int myConstexprMin(int a, int b) { + return a < b ? a : b; +} + +constexpr int myConstexprMax(int a, int b) { + return a > b ? a : b;

[llvm] [clang-tools-extra] [clang] Add clang-tidy check to suggest replacement of conditional statement with std::min/std::max (PR #77816)

2024-01-18 Thread Bhuminjay Soni via cfe-commits
@@ -0,0 +1,149 @@ +// RUN: %check_clang_tidy %s readability-use-std-min-max %t + +#define MY_MACRO_MIN(a, b) ((a) < (b) ? (a) : (b)) + +constexpr int myConstexprMin(int a, int b) { + return a < b ? a : b; +} + +constexpr int myConstexprMax(int a, int b) { + return a > b ? a : b;

[llvm] [clang-tools-extra] [clang] Add clang-tidy check to suggest replacement of conditional statement with std::min/std::max (PR #77816)

2024-01-18 Thread Bhuminjay Soni via cfe-commits
@@ -0,0 +1,149 @@ +// RUN: %check_clang_tidy %s readability-use-std-min-max %t + +#define MY_MACRO_MIN(a, b) ((a) < (b) ? (a) : (b)) + +constexpr int myConstexprMin(int a, int b) { + return a < b ? a : b; +} + +constexpr int myConstexprMax(int a, int b) { + return a > b ? a : b;

[llvm] [clang-tools-extra] [clang] Add clang-tidy check to suggest replacement of conditional statement with std::min/std::max (PR #77816)

2024-01-18 Thread Bhuminjay Soni via cfe-commits
https://github.com/11happy edited https://github.com/llvm/llvm-project/pull/77816 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [llvm] [clang] Add clang-tidy check to suggest replacement of conditional statement with std::min/std::max (PR #77816)

2024-01-18 Thread Bhuminjay Soni via cfe-commits
@@ -0,0 +1,149 @@ +// RUN: %check_clang_tidy %s readability-use-std-min-max %t + +#define MY_MACRO_MIN(a, b) ((a) < (b) ? (a) : (b)) + +constexpr int myConstexprMin(int a, int b) { + return a < b ? a : b; +} + +constexpr int myConstexprMax(int a, int b) { + return a > b ? a : b;

[llvm] [clang] [clang-tools-extra] Add clang-tidy check to suggest replacement of conditional statement with std::min/std::max (PR #77816)

2024-01-18 Thread Bhuminjay Soni via cfe-commits
11happy wrote: **Updates of Recent Commit:** - Incorporated all the naming and formatting suggestions by @5chmidti - Thanks @felix642 for such a great insight on testcases, actually those two you suggested were actually getting flagged when they shouldn't ,added changes so that they don't get

[llvm] [clang-tools-extra] [clang] Add clang-tidy check to suggest replacement of conditional statement with std::min/std::max (PR #77816)

2024-01-19 Thread Bhuminjay Soni via cfe-commits
11happy wrote: > I found some things that should be addressed. > > @PiotrZSL you had a comment about "improving readability and promoting the > use of standard library functions." in `ReleaseNotes.rst`, I just want to > mention that this sentence is also present in the header and check > docu

[clang-tools-extra] [clang] [llvm] Add clang-tidy check to suggest replacement of conditional statement with std::min/std::max (PR #77816)

2024-01-19 Thread Bhuminjay Soni via cfe-commits
11happy wrote: > > It currently handles this case: > > ``` > > if (value1 < value2) > > value = value2; > > else > > value = value1; > > ``` > > When I add > > ```c++ > if (value1 < value2) > value3 = value2; > else > value3 = value1; > ``` > > (just renamed `value` to `value3`

[clang] [llvm] [clang-tools-extra] Add clang-tidy check to suggest replacement of conditional statement with std::min/std::max (PR #77816)

2024-01-19 Thread Bhuminjay Soni via cfe-commits
11happy wrote: @5chmidti I have added all the requested changes. Thank you https://github.com/llvm/llvm-project/pull/77816 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang] [llvm] Add clang-tidy check to suggest replacement of conditional statement with std::min/std::max (PR #77816)

2024-01-20 Thread Bhuminjay Soni via cfe-commits
@@ -0,0 +1,139 @@ +//===--- UseStdMinMaxCheck.cpp - clang-tidy ---===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Ap

[clang-tools-extra] [clang] [llvm] Add clang-tidy check to suggest replacement of conditional statement with std::min/std::max (PR #77816)

2024-01-20 Thread Bhuminjay Soni via cfe-commits
11happy wrote: > Sorry for making this so iterative ^^ but I think that after these everything > is good from my side. No Problem! actually I am quite happy to contribute to the org and am able to learn something. https://github.com/llvm/llvm-project/pull/77816 ___

[clang-tools-extra] [clang] [llvm] Add clang-tidy check to suggest replacement of conditional statement with std::min/std::max (PR #77816)

2024-01-20 Thread Bhuminjay Soni via cfe-commits
11happy wrote: I did this only the ``` compoundStmt(statementCountIs(1), has(binaryOperator(...))) ``` error: ```LLVM/llvm-project/clang-tools-extra/test/clang-tidy/checkers/readability/use-std-min-max.cpp:148:19: error: CHECK-FIXES: expected string not found in input``` this one is failing in

[llvm] [clang-tools-extra] [clang] Add clang-tidy check to suggest replacement of conditional statement with std::min/std::max (PR #77816)

2024-01-20 Thread Bhuminjay Soni via cfe-commits
@@ -0,0 +1,139 @@ +//===--- UseStdMinMaxCheck.cpp - clang-tidy ---===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Ap

[llvm] [clang-tools-extra] [clang] Add clang-tidy check to suggest replacement of conditional statement with std::min/std::max (PR #77816)

2024-01-20 Thread Bhuminjay Soni via cfe-commits
@@ -0,0 +1,139 @@ +//===--- UseStdMinMaxCheck.cpp - clang-tidy ---===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Ap

[clang-tools-extra] [clang] [llvm] Add clang-tidy check to suggest replacement of conditional statement with std::min/std::max (PR #77816)

2024-01-20 Thread Bhuminjay Soni via cfe-commits
@@ -0,0 +1,175 @@ +// RUN: %check_clang_tidy %s readability-use-std-min-max %t + +#define MY_MACRO_MIN(a, b) ((a) < (b) ? (a) : (b)) + +constexpr int myConstexprMin(int a, int b) { + return a < b ? a : b; +} + +constexpr int myConstexprMax(int a, int b) { + return a > b ? a : b;

[clang-tools-extra] [clang] [llvm] Add clang-tidy check to suggest replacement of conditional statement with std::min/std::max (PR #77816)

2024-01-20 Thread Bhuminjay Soni via cfe-commits
@@ -0,0 +1,175 @@ +// RUN: %check_clang_tidy %s readability-use-std-min-max %t + +#define MY_MACRO_MIN(a, b) ((a) < (b) ? (a) : (b)) + +constexpr int myConstexprMin(int a, int b) { + return a < b ? a : b; +} + +constexpr int myConstexprMax(int a, int b) { + return a > b ? a : b;

[clang] [llvm] [clang-tools-extra] Add clang-tidy check to suggest replacement of conditional statement with std::min/std::max (PR #77816)

2024-01-21 Thread Bhuminjay Soni via cfe-commits
11happy wrote: > @11happy, regarding the statement count: The tests work when I add > `statementCountIs(1),` right after `compoundStmt(` -> > `compoundStmt(statementCountIs(1),`. I removed the binding of the compound > statement, `Compound` and the `Compoind->size() > 1` check. But the tests

[llvm] [clang] [clang-tools-extra] Add clang-tidy check to suggest replacement of conditional statement with std::min/std::max (PR #77816)

2024-01-21 Thread Bhuminjay Soni via cfe-commits
@@ -0,0 +1,175 @@ +// RUN: %check_clang_tidy %s readability-use-std-min-max %t + +#define MY_MACRO_MIN(a, b) ((a) < (b) ? (a) : (b)) + +constexpr int myConstexprMin(int a, int b) { + return a < b ? a : b; +} + +constexpr int myConstexprMax(int a, int b) { + return a > b ? a : b;

[llvm] [clang] [clang-tools-extra] Add clang-tidy check to suggest replacement of conditional statement with std::min/std::max (PR #77816)

2024-01-21 Thread Bhuminjay Soni via cfe-commits
https://github.com/11happy edited https://github.com/llvm/llvm-project/pull/77816 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang] [llvm] Add clang-tidy check to suggest replacement of conditional statement with std::min/std::max (PR #77816)

2024-01-23 Thread Bhuminjay Soni via cfe-commits
11happy wrote: > @11happy I've compiled your code to test it on llvm's project and clang-tidy > seems to sometimes crash. Would you be able to have a look before we merge > this PR ? > > ``` > PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ > and include the crash b

[clang] fix unnecessary warning when using bitand with boolean (PR #81976)

2024-02-16 Thread Bhuminjay Soni via cfe-commits
https://github.com/11happy created https://github.com/llvm/llvm-project/pull/81976 **Overview:** This pull request fixes #77601 where using the `bitand` operator with boolean operands should not trigger the warning, as it would indicate an intentional use of bitwise AND rather than a typo or e

[clang] fix unnecessary warning when using bitand with boolean operators (PR #81976)

2024-02-16 Thread Bhuminjay Soni via cfe-commits
https://github.com/11happy edited https://github.com/llvm/llvm-project/pull/81976 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Diagnose misuse of the cleanup attribute (PR #80040)

2024-02-19 Thread Bhuminjay Soni via cfe-commits
11happy wrote: what would be the reason for windows build failing , is it a CI issue or specific to this PR & what can I do to resolve that. Thank you https://github.com/llvm/llvm-project/pull/80040 ___ cfe-commits mailing list cfe-commits@lists.llvm.

[clang-tools-extra] Add clang-tidy check readability-math-missing-parentheses (PR #84481)

2024-04-08 Thread Bhuminjay Soni via cfe-commits
11happy wrote: Humble reminder! @PiotrZSL https://github.com/llvm/llvm-project/pull/84481 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Add new flag -Wpointer-integer-ordered-compare (PR #88489)

2024-04-12 Thread Bhuminjay Soni via cfe-commits
https://github.com/11happy created https://github.com/llvm/llvm-project/pull/88489 **Overview:** This pull request fixes #88090 where a false negative issue related to `-Wpointer-integer-compare` failing on comparison between a pointer and zero. **Testing:** - Tested the updated code. - Verifi

[clang] Add new flag -Wpointer-integer-ordered-compare (PR #88489)

2024-04-12 Thread Bhuminjay Soni via cfe-commits
https://github.com/11happy updated https://github.com/llvm/llvm-project/pull/88489 >From bc08f479ba483e1582304ca103dbd92481108f12 Mon Sep 17 00:00:00 2001 From: 11happy Date: Fri, 12 Apr 2024 14:56:42 +0530 Subject: [PATCH 1/2] add new flag -Wpointer-integer-ordered-compare Signed-off-by: 11ha

[clang-tools-extra] [clang-tidy] Ignore non-math operators in readability-math-missing-parentheses (PR #94654)

2024-06-08 Thread Bhuminjay Soni via cfe-commits
https://github.com/11happy approved this pull request. https://github.com/llvm/llvm-project/pull/94654 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Add new flag -Wpointer-integer-ordered-compare (PR #88489)

2024-04-18 Thread Bhuminjay Soni via cfe-commits
https://github.com/11happy updated https://github.com/llvm/llvm-project/pull/88489 >From bc08f479ba483e1582304ca103dbd92481108f12 Mon Sep 17 00:00:00 2001 From: 11happy Date: Fri, 12 Apr 2024 14:56:42 +0530 Subject: [PATCH 1/3] add new flag -Wpointer-integer-ordered-compare Signed-off-by: 11ha

[clang] Add new flag -Wpointer-integer-ordered-compare (PR #88489)

2024-04-18 Thread Bhuminjay Soni via cfe-commits
11happy wrote: Hello @vincent-mailhol thank you for the review I have made the suggested changed. https://github.com/llvm/llvm-project/pull/88489 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/

[clang] Add new flag -Wpointer-integer-ordered-compare (PR #88489)

2024-04-18 Thread Bhuminjay Soni via cfe-commits
11happy wrote: humble reminder @AaronBallman , @shafik https://github.com/llvm/llvm-project/pull/88489 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] Add clang-tidy check readability-math-missing-parentheses (PR #84481)

2024-04-18 Thread Bhuminjay Soni via cfe-commits
11happy wrote: Hello @PiotrZSL , I ran it on simple codebases & it looks good. I havent tried it on llvm codebase. it was taking a lot of time on my pc. https://github.com/llvm/llvm-project/pull/84481 ___ cfe-commits mailing list cfe-commits@lists.ll

[clang-tools-extra] Add clang-tidy check readability-math-missing-parentheses (PR #84481)

2024-04-18 Thread Bhuminjay Soni via cfe-commits
https://github.com/11happy updated https://github.com/llvm/llvm-project/pull/84481 >From 8fdf6306085ed4cf0f77b7e718e374e9f65fedf9 Mon Sep 17 00:00:00 2001 From: 11happy Date: Fri, 8 Mar 2024 19:02:47 +0530 Subject: [PATCH 01/12] add clang-tidy check readability-math-missing-parentheses Signed

[clang-tools-extra] Add clang-tidy check readability-math-missing-parentheses (PR #84481)

2024-04-18 Thread Bhuminjay Soni via cfe-commits
@@ -0,0 +1,97 @@ +//===--- MathMissingParenthesesCheck.cpp - clang-tidy -===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apa

[clang-tools-extra] Add clang-tidy check readability-math-missing-parentheses (PR #84481)

2024-04-18 Thread Bhuminjay Soni via cfe-commits
https://github.com/11happy updated https://github.com/llvm/llvm-project/pull/84481 >From 8fdf6306085ed4cf0f77b7e718e374e9f65fedf9 Mon Sep 17 00:00:00 2001 From: 11happy Date: Fri, 8 Mar 2024 19:02:47 +0530 Subject: [PATCH 01/13] add clang-tidy check readability-math-missing-parentheses Signed

[clang] Add new flag -Wpointer-integer-ordered-compare (PR #88489)

2024-04-18 Thread Bhuminjay Soni via cfe-commits
@@ -714,10 +714,11 @@ def HeaderHygiene : DiagGroup<"header-hygiene">; def DuplicateDeclSpecifier : DiagGroup<"duplicate-decl-specifier">; def CompareDistinctPointerType : DiagGroup<"compare-distinct-pointer-types">; def GNUUnionCast : DiagGroup<"gnu-union-cast">; +def PointerI

[clang] Add new flag -Wpointer-integer-ordered-compare (PR #88489)

2024-04-18 Thread Bhuminjay Soni via cfe-commits
@@ -245,6 +245,12 @@ Modified Compiler Flags f3 *c = (f3 *)x; } +- Added a new diagnostic flag ``-Wpointer-integer-ordered-compare`` which is + grouped under ``-Wpointer-integer-compare`` and moved previously + ungrouped diagnostics ``ext_typecheck_ordered_compa

[clang] Add new flag -Wpointer-integer-ordered-compare (PR #88489)

2024-04-18 Thread Bhuminjay Soni via cfe-commits
@@ -0,0 +1,30 @@ +// RUN: %clang_cc1 -Wno-pointer-integer-compare -Wpointer-integer-ordered-compare -fsyntax-only -verify=pointer-integer-ordered %s +// RUN: %clang_cc1 -Wpointer-integer-compare -Wno-pointer-integer-ordered-compare -fsyntax-only -verify=pointer-integer %s + +vo

[clang-tools-extra] Add clang-tidy check readability-math-missing-parentheses (PR #84481)

2024-04-23 Thread Bhuminjay Soni via cfe-commits
https://github.com/11happy updated https://github.com/llvm/llvm-project/pull/84481 >From 8fdf6306085ed4cf0f77b7e718e374e9f65fedf9 Mon Sep 17 00:00:00 2001 From: 11happy Date: Fri, 8 Mar 2024 19:02:47 +0530 Subject: [PATCH 01/14] add clang-tidy check readability-math-missing-parentheses Signed

[clang-tools-extra] Add clang-tidy check readability-math-missing-parentheses (PR #84481)

2024-04-23 Thread Bhuminjay Soni via cfe-commits
11happy wrote: hello @5chmidti I am sorry for my delayed response quite busy with my academic work last week, I have added this change ``` if (EndLoc.isInvalid()) return; ``` this works fine for those macros. Thank you https://github.com/llvm/llvm-project/pull/84481 ___

[clang] Add new flag -Wpointer-integer-ordered-compare (PR #88489)

2024-04-26 Thread Bhuminjay Soni via cfe-commits
11happy wrote: Humble ping! https://github.com/llvm/llvm-project/pull/88489 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy] fix false-negative for macros in `readability-math-missing-parentheses` (PR #90279)

2024-04-26 Thread Bhuminjay Soni via cfe-commits
https://github.com/11happy approved this pull request. LGTM. Thank you for CCing me. https://github.com/llvm/llvm-project/pull/90279 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

<    1   2   3