[clang-tools-extra] [clang-tidy] Support find for string-like classes in readability-container-contains (PR #157243)

2025-09-11 Thread Victor Chernyakin via cfe-commits
@@ -318,17 +321,15 @@ void testPrivateContains(CustomMapPrivateContains &MyMap, if (MyMap2.count(0)) {}; } -struct MyString {}; - struct WeirdNonMatchingContains { unsigned count(char) const; - bool contains(const MyString&) const; + bool contains(const std::string&) c

[clang-tools-extra] [clang-tidy] Support find for string-like classes in readability-container-contains (PR #157243)

2025-09-11 Thread Victor Chernyakin via cfe-commits
@@ -458,3 +454,41 @@ void testOperandPermutations(std::map& Map) { // CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: use 'contains' to check for membership [readability-container-contains] // CHECK-FIXES: if (!Map.contains(0)) {}; } + +void testStringNpos(std::string St

[clang-tools-extra] [clang-tidy] Support find for string-like classes in readability-container-contains (PR #157243)

2025-09-08 Thread Victor Chernyakin via cfe-commits
@@ -1,4 +1,7 @@ -// RUN: %check_clang_tidy -std=c++11-or-later %s readability-container-contains %t +// RUN: %check_clang_tidy -std=c++11-or-later %s readability-container-contains %t -- \ localspook wrote: ```suggestion // RUN: %check_clang_tidy %s readability

[clang-tools-extra] [clang-tidy][NFC] Do less unnecessary work in `NoLintDirectiveHandler` (PR #147553)

2025-09-08 Thread Victor Chernyakin via cfe-commits
https://github.com/localspook closed https://github.com/llvm/llvm-project/pull/147553 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy] make `misc-const-correctness` work with `auto` variables and lambdas (PR #157319)

2025-09-07 Thread Victor Chernyakin via cfe-commits
localspook wrote: Re: adding it under an option I'm struggling to imagine a user that wants this change: ```diff - int i = 10; + int const i = 10; ``` but *doesn't* want this change: ```diff - auto i = 10; + auto const i = 10; ``` The way I see it, this PR is more of a bugfix rather than a new f

[clang-tools-extra] [clang-tidy] make `misc-const-correctness` work with `auto` variables and lambdas (PR #157319)

2025-09-07 Thread Victor Chernyakin via cfe-commits
https://github.com/localspook updated https://github.com/llvm/llvm-project/pull/157319 >From e28e9e234b6165b49884cf254e1fb4efe44fe756 Mon Sep 17 00:00:00 2001 From: Victor Chernyakin Date: Sat, 6 Sep 2025 17:35:36 -0700 Subject: [PATCH 1/3] [clang-tidy] make `misc-const-correctness` work with

[clang-tools-extra] [clang-tidy] make `misc-const-correctness` work with `auto` variables and lambdas (PR #157319)

2025-09-07 Thread Victor Chernyakin via cfe-commits
localspook wrote: > I notice now there's no update in Release Notes for this. There is though; did you maybe mean documentation? https://github.com/llvm/llvm-project/pull/157319 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.ll

[clang-tools-extra] [clang-tidy] make `misc-const-correctness` work with `auto` variables and lambdas (PR #157319)

2025-09-07 Thread Victor Chernyakin via cfe-commits
@@ -10,6 +10,12 @@ template void type_dependent_variables() { T value = 42; auto &ref = value; + // CHECK-MESSAGES:[[@LINE-1]]:3: warning: variable 'ref' of type 'int &' can be declared 'const' + // CHECK-FIXES: auto const&ref = value; + // + // FIXME: This is a fals

[clang-tools-extra] [clang-tidy] make `misc-const-correctness` work with `auto` variables and lambdas (PR #157319)

2025-09-07 Thread Victor Chernyakin via cfe-commits
https://github.com/localspook updated https://github.com/llvm/llvm-project/pull/157319 >From e28e9e234b6165b49884cf254e1fb4efe44fe756 Mon Sep 17 00:00:00 2001 From: Victor Chernyakin Date: Sat, 6 Sep 2025 17:35:36 -0700 Subject: [PATCH 1/2] [clang-tidy] make `misc-const-correctness` work with

[clang-tools-extra] [clang-tidy] make `misc-const-correctness` work with `auto` variables and lambdas (PR #157319)

2025-09-07 Thread Victor Chernyakin via cfe-commits
@@ -10,6 +10,12 @@ template void type_dependent_variables() { T value = 42; auto &ref = value; + // CHECK-MESSAGES:[[@LINE-1]]:3: warning: variable 'ref' of type 'int &' can be declared 'const' + // CHECK-FIXES: auto const&ref = value; localspook wrote

[clang-tools-extra] [clang-tidy] make `misc-const-correctness` work with `auto` variables and lambdas (PR #157319)

2025-09-06 Thread Victor Chernyakin via cfe-commits
@@ -185,6 +185,10 @@ Changes in existing checks adding an option to allow pointer arithmetic via prefix/postfix increment or decrement operators. +- Improved :doc:`misc-const-correctness + ` check to diagnose + variables declared with ``auto``. localspoo

[clang-tools-extra] [clang-tidy] make `misc-const-correctness` work with `auto` variables and lambdas (PR #157319)

2025-09-06 Thread Victor Chernyakin via cfe-commits
https://github.com/localspook created https://github.com/llvm/llvm-project/pull/157319 Fixes #60789. Currently, the check will never make `auto` variables `const`. Here's the relevant bit of code: https://github.com/llvm/llvm-project/blob/6b200e21adec0e28407def6fcb2e6c7359fd881b/clang-tools-e

[clang-tools-extra] [clang-tidy][NFC] Do less unnecessary work in `NoLintDirectiveHandler` (PR #147553)

2025-09-04 Thread Victor Chernyakin via cfe-commits
@@ -31,8 +31,6 @@ class NoLintDirectiveHandler { public: NoLintDirectiveHandler(); ~NoLintDirectiveHandler(); localspook wrote: This check does backflips to keep the definition of `Impl` out of the header, and this is one of those backflips. The destructo

[clang-tools-extra] [clang-tidy][NFC] Enable `readability-convert-member-functions-to-static` in the codebase (PR #156265)

2025-09-04 Thread Victor Chernyakin via cfe-commits
localspook wrote: Tell me if I’m understanding correctly: Your concern is with the API of a class. That means you’re concerned about changes to `public` and `protected` methods, but okay with changes to `private` ones? https://github.com/llvm/llvm-project/pull/156265 _

[clang-tools-extra] [clang-tidy] Raise minimum standard level for several checks from C++98 to C++11 (PR #152401)

2025-09-04 Thread Victor Chernyakin via cfe-commits
https://github.com/localspook closed https://github.com/llvm/llvm-project/pull/152401 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-tools-extra] [clang-tidy] Do not crash when an empty directory is used in the comp… (PR #156873)

2025-09-04 Thread Victor Chernyakin via cfe-commits
@@ -574,22 +574,30 @@ int ClangTool::run(ToolAction *Action) { continue; } for (CompileCommand &CompileCommand : CompileCommandsForFile) { + // If the 'directory' field of the compilation database is empty, display + // an error and use the working direc

[clang-tools-extra] [clang-tidy] Add new '-hide-progress' option to tidy-scripts for suppressing progress information (PR #154416)

2025-09-03 Thread Victor Chernyakin via cfe-commits
@@ -122,6 +122,10 @@ Improvements to clang-tidy - Improved :program:`clang-tidy` option `-quiet` by suppressing diagnostic count messages. +- Improved :program:`run-clang-tidy.py` and :program:`clang-tidy-diff.py` + scripts by adding the `-hide-progress` option to suppress

[clang-tools-extra] [clang-tidy] Fix `readability-uppercase-literal-suffix` warning with hex literals (PR #156584)

2025-09-03 Thread Victor Chernyakin via cfe-commits
https://github.com/localspook closed https://github.com/llvm/llvm-project/pull/156584 ___ 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 `readability-uppercase-literal-suffix` warning with hex literals (PR #156584)

2025-09-03 Thread Victor Chernyakin via cfe-commits
localspook wrote: Because of the new `wb` suffix. I should’ve just added `wW` https://github.com/llvm/llvm-project/pull/156584 ___ 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 `readability-uppercase-literal-suffix` warning with hex literals (PR #156584)

2025-09-03 Thread Victor Chernyakin via cfe-commits
https://github.com/localspook created https://github.com/llvm/llvm-project/pull/156584 This is a regression I introduced in #148275 and was [noticed by](https://github.com/llvm/llvm-project/pull/148275#issuecomment-3246670841) @nettle. The check incorrectly fires on hex literals containing the

[clang-tools-extra] [clang-tidy] Teach `readability-uppercase-literal-suffix` about C++23 and C23 suffixes (PR #148275)

2025-09-02 Thread Victor Chernyakin via cfe-commits
localspook wrote: Good catch, thank you! Opened #156584 with a fix. https://github.com/llvm/llvm-project/pull/148275 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy] Teach `readability-uppercase-literal-suffix` about C++23 and C23 suffixes (PR #148275)

2025-09-02 Thread Victor Chernyakin via cfe-commits
localspook wrote: That CI failure looks unrelated. https://github.com/llvm/llvm-project/pull/148275 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy][NFC] Enable `readability-convert-member-functions-to-static` in the codebase (PR #156265)

2025-08-31 Thread Victor Chernyakin via cfe-commits
https://github.com/localspook updated https://github.com/llvm/llvm-project/pull/156265 >From c368372b8cc915a401a5dcbf6346e23a101f95e4 Mon Sep 17 00:00:00 2001 From: Victor Chernyakin Date: Sun, 31 Aug 2025 17:18:42 -0700 Subject: [PATCH 1/2] [clang-tidy][NFC] Enable `readability-convert-member

[clang-tools-extra] [clang-tidy][NFC] Enable `readability-convert-member-functions-to-static` in the codebase (PR #156265)

2025-08-31 Thread Victor Chernyakin via cfe-commits
https://github.com/localspook created https://github.com/llvm/llvm-project/pull/156265 Closes #156158. Ironically, one warning found in `ConvertMemberFunctionsToStatic.cpp` >From c368372b8cc915a401a5dcbf6346e23a101f95e4 Mon Sep 17 00:00:00 2001 From: Victor Chernyakin Date: Sun, 31 Aug 2025 1

[clang-tools-extra] [clang-tidy] Teach `readability-uppercase-literal-suffix` about C++23 and C23 suffixes (PR #148275)

2025-08-31 Thread Victor Chernyakin via cfe-commits
https://github.com/localspook closed https://github.com/llvm/llvm-project/pull/148275 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy] add option to `readability-use-concise-preprocessor-directives` to take consistency into account (PR #156220)

2025-08-30 Thread Victor Chernyakin via cfe-commits
https://github.com/localspook edited https://github.com/llvm/llvm-project/pull/156220 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy] add option to `readability-use-concise-preprocessor-directives` to take consistency into account (PR #156220)

2025-08-30 Thread Victor Chernyakin via cfe-commits
https://github.com/localspook created https://github.com/llvm/llvm-project/pull/156220 Fixes #155680. See that issue for context. The precise heuristic this PR implements is this: *none of the conditions in a chain will be shortened if any of them contains the `defined` operator but cannot be

[clang-tools-extra] [clang-tidy] New bugprone-derived-method-shadowing-base-method (PR #154746)

2025-08-29 Thread Victor Chernyakin via cfe-commits
@@ -0,0 +1,132 @@ +//===--===// +// +// 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] [clang-tidy] New bugprone-derived-method-shadowing-base-method (PR #154746)

2025-08-29 Thread Victor Chernyakin via cfe-commits
@@ -0,0 +1,127 @@ +//===--===// +// +// 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] [clang-tidy] New bugprone-derived-method-shadowing-base-method (PR #154746)

2025-08-29 Thread Victor Chernyakin via cfe-commits
@@ -153,6 +154,8 @@ class BugproneModule : public ClangTidyModule { "bugprone-incorrect-enable-if"); CheckFactories.registerCheck( "bugprone-incorrect-enable-shared-from-this"); +CheckFactories.registerCheck( +"bugprone-derived-method-shadowing-b

[clang-tools-extra] [clang-tidy] New bugprone-derived-method-shadowing-base-method (PR #154746)

2025-08-29 Thread Victor Chernyakin via cfe-commits
@@ -0,0 +1,127 @@ +//===--===// +// +// 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] [clang-tidy] New bugprone-derived-method-shadowing-base-method (PR #154746)

2025-08-29 Thread Victor Chernyakin via cfe-commits
@@ -0,0 +1,127 @@ +//===--===// +// +// 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] [clang-tidy] New bugprone-derived-method-shadowing-base-method (PR #154746)

2025-08-29 Thread Victor Chernyakin via cfe-commits
@@ -31,6 +31,7 @@ add_clang_library(clangTidyBugproneModule STATIC IncorrectEnableIfCheck.cpp IncorrectEnableSharedFromThisCheck.cpp InvalidEnumDefaultInitializationCheck.cpp + DerivedMethodShadowingBaseMethodCheck.cpp localspook wrote: Ditto alphabetic

[clang-tools-extra] [clang-tidy] New bugprone-derived-method-shadowing-base-method (PR #154746)

2025-08-29 Thread Victor Chernyakin via cfe-commits
@@ -0,0 +1,127 @@ +//===--===// +// +// 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] [clang-tidy] Teach `readability-uppercase-literal-suffix` about C++23 and C23 suffixes (PR #148275)

2025-08-26 Thread Victor Chernyakin via cfe-commits
@@ -0,0 +1,162 @@ +// TODO: When Clang adds support for decimal floating point types, enable these tests by: +//1. Removing all the #if 0 + #endif guards. +//2. Removing all occurrences of the string "DISABLED-" in this file. +//3. Deleting this message. + +// RUN: %c

[clang-tools-extra] [clang-tidy] Teach `readability-uppercase-literal-suffix` about C++23 and C23 suffixes (PR #148275)

2025-08-26 Thread Victor Chernyakin via cfe-commits
https://github.com/localspook edited https://github.com/llvm/llvm-project/pull/148275 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy] Teach `readability-uppercase-literal-suffix` about C++23 and C23 suffixes (PR #148275)

2025-08-26 Thread Victor Chernyakin via cfe-commits
@@ -0,0 +1,162 @@ +// TODO: When Clang adds support for decimal floating point types, enable these tests by: +//1. Removing all the #if 0 + #endif guards. +//2. Removing all occurrences of the string "DISABLED-" in this file. +//3. Deleting this message. + +// RUN: %c

[clang-tools-extra] [clang-tidy] Teach `readability-uppercase-literal-suffix` about C++23 and C23 suffixes (PR #148275)

2025-08-26 Thread Victor Chernyakin via cfe-commits
https://github.com/localspook edited https://github.com/llvm/llvm-project/pull/148275 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy] Teach `readability-uppercase-literal-suffix` about C++23 and C23 suffixes (PR #148275)

2025-08-26 Thread Victor Chernyakin via cfe-commits
@@ -0,0 +1,162 @@ +// TODO: When Clang adds support for decimal floating point types, enable these tests by: +//1. Removing all the #if 0 + #endif guards. +//2. Removing all occurrences of the string "DISABLED-" in this file. +//3. Deleting this message. + +// RUN: %c

[clang-tools-extra] [clang-tidy] Teach `readability-uppercase-literal-suffix` about C++23 and C23 suffixes (PR #148275)

2025-08-25 Thread Victor Chernyakin via cfe-commits
https://github.com/localspook edited https://github.com/llvm/llvm-project/pull/148275 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy] Teach `readability-uppercase-literal-suffix` about C++23 and C23 suffixes (PR #148275)

2025-08-25 Thread Victor Chernyakin via cfe-commits
https://github.com/localspook edited https://github.com/llvm/llvm-project/pull/148275 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy] Teach `readability-uppercase-literal-suffix` about C++23 and C23 suffixes (PR #148275)

2025-08-25 Thread Victor Chernyakin via cfe-commits
https://github.com/localspook updated https://github.com/llvm/llvm-project/pull/148275 >From b19ad9cda58288d727861bdd0a9d2a7cedc7c1a6 Mon Sep 17 00:00:00 2001 From: Victor Chernyakin Date: Fri, 11 Jul 2025 11:35:50 -0700 Subject: [PATCH 1/6] [clang-tidy] Teach `readability-uppercase-literal-suf

[clang-tools-extra] [clang-tidy] Teach `readability-uppercase-literal-suffix` about C++23 and C23 suffixes (PR #148275)

2025-08-25 Thread Victor Chernyakin via cfe-commits
@@ -0,0 +1,248 @@ +// TODO: When Clang adds support for C++23 floating-point types, enable these tests by: +//1. Removing all the #if 0 + #endif guards. +//2. Removing all occurrences of the string "DISABLED-" in this file. +//3. Deleting this message. +// These suffi

[clang-tools-extra] [clang-tidy] Teach `readability-uppercase-literal-suffix` about C++23 and C23 suffixes (PR #148275)

2025-08-25 Thread Victor Chernyakin via cfe-commits
@@ -0,0 +1,248 @@ +// TODO: When Clang adds support for C++23 floating-point types, enable these tests by: +//1. Removing all the #if 0 + #endif guards. +//2. Removing all occurrences of the string "DISABLED-" in this file. +//3. Deleting this message. +// These suffi

[clang-tools-extra] [clang-tidy] Teach `readability-uppercase-literal-suffix` about C++23 and C23 suffixes (PR #148275)

2025-08-25 Thread Victor Chernyakin via cfe-commits
https://github.com/localspook updated https://github.com/llvm/llvm-project/pull/148275 >From b19ad9cda58288d727861bdd0a9d2a7cedc7c1a6 Mon Sep 17 00:00:00 2001 From: Victor Chernyakin Date: Fri, 11 Jul 2025 11:35:50 -0700 Subject: [PATCH 1/5] [clang-tidy] Teach `readability-uppercase-literal-suf

[clang-tools-extra] [clang-tidy][NFC] clean up some matchers in `modernize-type-traits` (PR #155180)

2025-08-24 Thread Victor Chernyakin via cfe-commits
https://github.com/localspook closed https://github.com/llvm/llvm-project/pull/155180 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy][NFC] clean up some matchers in `modernize-type-traits` (PR #155180)

2025-08-24 Thread Victor Chernyakin via cfe-commits
https://github.com/localspook created https://github.com/llvm/llvm-project/pull/155180 `dependentNameTypeLoc` is unused. `dependentScopeDeclRefExpr` has appeared in `ASTMatchers.h` since this code was written. >From d4e27d738a71c1a9b0f2b699f41e74b3a8a41366 Mon Sep 17 00:00:00 2001 From: Victor

[clang-tools-extra] [clang-tidy] Mark bunch of checks as C++-only (PR #155083)

2025-08-23 Thread Victor Chernyakin via cfe-commits
https://github.com/localspook closed https://github.com/llvm/llvm-project/pull/155083 ___ 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 `modernize-use-constraints` crash on uses of nonstandard `enable_if`s (PR #152938)

2025-08-23 Thread Victor Chernyakin via cfe-commits
https://github.com/localspook closed https://github.com/llvm/llvm-project/pull/152938 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy] Add `-std` argument in `check_clang_tidy.py` for C files (PR #150791)

2025-08-23 Thread Victor Chernyakin via cfe-commits
https://github.com/localspook closed https://github.com/llvm/llvm-project/pull/150791 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy] Add `-std` argument in `check_clang_tidy.py` for C files (PR #150791)

2025-08-23 Thread Victor Chernyakin via cfe-commits
https://github.com/localspook edited https://github.com/llvm/llvm-project/pull/150791 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy] Mark bunch of checks as C++-only (PR #155083)

2025-08-23 Thread Victor Chernyakin via cfe-commits
https://github.com/localspook created https://github.com/llvm/llvm-project/pull/155083 Hope I got them all... >From 2e397d72b35e85d80da270f5509b9d2278770307 Mon Sep 17 00:00:00 2001 From: Victor Chernyakin Date: Sat, 23 Aug 2025 01:54:21 -0700 Subject: [PATCH] [clang-tidy] Mark bunch of checks

[clang-tools-extra] [clang-tidy] Ignore default ctor with user provided argument in `readability-container-size-empty` (PR #154782)

2025-08-22 Thread Victor Chernyakin via cfe-commits
@@ -190,7 +190,7 @@ void ContainerSizeEmptyCheck::registerMatchers(MatchFinder *Finder) { const auto WrongComparend = anyOf(stringLiteral(hasSize(0)), userDefinedLiteral(hasLiteral(stringLiteral(hasSize(0, -cxxConstructExpr(isDefaultConstruc

[clang-tools-extra] [clang-tidy] Add `-std` argument in `check_clang_tidy.py` for C files (PR #150791)

2025-08-20 Thread Victor Chernyakin via cfe-commits
https://github.com/localspook updated https://github.com/llvm/llvm-project/pull/150791 >From 20eb165f1abd9bf7976a2c401579a1284258e13e Mon Sep 17 00:00:00 2001 From: Victor Chernyakin Date: Sat, 26 Jul 2025 11:52:19 -0700 Subject: [PATCH 1/6] [clang-tidy] Stop ignoring `-std` argument in `check

[clang-tools-extra] [clang-tidy] Add `-std` argument in `check_clang_tidy.py` for C files (PR #150791)

2025-08-20 Thread Victor Chernyakin via cfe-commits
@@ -374,15 +373,23 @@ def parse_arguments() -> Tuple[argparse.Namespace, List[str]]: parser.add_argument( "-std", type=csv, -default=["c++11-or-later"], +default=None, help="Passed to clang. Special -or-later values are expanded.",

[clang-tools-extra] [clang-tidy] Add `-std` argument in `check_clang_tidy.py` for C files (PR #150791)

2025-08-18 Thread Victor Chernyakin via cfe-commits
https://github.com/localspook updated https://github.com/llvm/llvm-project/pull/150791 >From 20eb165f1abd9bf7976a2c401579a1284258e13e Mon Sep 17 00:00:00 2001 From: Victor Chernyakin Date: Sat, 26 Jul 2025 11:52:19 -0700 Subject: [PATCH 1/5] [clang-tidy] Stop ignoring `-std` argument in `check

[clang] [clang][Sema] Diagnose passing function pointer to `__builtin_assume_aligned` (PR #153552)

2025-08-14 Thread Victor Chernyakin via cfe-commits
@@ -1,9 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -Wno-int-conversion -triple x86_64-linux -verify %s localspook wrote: The pointer is now always converted to `const void *`, so we no longer need to disallow these integer conversions. https://github.com/llvm/l

[clang] [clang][Sema] Diagnose passing function pointer to `__builtin_assume_aligned` (PR #153552)

2025-08-14 Thread Victor Chernyakin via cfe-commits
localspook wrote: I've switched to `checkBuiltinArgument`, but it causes an issue that I'd like input on before I continue. `clang/test/CodeGen/catch-alignment-assumption-ignorelist.c` tests that UBSan doesn't validate the alignment of pointers to volatile. With this change, the `volatile`-ne

[clang] [clang][Sema] Diagnose passing function pointer to `__builtin_assume_aligned` (PR #153552)

2025-08-14 Thread Victor Chernyakin via cfe-commits
https://github.com/localspook updated https://github.com/llvm/llvm-project/pull/153552 >From 63c02556bc65571a84e27debde2e2cfd724a0e9b Mon Sep 17 00:00:00 2001 From: Victor Chernyakin Date: Thu, 14 Aug 2025 00:52:37 -0700 Subject: [PATCH 1/2] [clang][Sema] Diagnose passing function pointer to `

[clang] [clang][Sema] Diagnose passing function pointer to `__builtin_assume_aligned` (PR #153552)

2025-08-14 Thread Victor Chernyakin via cfe-commits
https://github.com/localspook created https://github.com/llvm/llvm-project/pull/153552 The first parameter of the builtin is `const void *`, and function pointers aren't convertible to that. [GCC diagnoses this](https://godbolt.org/z/67njxGE61). >From 63c02556bc65571a84e27debde2e2cfd724a0e9b

[clang-tools-extra] [clang-tidy] Fix `modernize-use-constraints` crash on uses of nonstandard `enable_if`s (PR #152938)

2025-08-11 Thread Victor Chernyakin via cfe-commits
@@ -78,6 +79,15 @@ matchEnableIfSpecializationImplTypename(TypeLoc TheType) { if (!TD || TD->getName() != "enable_if") return std::nullopt; +const TemplateParameterList *Params = TD->getTemplateParameters(); +if (Params->size() != 2) + return std::nullop

[clang-tools-extra] [clang-tidy] Fix `modernize-use-constraints` crash on uses of nonstandard `enable_if`s (PR #152938)

2025-08-11 Thread Victor Chernyakin via cfe-commits
https://github.com/localspook updated https://github.com/llvm/llvm-project/pull/152938 >From 728fc710260d529a604bf3692b18c9131061e070 Mon Sep 17 00:00:00 2001 From: Victor Chernyakin Date: Sun, 10 Aug 2025 12:25:26 -0700 Subject: [PATCH 1/4] [clang-tidy] Fix `modernize-use-constraints` crash on

[clang-tools-extra] [clang-tidy] performance-unnecessary-copy-initialization: Enhance the check for the scenario with MemberExpr initialization. (PR #151936)

2025-08-10 Thread Victor Chernyakin via cfe-commits
https://github.com/localspook edited https://github.com/llvm/llvm-project/pull/151936 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy] performance-unnecessary-copy-initialization: Enhance the check for the scenario with MemberExpr initialization. (PR #151936)

2025-08-10 Thread Victor Chernyakin via cfe-commits
@@ -371,6 +392,21 @@ void UnnecessaryCopyInitialization::diagnoseCopyFromLocalVar( maybeIssueFixes(Ctx, Diagnostic); } +void UnnecessaryCopyInitialization::diagnoseCopyFromConstVarMember( +const CheckContext &Ctx, const VarDecl &OldVar, const MemberExpr &ME) { + std::s

[clang-tools-extra] [clang-tidy] Fix `modernize-use-constraints` crash on uses of nonstandard `enable_if`s (PR #152938)

2025-08-10 Thread Victor Chernyakin via cfe-commits
localspook wrote: Latest commit fixes `enable_if_t`, it also causes this crash https://github.com/llvm/llvm-project/pull/152938 ___ 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 `modernize-use-constraints` crash on uses of nonstandard `enable_if`s (PR #152938)

2025-08-10 Thread Victor Chernyakin via cfe-commits
@@ -78,6 +79,15 @@ matchEnableIfSpecializationImplTypename(TypeLoc TheType) { if (!TD || TD->getName() != "enable_if") return std::nullopt; +const TemplateParameterList *Params = TD->getTemplateParameters(); +if (Params->size() != 2) + return std::nullop

[clang-tools-extra] [clang-tidy] Fix `modernize-use-constraints` crash on uses of nonstandard `enable_if`s (PR #152938)

2025-08-10 Thread Victor Chernyakin via cfe-commits
https://github.com/localspook updated https://github.com/llvm/llvm-project/pull/152938 >From 728fc710260d529a604bf3692b18c9131061e070 Mon Sep 17 00:00:00 2001 From: Victor Chernyakin Date: Sun, 10 Aug 2025 12:25:26 -0700 Subject: [PATCH 1/3] [clang-tidy] Fix `modernize-use-constraints` crash on

[clang-tools-extra] [clang-tidy] Fix `modernize-use-constraints` crash on uses of nonstandard `enable_if`s (PR #152938)

2025-08-10 Thread Victor Chernyakin via cfe-commits
https://github.com/localspook updated https://github.com/llvm/llvm-project/pull/152938 >From 728fc710260d529a604bf3692b18c9131061e070 Mon Sep 17 00:00:00 2001 From: Victor Chernyakin Date: Sun, 10 Aug 2025 12:25:26 -0700 Subject: [PATCH 1/2] [clang-tidy] Fix `modernize-use-constraints` crash on

[clang-tools-extra] [clang-tidy] Fix `modernize-use-constraints` crash on uses of nonstandard `enable_if`s (PR #152938)

2025-08-10 Thread Victor Chernyakin via cfe-commits
@@ -78,6 +79,15 @@ matchEnableIfSpecializationImplTypename(TypeLoc TheType) { if (!TD || TD->getName() != "enable_if") return std::nullopt; +const TemplateParameterList *Params = TD->getTemplateParameters(); +if (Params->size() != 2) + return std::nullop

[clang-tools-extra] [clang-tidy] Fix `modernize-use-constraints` crash on uses of nonstandard `enable_if`s (PR #152938)

2025-08-10 Thread Victor Chernyakin via cfe-commits
https://github.com/localspook edited https://github.com/llvm/llvm-project/pull/152938 ___ 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 `modernize-use-constraints` crash on uses of nonstandard `enable_if`s (PR #152938)

2025-08-10 Thread Victor Chernyakin via cfe-commits
https://github.com/localspook created https://github.com/llvm/llvm-project/pull/152938 Fixes #152868. See that issue for details. >From 728fc710260d529a604bf3692b18c9131061e070 Mon Sep 17 00:00:00 2001 From: Victor Chernyakin Date: Sun, 10 Aug 2025 12:25:26 -0700 Subject: [PATCH] [clang-tidy]

[clang-tools-extra] [clang-tidy] Raise minimum standard level for several checks from C++98 to C++11 (PR #152401)

2025-08-08 Thread Victor Chernyakin via cfe-commits
https://github.com/localspook updated https://github.com/llvm/llvm-project/pull/152401 >From f09e05a1aee29d94e908c3ef73d422bad65a3b34 Mon Sep 17 00:00:00 2001 From: Victor Chernyakin Date: Wed, 6 Aug 2025 15:31:55 -0700 Subject: [PATCH 1/5] [clang-tidy] Raise minimum standard level for several

[clang-tools-extra] [clang-tidy] Raise minimum standard level for several checks from C++98 to C++11 (PR #152401)

2025-08-08 Thread Victor Chernyakin via cfe-commits
https://github.com/localspook edited https://github.com/llvm/llvm-project/pull/152401 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy] Raise minimum standard level for several checks from C++98 to C++11 (PR #152401)

2025-08-08 Thread Victor Chernyakin via cfe-commits
https://github.com/localspook edited https://github.com/llvm/llvm-project/pull/152401 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy] Raise minimum standard level for several checks from C++98 to C++11 (PR #152401)

2025-08-08 Thread Victor Chernyakin via cfe-commits
https://github.com/localspook edited https://github.com/llvm/llvm-project/pull/152401 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy] Raise minimum standard level for several checks from C++98 to C++11 (PR #152401)

2025-08-08 Thread Victor Chernyakin via cfe-commits
localspook wrote: `-fno-delayed-template-parsing` did the trick for some tests! And it was a good hint that helped me figure out why the others were inconsistent: `-fms-extensions` apparently enables C++98-style int-to-pointer conversions in higher language versions, which affects the generate

[clang-tools-extra] [clang-tidy] Raise minimum standard level for several checks from C++98 to C++11 (PR #152401)

2025-08-08 Thread Victor Chernyakin via cfe-commits
https://github.com/localspook updated https://github.com/llvm/llvm-project/pull/152401 >From f09e05a1aee29d94e908c3ef73d422bad65a3b34 Mon Sep 17 00:00:00 2001 From: Victor Chernyakin Date: Wed, 6 Aug 2025 15:31:55 -0700 Subject: [PATCH 1/4] [clang-tidy] Raise minimum standard level for several

[clang-tools-extra] [clang-tidy] performance-unnecessary-copy-initialization: Enhance the check for the scenario with MemberExpr initialization. (PR #151936)

2025-08-07 Thread Victor Chernyakin via cfe-commits
https://github.com/localspook edited https://github.com/llvm/llvm-project/pull/151936 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy] performance-unnecessary-copy-initialization: Enhance the check for the scenario with MemberExpr initialization. (PR #151936)

2025-08-07 Thread Victor Chernyakin via cfe-commits
@@ -371,6 +392,21 @@ void UnnecessaryCopyInitialization::diagnoseCopyFromLocalVar( maybeIssueFixes(Ctx, Diagnostic); } +void UnnecessaryCopyInitialization::diagnoseCopyFromConstVarMember( +const CheckContext &Ctx, const VarDecl &OldVar, const MemberExpr &ME) { + std::s

[clang-tools-extra] [clang-tidy] performance-unnecessary-copy-initialization: Enhance the check for the scenario with MemberExpr initialization. (PR #151936)

2025-08-07 Thread Victor Chernyakin via cfe-commits
@@ -938,3 +938,59 @@ template bool OperatorWithNoDirectCallee(T t) { ExpensiveToCopyType a2 = a1; return a1 == t; } + +bool CopiedFromParmVarField(const Struct &crs, const Struct cs, Struct &rs, Struct s) { + const auto m1 = crs.Member; + // CHECK-MESSAGES: [[@LINE-1]]:1

[clang-tools-extra] [clang-tidy] performance-unnecessary-copy-initialization: Enhance the check for the scenario with MemberExpr initialization. (PR #151936)

2025-08-07 Thread Victor Chernyakin via cfe-commits
localspook wrote: All my comments above this message are resolved, but it seems I can't *mark* them resolved (because I don't have commit permissions, I think?). Could someone else resolve them for me? https://github.com/llvm/llvm-project/pull/151936 ___

[clang-tools-extra] [clang-tidy] Raise minimum standard level for several checks from C++98 to C++11 (PR #152401)

2025-08-06 Thread Victor Chernyakin via cfe-commits
https://github.com/localspook edited https://github.com/llvm/llvm-project/pull/152401 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy] Raise minimum standard level for several checks from C++98 to C++11 (PR #152401)

2025-08-06 Thread Victor Chernyakin via cfe-commits
https://github.com/localspook updated https://github.com/llvm/llvm-project/pull/152401 >From f09e05a1aee29d94e908c3ef73d422bad65a3b34 Mon Sep 17 00:00:00 2001 From: Victor Chernyakin Date: Wed, 6 Aug 2025 15:31:55 -0700 Subject: [PATCH 1/3] [clang-tidy] Raise minimum standard level for several

[clang-tools-extra] [clang-tidy] Raise minimum standard level for several checks from C++98 to C++11 (PR #152401)

2025-08-06 Thread Victor Chernyakin via cfe-commits
https://github.com/localspook created https://github.com/llvm/llvm-project/pull/152401 `modernize-replace-auto-ptr`, `modernize-use-equals-delete`, and `modernize-use-auto` use `std::unique_ptr`, `= delete`, and `auto` respectively, which are all C++11 features. The interesting bit is `modern

[clang-tools-extra] [clang-tidy] performance-unnecessary-copy-initialization: Enhance the check for the scenario with MemberExpr initialization. (PR #151936)

2025-08-05 Thread Victor Chernyakin via cfe-commits
@@ -369,6 +387,18 @@ void UnnecessaryCopyInitialization::diagnoseCopyFromLocalVar( maybeIssueFixes(Ctx, Diagnostic); } +void UnnecessaryCopyInitialization::diagnoseCopyFromConstLocalVarMember( +const CheckContext &Ctx, const VarDecl &OldVar) { + auto Diagnostic = +

[clang-tools-extra] [clang-tidy] performance-unnecessary-copy-initialization: Enhance the check for the scenario with MemberExpr initialization. (PR #151936)

2025-08-05 Thread Victor Chernyakin via cfe-commits
@@ -170,6 +170,11 @@ Changes in existing checks when the format string is converted to a different type by an implicit constructor call. +- Improved :doc:`performance-unnecessary-copy-initialization + ` check by + adding detection for the local variables initialized wit

[clang-tools-extra] [clang-tidy] performance-unnecessary-copy-initialization: Enhance the check for the scenario with MemberExpr initialization. (PR #151936)

2025-08-05 Thread Victor Chernyakin via cfe-commits
@@ -939,3 +939,28 @@ template bool OperatorWithNoDirectCallee(T t) { return a1 == t; } +bool CopiedFromConstRefParmVar(const Struct &crs, const Struct cs, Struct &rs, Struct s) { + const auto m1 = crs.Member; + // CHECK-MESSAGES: [[@LINE-1]]:14: warning: local copy 'm1' o

[clang-tools-extra] [clang-tidy][NFC] Enable `readability-avoid-return-with-void-value` check in the codebase (PR #151356)

2025-07-31 Thread Victor Chernyakin via cfe-commits
@@ -610,9 +619,10 @@ void NarrowingConversionsCheck::handleBinaryOperator(const ASTContext &Context, void NarrowingConversionsCheck::check(const MatchFinder::MatchResult &Result) { if (const auto *Op = Result.Nodes.getNodeAs("binary_op")) -return handleBinaryOperator(*R

[clang-tools-extra] [clang-tidy][NFC] Enable `readability-avoid-return-with-void-value` check in the codebase (PR #151356)

2025-07-31 Thread Victor Chernyakin via cfe-commits
https://github.com/localspook updated https://github.com/llvm/llvm-project/pull/151356 >From 8dd39dd51cb3d199734defcb1c0626d608806812 Mon Sep 17 00:00:00 2001 From: Victor Chernyakin Date: Wed, 30 Jul 2025 08:38:42 -0700 Subject: [PATCH 1/3] [clang-tidy][NFC] Enable `readability-avoid-return-w

[clang-tools-extra] [clang-tidy][NFC] Enable `readability-avoid-return-with-void-value` check in the codebase (PR #151356)

2025-07-31 Thread Victor Chernyakin via cfe-commits
https://github.com/localspook updated https://github.com/llvm/llvm-project/pull/151356 >From 8dd39dd51cb3d199734defcb1c0626d608806812 Mon Sep 17 00:00:00 2001 From: Victor Chernyakin Date: Wed, 30 Jul 2025 08:38:42 -0700 Subject: [PATCH 1/2] [clang-tidy][NFC] Enable `readability-avoid-return-w

[clang-tools-extra] Add clang tidy check performance constexpr non static in scope (PR #147809)

2025-07-30 Thread Victor Chernyakin via cfe-commits
https://github.com/localspook edited https://github.com/llvm/llvm-project/pull/147809 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy][NFC] Enable `readability-avoid-return-with-void-value` check in the codebase (PR #151356)

2025-07-30 Thread Victor Chernyakin via cfe-commits
https://github.com/localspook created https://github.com/llvm/llvm-project/pull/151356 None >From 8dd39dd51cb3d199734defcb1c0626d608806812 Mon Sep 17 00:00:00 2001 From: Victor Chernyakin Date: Wed, 30 Jul 2025 08:38:42 -0700 Subject: [PATCH] [clang-tidy][NFC] Enable `readability-avoid-return

[clang-tools-extra] [clang-tidy] Make `modernize-use-using`'s fix-its more robust (PR #149694)

2025-07-30 Thread Victor Chernyakin via cfe-commits
https://github.com/localspook edited https://github.com/llvm/llvm-project/pull/149694 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][analyzer][NFC] Run `modernize-use-using` check over all the code (PR #149934)

2025-07-30 Thread Victor Chernyakin via cfe-commits
https://github.com/localspook edited https://github.com/llvm/llvm-project/pull/149934 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][NFC] Run `modernize-use-using` check over all the code (PR #149934)

2025-07-30 Thread Victor Chernyakin via cfe-commits
localspook wrote: > Given that there is pushback, its probably safe to split this up into smaller > chunks and let the owners of the parts decide if they want it or not. I can > say for the StaticAnalyzer and Analysis libraries its a welcomed change. Yep, I've gone and limited the changes in t

[clang-tools-extra] [clang-tidy] Make `modernize-use-using`'s fix-its more robust (PR #149694)

2025-07-29 Thread Victor Chernyakin via cfe-commits
https://github.com/localspook updated https://github.com/llvm/llvm-project/pull/149694 >From 823bfd458a0e03125d84fd676fbc284f09b50a5b Mon Sep 17 00:00:00 2001 From: Victor Chernyakin Date: Sat, 19 Jul 2025 23:43:55 -0700 Subject: [PATCH 1/4] [clang-tidy] Make `modernize-use-using`'s fixits more

[clang-tools-extra] [clang-tidy] Make `modernize-use-using`'s fix-its more robust (PR #149694)

2025-07-29 Thread Victor Chernyakin via cfe-commits
https://github.com/localspook updated https://github.com/llvm/llvm-project/pull/149694 >From 823bfd458a0e03125d84fd676fbc284f09b50a5b Mon Sep 17 00:00:00 2001 From: Victor Chernyakin Date: Sat, 19 Jul 2025 23:43:55 -0700 Subject: [PATCH 1/4] [clang-tidy] Make `modernize-use-using`'s fixits more

[clang-tools-extra] [clang-tidy] Make `modernize-use-using`'s fix-its more robust (PR #149694)

2025-07-29 Thread Victor Chernyakin via cfe-commits
localspook wrote: Nope; that's the preexisting issue I mention in the description. I believe fixing it in the general case would require Clang to provide extra information in `TypedefDecl`, something like a `SourceRange DeclSpecSeqRange`: ```cpp typedef const int *ptr1, *ptr2; ^

[clang-tools-extra] [clang-tidy] Add `-std` argument in `check_clang_tidy.py` for C files (PR #150791)

2025-07-28 Thread Victor Chernyakin via cfe-commits
https://github.com/localspook edited https://github.com/llvm/llvm-project/pull/150791 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy] Add `-std` argument in `check_clang_tidy.py` for C files (PR #150791)

2025-07-28 Thread Victor Chernyakin via cfe-commits
@@ -19,13 +18,16 @@ void notRelated(int A, int B) {} int addedTogether(int A, int B) { return add(A, B); } // NO-WARN: Passed to same function. +// FIXME: This triggers a false positive: the "passed to same function" heuristic +// can't map the parameter index 1 to A and B

  1   2   3   >