[clang-tools-extra] [clang-tidy] Add readability-use-span-first-last check (PR #118074)

2024-11-30 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti edited https://github.com/llvm/llvm-project/pull/118074 ___ 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 recursion protection in ExceptionSpecAnalyzer (PR #66810)

2024-11-30 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti approved this pull request. LGTM, but please add a release note about fixing the infinite recursion https://github.com/llvm/llvm-project/pull/66810 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.o

[clang-tools-extra] [clang-tidy] Add recursion protection in ExceptionSpecAnalyzer (PR #66810)

2024-11-30 Thread Julian Schmidt via cfe-commits
5chmidti wrote: And maybe @carlosgalvezp wants to comment https://github.com/llvm/llvm-project/pull/66810 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy][use-internal-linkage]fix false positives for global overloaded operator new and operator delete (PR #117945)

2024-11-30 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/117945 ___ 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 cppcoreguidelines-narrowing-conversions false positives when narrowing integer to signed integer in C++20 (PR #116591)

2024-11-30 Thread Julian Schmidt via cfe-commits
5chmidti wrote: > Whether it well-defined behavior in C++20 or implementation-defined behavior > pre-C++20 does not seem relevant to me. We could certainly adjust the warning > message to avoid saying it's "implementation-defined" in C++20. +1 > When implementing guidelines, we must make sure

[clang] [clang-tools-extra] [clang-tidy][use-internal-linkage]fix false positives for ExportDecl (PR #117901)

2024-11-30 Thread Julian Schmidt via cfe-commits
@@ -926,6 +926,8 @@ AST Matchers - Ensure ``hasName`` matches template specializations across inline namespaces, making `matchesNodeFullSlow` and `matchesNodeFullFast` consistent. +- Add ``exportDecl`` matches export declaration. 5chmidti wrote: > Add a `ex

[clang] [clang-tools-extra] [clang-tidy][use-internal-linkage]fix false positives for ExportDecl (PR #117901)

2024-11-30 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti commented: Please add the matcher to https://github.com/llvm/llvm-project/blob/main/clang/lib/ASTMatchers/Dynamic/Registry.cpp as well (clang-query). https://github.com/llvm/llvm-project/pull/117901 ___ cfe-commits mailing

[clang] [clang-tools-extra] [clang-tidy][use-internal-linkage]fix false positives for ExportDecl (PR #117901)

2024-11-30 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti edited https://github.com/llvm/llvm-project/pull/117901 ___ 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 readability-use-span-first-last check (PR #118074)

2024-11-30 Thread Julian Schmidt via cfe-commits
@@ -0,0 +1,110 @@ +//===--- UseSpanFirstLastCheck.cpp - clang-tidy-*- C++ -*-===// +// +// 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: Apac

[clang-tools-extra] [clang-tidy] Add readability-use-span-first-last check (PR #118074)

2024-11-30 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti requested changes to this pull request. It would be great to have this check work with uninstantiated templates and use `TK_TraversUnlessSpelledInSource` as well. Here is an example of a matcher for the uninstantiated case: https://godbolt.org/z/1xnGGj7z9 I couldn'

[clang-tools-extra] [clang-tidy] Add readability-use-span-first-last check (PR #118074)

2024-11-30 Thread Julian Schmidt via cfe-commits
@@ -0,0 +1,110 @@ +//===--- UseSpanFirstLastCheck.cpp - clang-tidy-*- C++ -*-===// +// +// 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: Apac

[clang-tools-extra] [clang-tidy] Add readability-use-span-first-last check (PR #118074)

2024-11-30 Thread Julian Schmidt via cfe-commits
@@ -0,0 +1,110 @@ +//===--- UseSpanFirstLastCheck.cpp - clang-tidy-*- C++ -*-===// +// +// 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: Apac

[clang-tools-extra] [clang-tidy] Add readability-use-span-first-last check (PR #118074)

2024-11-30 Thread Julian Schmidt via cfe-commits
5chmidti wrote: Please add tests with macros involved (e.g., fully wrapped `#define F(obj, n)...` or `#define N 2`, etc), and with templates https://github.com/llvm/llvm-project/pull/118074 ___ cfe-commits mailing li

[clang-tools-extra] [clang-tidy] Add readability-use-span-first-last check (PR #118074)

2024-11-30 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti edited https://github.com/llvm/llvm-project/pull/118074 ___ 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 readability-use-span-first-last check (PR #118074)

2024-11-30 Thread Julian Schmidt via cfe-commits
@@ -0,0 +1,110 @@ +//===--- UseSpanFirstLastCheck.cpp - clang-tidy-*- C++ -*-===// +// +// 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: Apac

[clang-tools-extra] [clang-tidy] Add readability-use-span-first-last check (PR #118074)

2024-11-30 Thread Julian Schmidt via cfe-commits
@@ -0,0 +1,110 @@ +//===--- UseSpanFirstLastCheck.cpp - clang-tidy-*- C++ -*-===// +// +// 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: Apac

[clang-tools-extra] [clang-tidy] Add readability-use-span-first-last check (PR #118074)

2024-11-30 Thread Julian Schmidt via cfe-commits
@@ -0,0 +1,110 @@ +//===--- UseSpanFirstLastCheck.cpp - clang-tidy-*- C++ -*-===// +// +// 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: Apac

[clang-tools-extra] [clang-tidy] Add readability-use-span-first-last check (PR #118074)

2024-11-30 Thread Julian Schmidt via cfe-commits
5chmidti wrote: You removed this by mistake, it's from another check https://github.com/llvm/llvm-project/pull/118074 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/list

[clang-tools-extra] [clang-tidy] Add readability-use-span-first-last check (PR #118074)

2024-11-30 Thread Julian Schmidt via cfe-commits
@@ -0,0 +1,110 @@ +//===--- UseSpanFirstLastCheck.cpp - clang-tidy-*- C++ -*-===// +// +// 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: Apac

[clang-tools-extra] [clang-tidy] Add readability-use-span-first-last check (PR #118074)

2024-11-30 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti edited https://github.com/llvm/llvm-project/pull/118074 ___ 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 readability-use-span-first-last check (PR #118074)

2024-11-30 Thread Julian Schmidt via cfe-commits
@@ -0,0 +1,44 @@ +//===--- UseSpanFirstLastCheck.h - clang-tidy---*- C++ -*-===// +// +// 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: Apach

[clang-tools-extra] [clang-tidy] Add readability-use-span-first-last check (PR #118074)

2024-11-30 Thread Julian Schmidt via cfe-commits
@@ -172,6 +173,8 @@ class ReadabilityModule : public ClangTidyModule { "readability-use-anyofallof"); CheckFactories.registerCheck( "readability-use-std-min-max"); +CheckFactories.registerCheck( +"readability-use-span-first-last"); --

[clang-tools-extra] [clang-tidy] fix nullptr dereference in bugprone-forwarding-reference (PR #106856)

2024-09-17 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti closed https://github.com/llvm/llvm-project/pull/106856 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [NFC][clang-tidy] reword diagnostic note in definitions-in-headers (PR #106862)

2024-09-17 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti closed https://github.com/llvm/llvm-project/pull/106862 ___ 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 positive in modernize-min-max-use-initializer-list (PR #107649)

2024-09-17 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti closed https://github.com/llvm/llvm-project/pull/107649 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy] only diagnose definitions in readability-enum-initial-value (PR #107652)

2024-09-17 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti closed https://github.com/llvm/llvm-project/pull/107652 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy] use specified type verbatim in modernize-use-using fix (PR #113837)

2024-12-01 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti edited https://github.com/llvm/llvm-project/pull/113837 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy] use specified type verbatim in modernize-use-using fix (PR #113837)

2024-12-01 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti edited https://github.com/llvm/llvm-project/pull/113837 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy] use specified type verbatim in modernize-use-using fix (PR #113837)

2024-12-01 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti updated https://github.com/llvm/llvm-project/pull/113837 >From 8170641109c09e55b1530081e103a1e919eb8bfc Mon Sep 17 00:00:00 2001 From: Julian Schmidt Date: Sun, 27 Oct 2024 21:49:34 +0100 Subject: [PATCH 1/6] [clang-tidy] do not expand macros in modernize-use-using

[clang-tools-extra] [clang-tidy] use specified type verbatim in modernize-use-using fix (PR #113837)

2024-12-01 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti edited https://github.com/llvm/llvm-project/pull/113837 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy] use specified type verbatim in modernize-use-using fix (PR #113837)

2024-12-01 Thread Julian Schmidt via cfe-commits
@@ -119,14 +122,55 @@ void UseUsingCheck::check(const MatchFinder::MatchResult &Result) { return; } - PrintingPolicy PrintPolicy(getLangOpts()); - PrintPolicy.SuppressScope = true; - PrintPolicy.ConstantArraySizeAsWritten = true; - PrintPolicy.UseVoidForZeroParams =

[clang-tools-extra] [clang-tidy] use specified type verbatim in modernize-use-using fix (PR #113837)

2024-12-01 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti commented: I noticed some more issues that this is fixing, so I've added their examples as test-cases https://github.com/llvm/llvm-project/pull/113837 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.ll

[clang-tools-extra] [clang-tidy] Create a check for signed and unsigned integers comparison (PR #113144)

2024-12-02 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti approved this pull request. LGTM, thanks! https://github.com/llvm/llvm-project/pull/113144 ___ 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 readability-use-span-first-last check (PR #118074)

2024-12-02 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti edited https://github.com/llvm/llvm-project/pull/118074 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy] ignore `[[clang::lifetimebound]]` param in return-const-ref-from-parameter (PR #118315)

2024-12-02 Thread Julian Schmidt via cfe-commits
@@ -38,3 +29,21 @@ Example const S& s = fn(S{1}); s.v; // use after free + + +This issue can be resolved by declaring an overload of the problematic function +where the ``const &`` parameter is instead declared as ``&&``. The developer has +to ensure that the implementati

[clang-tools-extra] [clang-tidy] ignore `[[clang::lifetimebound]]` param in return-const-ref-from-parameter (PR #118315)

2024-12-02 Thread Julian Schmidt via cfe-commits
@@ -38,3 +29,21 @@ Example const S& s = fn(S{1}); s.v; // use after free + + +This issue can be resolved by declaring an overload of the problematic function +where the ``const &`` parameter is instead declared as ``&&``. The developer has +to ensure that the implementati

[clang-tools-extra] [clang-tidy] ignore `[[clang::lifetimebound]]` param in return-const-ref-from-parameter (PR #118315)

2024-12-02 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti edited https://github.com/llvm/llvm-project/pull/118315 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy] ignore `[[clang::lifetimebound]]` param in return-const-ref-from-parameter (PR #118315)

2024-12-02 Thread Julian Schmidt via cfe-commits
@@ -184,7 +184,8 @@ Changes in existing checks ` check to diagnose potential dangling references when returning a ``const &`` parameter by using the conditional operator ``cond ? var1 : var2`` and no longer giving - false positives for functions which contain lambda. +

[clang-tools-extra] [clang-tidy] ignore `[[clang::lifetimebound]]` param in return-const-ref-from-parameter (PR #118315)

2024-12-02 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti approved this pull request. LGTM, just small nits. https://github.com/llvm/llvm-project/pull/118315 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy] ignore `[[clang::lifetimebound]]` param in return-const-ref-from-parameter (PR #118315)

2024-12-02 Thread Julian Schmidt via cfe-commits
@@ -15,14 +16,23 @@ using namespace clang::ast_matchers; namespace clang::tidy::bugprone { +namespace { + +AST_MATCHER(ParmVarDecl, hasLifetimeBoundAttr) { + return Node.getAttr() != nullptr; 5chmidti wrote: nit: `Node.hasAttr()` https://github.com/llvm/ll

[clang] Revert "Reland: [clang][test] add testing for the AST matcher reference" (PR #116477)

2024-11-15 Thread Julian Schmidt via cfe-commits
5chmidti wrote: > Reverts llvm/llvm-project#112168 > LLVM Buildbot has detected a new failure on builder > `clang-arm64-windows-msvc` running on `linaro-armv8-windows-msvc-04` while > building `clang` at step 5 "ninja check 1". > > Full details are available at: > https://lab.llvm.org/buildb

[clang] Revert "Reland: [clang][test] add testing for the AST matcher reference" (PR #116477)

2024-11-15 Thread Julian Schmidt via cfe-commits
5chmidti wrote: Sure! It timed out on the Windows arm builder again, I'm already in contact with the bot owner. https://github.com/llvm/llvm-project/pull/116477 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mai

[clang-tools-extra] [clang-tidy] Fix false positive in cppcoreguidelines-avoid-const-or-ref-data-members when detecting templated classes with inheritance (PR #115180)

2024-11-15 Thread Julian Schmidt via cfe-commits
@@ -13,79 +13,92 @@ using namespace clang::ast_matchers; namespace clang::tidy::cppcoreguidelines { -namespace { -AST_MATCHER(FieldDecl, isMemberOfLambda) { - return Node.getParent()->isLambda(); +static bool hasCopyConstructor(CXXRecordDecl const &Node) { + if (Node.needs

[clang] Revert "Reland: [clang][test] add testing for the AST matcher reference" (PR #116477)

2024-11-15 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti closed https://github.com/llvm/llvm-project/pull/116477 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy] Improved readability redundant casting with enums (PR #111424)

2024-11-16 Thread Julian Schmidt via cfe-commits
=?utf-8?q?Félix-Antoine?= Constantin, =?utf-8?q?Félix-Antoine?= Constantin, =?utf-8?q?Félix-Antoine?= Constantin Message-ID: In-Reply-To: 5chmidti wrote: > Is it really a false negative? In another word, does `enum E1 : char {};` > mean `E1` is the type alias of `char`? > IMO is not. for me a

[clang-tools-extra] [clang-tidy] Create bugprone-incorrect-enable-shared-from-this check (PR #102299)

2024-11-25 Thread Julian Schmidt via cfe-commits
5chmidti wrote: Unless someone also wants to review this PR, I'll merge this tomorrow. The unresolved review comments of the other reviewers have, FWICT, been resolved. https://github.com/llvm/llvm-project/pull/102299 ___ cfe-commits mailing list cfe-

[clang-tools-extra] [clang-tidy] New option `CompilationArgsToRemoveRegex` to remove arguments from the command line (PR #111453)

2024-11-24 Thread Julian Schmidt via cfe-commits
=?utf-8?q?Félix-Antoine?= Constantin Message-ID: In-Reply-To: 5chmidti wrote: I think the regex solution might be brittle/not clean from a user perspective, with potential for a small amount of maintenance. Instead, I would also suggest a flag to error, warn, or silence these, defaulting to a

[clang] [clang-tools-extra] [clang-tidy][use-internal-linkage]fix false positives for ExportDecl (PR #117901)

2024-11-30 Thread Julian Schmidt via cfe-commits
5chmidti wrote: > > Please add the matcher to > > https://github.com/llvm/llvm-project/blob/main/clang/lib/ASTMatchers/Dynamic/Registry.cpp > > as well (clang-query). > > i will do it separately to avoid this pr become bigger. I think you only have to add it into that file for it to work, and

[clang-tools-extra] [clang-tidy] Create a check for signed and unsigned integers comparison (PR #113144)

2024-12-01 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti edited https://github.com/llvm/llvm-project/pull/113144 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy] Create a check for signed and unsigned integers comparison (PR #113144)

2024-12-01 Thread Julian Schmidt via cfe-commits
@@ -0,0 +1,165 @@ +//===--- UseIntegerSignComparisonCheck.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-tidy] Create a check for signed and unsigned integers comparison (PR #113144)

2024-12-01 Thread Julian Schmidt via cfe-commits
@@ -0,0 +1,36 @@ +.. title:: clang-tidy - modernize-use-integer-sign-comparison + +modernize-use-integer-sign-comparison += + +Replace comparisons between signed and unsigned integers with their safe +C++20 ``std::cmp_*`` alternative, if availab

[clang-tools-extra] [clang-tidy] Create a check for signed and unsigned integers comparison (PR #113144)

2024-12-01 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti commented: Just some small things to address https://github.com/llvm/llvm-project/pull/113144 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy] Create a check for signed and unsigned integers comparison (PR #113144)

2024-12-01 Thread Julian Schmidt via cfe-commits
@@ -0,0 +1,36 @@ +.. title:: clang-tidy - modernize-use-integer-sign-comparison + +modernize-use-integer-sign-comparison += + +Replace comparisons between signed and unsigned integers with their safe +C++20 ``std::cmp_*`` alternative, if availab

[clang-tools-extra] [clang-tidy] Create a check for signed and unsigned integers comparison (PR #113144)

2024-12-01 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti edited https://github.com/llvm/llvm-project/pull/113144 ___ 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 readability-use-span-first-last check (PR #118074)

2024-12-03 Thread Julian Schmidt via cfe-commits
@@ -0,0 +1,98 @@ +// RUN: %check_clang_tidy -std=c++20 %s readability-use-span-first-last %t + +namespace std { +template +class span { + T* ptr; + __SIZE_TYPE__ len; + +public: + span(T* p, __SIZE_TYPE__ l) : ptr(p), len(l) {} + + span subspan(__SIZE_TYPE__ offset) const {

[clang-tools-extra] [clang-tidy] Add readability-use-span-first-last check (PR #118074)

2024-12-03 Thread Julian Schmidt via cfe-commits
@@ -0,0 +1,24 @@ +.. title:: clang-tidy - readability-use-span-first-last + +readability-use-span-first-last +=== + +Checks for uses of ``std::span::subspan()`` that can be replaced with clearer +``first()`` or ``last()`` member functions. These dedicat

[clang-tools-extra] [clang-tidy] Add readability-use-span-first-last check (PR #118074)

2024-12-03 Thread Julian Schmidt via cfe-commits
@@ -0,0 +1,125 @@ +//===--- UseSpanFirstLastCheck.cpp - clang-tidy -*- C++ -*-===// +// +// 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-tidy] Add readability-use-span-first-last check (PR #118074)

2024-12-03 Thread Julian Schmidt via cfe-commits
@@ -0,0 +1,125 @@ +//===--- UseSpanFirstLastCheck.cpp - clang-tidy -*- C++ -*-===// +// +// 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-tidy] Add readability-use-span-first-last check (PR #118074)

2024-12-03 Thread Julian Schmidt via cfe-commits
@@ -0,0 +1,125 @@ +//===--- UseSpanFirstLastCheck.cpp - clang-tidy -*- C++ -*-===// +// +// 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-tidy] ignore `[[clang::lifetimebound]]` param in return-const-ref-from-parameter (PR #118315)

2024-12-03 Thread Julian Schmidt via cfe-commits
@@ -38,3 +29,21 @@ Example const S& s = fn(S{1}); s.v; // use after free + + +This issue can be resolved by declaring an overload of the problematic function +where the ``const &`` parameter is instead declared as ``&&``. The developer has +to ensure that the implementati

[clang-tools-extra] [clang-tidy] modernize-make-shared: Add MakeSmartPtrType option (PR #117529)

2024-12-04 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti commented: > With current implementation you may run into issue where when setting custom > smart ptr, you won't have anymore support for shared_ptr. Other option would be to add "make-custom" check, and leave it unconfigured. Supporting multiple `make_x` would be be

[clang-tools-extra] [clang-tidy] modernize-make-shared: Add MakeSmartPtrType option (PR #117529)

2024-12-04 Thread Julian Schmidt via cfe-commits
@@ -22,7 +22,8 @@ namespace clang::tidy::modernize { class MakeSmartPtrCheck : public ClangTidyCheck { public: MakeSmartPtrCheck(StringRef Name, ClangTidyContext *Context, -StringRef MakeSmartPtrFunctionName); +StringRef MakeSmartPtrFun

[clang-tools-extra] [clang-tidy] modernize-make-shared: Add MakeSmartPtrType option (PR #117529)

2024-12-04 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti edited https://github.com/llvm/llvm-project/pull/117529 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy][docs] improve documentation on cppcoreguidelines-narrowing-conversions (#111510) (PR #118209)

2024-12-04 Thread Julian Schmidt via cfe-commits
@@ -27,6 +27,39 @@ This check will flag: - All applications of binary operators with a narrowing conversions. For example: ``int i; i+= 0.1;``. +Arithmetic with smaller integer types than ``int`` trigger implicit conversions, +as explained under `"Integral Promotion" on c

[clang] [Clang] Diagnose down casting static_cast (PR #117914)

2024-12-05 Thread Julian Schmidt via cfe-commits
5chmidti wrote: > I think the checker can be removed if clang has this kind of compilation time > warning and can totally cover the checker. It only covers the whole check if `StrictMode` is not set to `false`, because that enables diagnosing down-casts for non-polymorphic types as well. > Pe

[clang-tools-extra] [clang-tidy][NFC] move AST_MATCHER to anonymous namespace in InfiniteLoopCheck (PR #118820)

2024-12-05 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/118820 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy][clangd] Fixed removeFunctionArgs don't remove comma for use-ranges check (PR #118568)

2024-12-28 Thread Julian Schmidt via cfe-commits
@@ -164,6 +164,33 @@ void UseRangesCheck::registerMatchers(MatchFinder *Finder) { static void removeFunctionArgs(DiagnosticBuilder &Diag, const CallExpr &Call, ArrayRef Indexes, const ASTContext &Ctx) { + auto GetC

[clang-tools-extra] [clang-tidy] swap cppcoreguidelines-narrowing-conversions and bugprone-narrowing-conversions (PR #120245)

2024-12-28 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti approved this pull request. LGTM, thanks https://github.com/llvm/llvm-project/pull/120245 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy] Mention std::forward_list in container-size-empty doc (PR #120701)

2024-12-28 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti approved this pull request. https://github.com/llvm/llvm-project/pull/120701 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy] Filter out googletest TUs in bugprone-unchecked-optional-access (PR #115051)

2025-01-07 Thread Julian Schmidt via cfe-commits
@@ -40,11 +40,30 @@ void UncheckedOptionalAccessCheck::registerMatchers(MatchFinder *Finder) { this); } +void UncheckedOptionalAccessCheck::onStartOfTranslationUnit() { + // Reset the flag for each TU. + is_test_tu_ = false; +} + void UncheckedOptionalAccessCheck::ch

[clang-tools-extra] [clang-tidy] Filter out googletest TUs in bugprone-unchecked-optional-access (PR #115051)

2025-01-07 Thread Julian Schmidt via cfe-commits
@@ -40,11 +40,30 @@ void UncheckedOptionalAccessCheck::registerMatchers(MatchFinder *Finder) { this); } +void UncheckedOptionalAccessCheck::onStartOfTranslationUnit() { + // Reset the flag for each TU. + is_test_tu_ = false; +} + void UncheckedOptionalAccessCheck::ch

[clang-tools-extra] [clang-tidy] Filter out googletest TUs in bugprone-unchecked-optional-access (PR #115051)

2025-01-07 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti edited https://github.com/llvm/llvm-project/pull/115051 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy] Filter out googletest TUs in bugprone-unchecked-optional-access (PR #115051)

2025-01-07 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti commented: Sorry for the delay. I think, that we can probably all agree that the best solution would be to have the model support the macros, e.g., by recognizing the patterns that are behind these macros. However, that is currently not something that people can fin

[clang-tools-extra] [clang-tidy] fix false positives when using name-independent variables after C++26 for bugprone-unused-local-non-trivial-variable (PR #121783)

2025-01-08 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/121783 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy][doc] mention smart ptr in bugprone-unhandled-self-assignment.WarnOnlyIfThisHasSuspiciousField option (PR #121316)

2024-12-30 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti approved this pull request. https://github.com/llvm/llvm-project/pull/121316 ___ 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 depercation warning for non-whitelisted global options (PR #121057)

2024-12-28 Thread Julian Schmidt via cfe-commits
5chmidti wrote: > Good point, maybe we can use more smart way to do warning: only warn the > global option is set but local option is not. > > Have some redundant options is not the aim for this deprecation things, we > only want to avoid user suddenly find the behaviors of lots of check are

[clang] [Clang][ASTMatcher] Add `dependentNameType` Matcher (PR #121263)

2024-12-28 Thread Julian Schmidt via cfe-commits
@@ -218,6 +218,7 @@ RegistryMaps::RegistryMaps() { REGISTER_MATCHER(cxxTryStmt); REGISTER_MATCHER(cxxUnresolvedConstructExpr); REGISTER_MATCHER(decayedType); + REGISTER_MATCHER(dependentNameType); 5chmidti wrote: Please sort this in alphabetically http

[clang] [Clang][ASTMatcher] Add `dependentNameType` Matcher (PR #121263)

2024-12-28 Thread Julian Schmidt via cfe-commits
@@ -7711,6 +7711,16 @@ AST_MATCHER_P(DecayedType, hasDecayedType, internal::Matcher, return InnerType.matches(Node.getDecayedType(), Finder, Builder); } +/// Matches dependent name type 5chmidti wrote: nit: `a dependent name type` (+1 in release notes) ht

[clang-tools-extra] [clang-tidy] add depercation warning for non-whitelisted global options (PR #121057)

2024-12-30 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti approved this pull request. Looks good from my side. --- > Perhaps we can just land this as is for now and introduce the escape hatch if > we get feedback indicating it's needed? I think that is totally fine. If this comes up, we can also immediately backport the

[clang-tools-extra] [clang-tidy] Add bugprone-smartptr-reset-ambiguous-call check (PR #121291)

2024-12-30 Thread Julian Schmidt via cfe-commits
@@ -0,0 +1,134 @@ +//===--- SmartptrResetAmbiguousCallCheck.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-tidy] Add bugprone-smartptr-reset-ambiguous-call check (PR #121291)

2024-12-30 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti edited https://github.com/llvm/llvm-project/pull/121291 ___ 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 bugprone-smartptr-reset-ambiguous-call check (PR #121291)

2024-12-30 Thread Julian Schmidt via cfe-commits
@@ -0,0 +1,34 @@ +//===--- SmartptrResetAmbiguousCallCheck.h - clang-tidy -*- C++ -*-===// +// +// 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] Add bugprone-smartptr-reset-ambiguous-call check (PR #121291)

2024-12-30 Thread Julian Schmidt via cfe-commits
@@ -0,0 +1,34 @@ +.. title:: clang-tidy - bugprone-smartptr-reset-ambiguous-call + +bugprone-smartptr-reset-ambiguous-call +== + +Finds potentially erroneous calls to ``reset`` method on +smart pointers when the pointee type also has a ``reset``

[clang-tools-extra] [clang-tidy] Add bugprone-smartptr-reset-ambiguous-call check (PR #121291)

2024-12-30 Thread Julian Schmidt via cfe-commits
@@ -0,0 +1,34 @@ +.. title:: clang-tidy - bugprone-smartptr-reset-ambiguous-call + +bugprone-smartptr-reset-ambiguous-call +== + +Finds potentially erroneous calls to ``reset`` method on +smart pointers when the pointee type also has a ``reset``

[clang-tools-extra] [clang-tidy] Add bugprone-smartptr-reset-ambiguous-call check (PR #121291)

2024-12-30 Thread Julian Schmidt via cfe-commits
@@ -0,0 +1,34 @@ +.. title:: clang-tidy - bugprone-smartptr-reset-ambiguous-call + +bugprone-smartptr-reset-ambiguous-call +== + +Finds potentially erroneous calls to ``reset`` method on +smart pointers when the pointee type also has a ``reset``

[clang-tools-extra] [clang-tidy] Add bugprone-smartptr-reset-ambiguous-call check (PR #121291)

2024-12-30 Thread Julian Schmidt via cfe-commits
@@ -144,6 +145,8 @@ class BugproneModule : public ClangTidyModule { "bugprone-inaccurate-erase"); CheckFactories.registerCheck( "bugprone-incorrect-enable-if"); +CheckFactories.registerCheck( +"bugprone-smartptr-reset-ambiguous-call"); --

[clang-tools-extra] [clang-tidy] Add bugprone-smartptr-reset-ambiguous-call check (PR #121291)

2024-12-30 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti requested changes to this pull request. I think that this check is one that we don't want to emit fixes for, at least not in the main diagnostic, but maybe as a fixit attached to a note. Sort of like: ``` warning: ... note: (be more explicit and) use '= nullptr' ```

[clang-tools-extra] [clang-tidy] Add bugprone-smartptr-reset-ambiguous-call check (PR #121291)

2024-12-30 Thread Julian Schmidt via cfe-commits
@@ -0,0 +1,134 @@ +//===--- SmartptrResetAmbiguousCallCheck.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-tidy] Add readability-use-span-first-last check (PR #118074)

2024-12-11 Thread Julian Schmidt via cfe-commits
@@ -0,0 +1,96 @@ +//===--- UseSpanFirstLastCheck.cpp - clang-tidy -*- C++ -*-===// +// +// 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][NFC][doc] clean out-dated clang-static-analyzer checks (PR #119580)

2024-12-11 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti approved this pull request. https://github.com/llvm/llvm-project/pull/119580 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [analyzer] Split alpha core Identical Expression tests (PR #119543)

2024-12-11 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti edited https://github.com/llvm/llvm-project/pull/119543 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [analyzer] Split alpha core Identical Expression tests (PR #119543)

2024-12-11 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti commented: Please change the `RUN` lines to use `check_clang_tidy` like so: `// RUN: %check_clang_tidy %s bugprone-branch-clone %t`, and drop the `BUGPRONEBRANCH` suffix in `bugprone-branch-clone.cpp`, as it is redundant after this change, and after removing the acci

[clang-tools-extra] [analyzer] Split alpha core Identical Expression tests (PR #119543)

2024-12-11 Thread Julian Schmidt via cfe-commits
@@ -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) +{ + r

[clang-tools-extra] [clang-tidy]detecting conversion directly by `make_unique` and `make_shared` in bugprone-optional-value-conversion (PR #119371)

2024-12-11 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti approved this pull request. https://github.com/llvm/llvm-project/pull/119371 ___ 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 readability-use-span-first-last check (PR #118074)

2024-12-11 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti edited https://github.com/llvm/llvm-project/pull/118074 ___ 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 readability-use-span-first-last check (PR #118074)

2024-12-11 Thread Julian Schmidt via cfe-commits
@@ -0,0 +1,104 @@ +//===--- UseSpanFirstLastCheck.cpp - clang-tidy -*- C++ -*-===// +// +// 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-tidy] Add readability-use-span-first-last check (PR #118074)

2024-12-11 Thread Julian Schmidt via cfe-commits
@@ -0,0 +1,104 @@ +//===--- UseSpanFirstLastCheck.cpp - clang-tidy -*- C++ -*-===// +// +// 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-tidy] Add readability-use-span-first-last check (PR #118074)

2024-12-11 Thread Julian Schmidt via cfe-commits
@@ -0,0 +1,104 @@ +//===--- UseSpanFirstLastCheck.cpp - clang-tidy -*- C++ -*-===// +// +// 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-tidy][NFC] use local config in test cases (PR #120004)

2024-12-15 Thread Julian Schmidt via cfe-commits
@@ -26,7 +26,7 @@ class InconsistentDeclarationParameterNameCheck : public ClangTidyCheck { ClangTidyContext *Context) : ClangTidyCheck(Name, Context), IgnoreMacros(Options.getLocalOrGlobal("IgnoreMacros", true)), -

[clang] [clang-tools-extra] [ASTMatchers] fix `isStaticStorageClass` not matching definitions of forward declared functions (PR #120027)

2024-12-15 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti created https://github.com/llvm/llvm-project/pull/120027 ```c++ static void foo(); void foo() {} struct A { static void bar(); }; void A::bar() {} ``` Both definitions refer to their previous declaration, but were not considered `static`, because the matcher did

<    7   8   9   10   11   12   13   >