[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 updated https://github.com/llvm/llvm-project/pull/120027 >From 35a1cecb08d1827fb45c2e6bb06983ed363ca769 Mon Sep 17 00:00:00 2001 From: Julian Schmidt Date: Mon, 16 Dec 2024 01:18:06 +0100 Subject: [PATCH] [ASTMatchers] fix `isStaticStorageClass` not matching definit

[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 edited https://github.com/llvm/llvm-project/pull/120027 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [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 edited https://github.com/llvm/llvm-project/pull/120027 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [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 updated https://github.com/llvm/llvm-project/pull/120027 >From 07dd31ddd40cdb792d33fc3394f6356de029a137 Mon Sep 17 00:00:00 2001 From: Julian Schmidt Date: Mon, 16 Dec 2024 01:28:42 +0100 Subject: [PATCH] [ASTMatchers] fix `isStaticStorageClass` not matching definit

[clang-tools-extra] [clang-tidy] performance-unnecessary-copy-initialization: Consider static functions (PR #119974)

2024-12-15 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti commented: > Not sure how many more tests I should add, since this uses the same code > paths as free functions. I think the amount of tests you've added are enough > This is the 5th instance of the `isStatic` matcher in clang-tidy. Good point, thanks. I've checked

[clang-tools-extra] [clang-tidy] performance-unnecessary-copy-initialization: Consider static functions (PR #119974)

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

[clang] [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 ready_for_review https://github.com/llvm/llvm-project/pull/120027 ___ 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: Consider static functions (PR #119974)

2024-12-15 Thread Julian Schmidt via cfe-commits
@@ -104,14 +104,16 @@ AST_MATCHER_FUNCTION_P(StatementMatcher, hasArgument(0, hasType(ReceiverType); } +AST_MATCHER(CXXMethodDecl, isStatic) { return Node.isStatic(); } + AST_MATCHER_FUNCTION(StatementMatcher, isConstRefReturningFunctionCal

[clang-tools-extra] [clang-tidy] performance-unnecessary-copy-initialization: Consider static functions (PR #119974)

2024-12-15 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti edited https://github.com/llvm/llvm-project/pull/119974 ___ 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-12-15 Thread Julian Schmidt via cfe-commits
5chmidti wrote: The move to bugprone makes sense to me. However, I'm not sure that conversions of integers to signed integers should be ignored-by-default since C++20. It may be well-defined behavior w.r.t. the resulting value, but the pattern is still prone to bugs. You will get a well-defi

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

2024-12-15 Thread Julian Schmidt via cfe-commits
5chmidti wrote: Ping 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] [ASTMatchers] fix `isStaticStorageClass` not matching definitions of forward declared functions (PR #120027)

2024-12-16 Thread Julian Schmidt via cfe-commits
5chmidti wrote: Another solution would be to explicitly document the definition is not matching with `isStaticStorageClass`, and we add `hasCanonicalDecl`. That solution would do less behind the scenes at the cost of potentially tripping poeple up (though documenting this for `isStaticStorageC

[clang] [Clang] Permit noescape on non-pointer types (PR #117344)

2024-12-12 Thread Julian Schmidt via cfe-commits
5chmidti wrote: > whether `bugprone-no-escape` would want to see these changes or not. The `bugprone-no-escape` check seems to be a bit limited because it only works with `dispatch_async` and `dispatch_after` (from Apple, it seems). It could probably be expanded to include some more async cons

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

2024-12-12 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] [clang-tidy] remove misuse of `getLocalOrGlobal` for non common used options (PR #119948)

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

[clang-tools-extra] [clang-tidy] remove misuse of `getLocalOrGlobal` for non common used options (PR #119948)

2024-12-14 Thread Julian Schmidt via cfe-commits
5chmidti wrote: @HerrCai0907 Could you retroactively add a release note? While this hopefully doesn't exist in anyone's config, but if someone were to look, they'd see why this was done. https://github.com/llvm/llvm-project/pull/119948 ___ cfe-commi

[clang-tools-extra] [clang-tidy][NFC] extract options verify to separately function (PR #120768)

2024-12-20 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/120768 ___ 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-string-view-substr check (PR #120055)

2024-12-19 Thread Julian Schmidt via cfe-commits
@@ -0,0 +1,39 @@ +//===--- StringViewSubstrCheck.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:

[clang-tools-extra] [clang-tidy] Add readability-string-view-substr check (PR #120055)

2024-12-19 Thread Julian Schmidt via cfe-commits
@@ -0,0 +1,39 @@ +//===--- StringViewSubstrCheck.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:

[clang-tools-extra] [clang-tidy] Add readability-string-view-substr check (PR #120055)

2024-12-19 Thread Julian Schmidt via cfe-commits
@@ -0,0 +1,201 @@ +//===--- StringViewSubstrCheck.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-string-view-substr check (PR #120055)

2024-12-19 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti edited https://github.com/llvm/llvm-project/pull/120055 ___ 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-string-view-substr check (PR #120055)

2024-12-19 Thread Julian Schmidt via cfe-commits
@@ -0,0 +1,201 @@ +//===--- StringViewSubstrCheck.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-string-view-substr check (PR #120055)

2024-12-19 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti commented: The detected issues together with the fixes can currently produce code that can't compile. For example: ```diff void f(std::string_view sv); void g(std::string_view sv) { - const auto copy = sv = sv.substr(0, sv.length() - 3);

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

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

[clang-tools-extra] Added options to readability-implicit-bool-conversion (PR #120087)

2024-12-19 Thread Julian Schmidt via cfe-commits
@@ -319,10 +319,9 @@ Changes in existing checks diagnostic. - Improved :doc:`readability-implicit-bool-conversion - ` check - by adding the option `UseUpperCaseLiteralSuffix` to select the - case of the literal suffix in fixes and fixing false positive for implicit - con

[clang-tools-extra] Added options to readability-implicit-bool-conversion (PR #120087)

2024-12-19 Thread Julian Schmidt via cfe-commits
@@ -287,72 +292,83 @@ void ImplicitBoolConversionCheck::registerMatchers(MatchFinder *Finder) { auto BoolXor = binaryOperator(hasOperatorName("^"), hasLHS(ImplicitCastFromBool), hasRHS(ImplicitCastFromBool)); - auto ComparisonInCall = allOf( -

[clang-tools-extra] Added options to readability-implicit-bool-conversion (PR #120087)

2024-12-19 Thread Julian Schmidt via cfe-commits
5chmidti wrote: You have added `-check-suffix` options to each of your `RUN` lines, but none of your `CHECK-MESSAGES` are actually using it. E.g.,: ```C++ // CHECK-MESSAGES-TO-BOOL-FALSE ``` Although, instead of using the suffixes to say `FALSE`, you could sw

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

2024-12-19 Thread Julian Schmidt via cfe-commits
@@ -1,10 +1,93 @@ .. title:: clang-tidy - bugprone-narrowing-conversions -.. meta:: - :http-equiv=refresh: 5;URL=../cppcoreguidelines/narrowing-conversions.html bugprone-narrowing-conversions == -The bugprone-narrowing-conversions check is an a

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

2024-12-19 Thread Julian Schmidt via cfe-commits
5chmidti wrote: Please change the header guard to use `bugprone` as the 'path' instead of `cppcoreguidelines` https://github.com/llvm/llvm-project/pull/120245 ___ cfe-commits mailing list cfe-commits@lists.llvm.org h

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

2024-12-19 Thread Julian Schmidt via cfe-commits
@@ -411,7 +411,7 @@ Check aliases .. csv-table:: :header: "Name", "Redirect", "Offers fixes" - :doc:`bugprone-narrowing-conversions `, :doc:`cppcoreguidelines-narrowing-conversions `, + :doc:`cppcoreguidelines-narrowing-conversions `, :doc:`bugprone-narrowing-convers

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

2024-12-19 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti commented: No release note is fine for this patch, as this fixes a problem that is invisible when using clang-tidy, but visible with clangd. The general case for clangd is fixed in #118569. Otherwise, I don't think this would be a release note for clang-tidy, but fo

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

2024-12-19 Thread Julian Schmidt via cfe-commits
@@ -173,21 +174,21 @@ static void removeFunctionArgs(DiagnosticBuilder &Diag, const CallExpr &Call, for (unsigned Index : Sorted) { const Expr *Arg = Call.getArg(Index); if (Commas[Index]) { - if (Index >= Commas.size()) { -Diag << FixItHint::CreateRemov

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

2024-12-19 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti edited https://github.com/llvm/llvm-project/pull/118568 ___ 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-19 Thread Julian Schmidt via cfe-commits
@@ -28,6 +28,7 @@ #include "llvm/ADT/Twine.h" #include "llvm/Support/raw_ostream.h" #include +#include 5chmidti wrote: Please remove this include https://github.com/llvm/llvm-project/pull/118568 ___ cfe-commits ma

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

2024-12-19 Thread Julian Schmidt via cfe-commits
5chmidti wrote: The file-names should follow the naming convention of the other tests: `checkers/misc/redundant-expression.cpp` (applies to both). @HerrCai0907 @PiotrZSL IMO merging these tests with the existing ones would result in too-large files, so the files would probably be named somet

[clang-tools-extra] [clang-tidy] performance-unnecessary-copy-initialization: Consider static functions (PR #119974)

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

[clang-tools-extra] [clang-tidy] support parameters file in command line (PR #120547)

2024-12-19 Thread Julian Schmidt via cfe-commits
@@ -33,6 +33,13 @@ compilation options on the command line after ``--``: $ clang-tidy test.cpp -- -Imy_project/include -DMY_DEFINES ... +If there are too many options to specify on the command line, you can store them +in a parameter file, and use :program:`clang-tidy` wit

[clang-tools-extra] [clang-tidy] support parameters file in command line (PR #120547)

2024-12-19 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti commented: As this is not using `llvm::cl`, it is not automatically documented in `--help`. Maybe some sort of comment inside `ClangTidyHelp` would help with the discoverability from the CLI. https://github.com/llvm/llvm-project/pull/120547 _

[clang-tools-extra] [clang-tidy] support parameters file in command line (PR #120547)

2024-12-19 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti edited https://github.com/llvm/llvm-project/pull/120547 ___ 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-19 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti approved this pull request. Thanks. LGTM from my side, but give it a few days in case the others want to review as well https://github.com/llvm/llvm-project/pull/119543 ___ cfe-commits mailing list cfe-commits@lists.llvm.o

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

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

2024-12-19 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti commented: You could try to implement the check with `TK_TraverseUnlessSpelledInSource` if you'd like, which would only add two more matchers via `addMatcher`, and the traversal kind function (https://godbolt.org/z/GrfMTxeGa). IMO, this can be done in a follow-up by

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

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

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

2024-11-21 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti requested changes to this pull request. The check will currently not flag the use of literals like so: ```c++ void foo(unsigned short *uArray){ uArray[0] <= 10; } ``` https://godbolt.org/z/a6W9xGcMY because they do not contain an implicit cast. Only one of the tw

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

2024-11-21 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-11-21 Thread Julian Schmidt via cfe-commits
@@ -0,0 +1,34 @@ +.. 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-11-21 Thread Julian Schmidt via cfe-commits
@@ -0,0 +1,182 @@ +//===--- 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] Enhance modernize-use-starts-ends-with to handle substr patterns (PR #116033)

2024-11-21 Thread Julian Schmidt via cfe-commits
@@ -265,4 +255,63 @@ void test(std::string s, std::string_view sv, sub_string ss, sub_sub_string sss, s.compare(0, 1, "ab") == 0; s.rfind(suffix, 1) == s.size() - suffix.size(); + + #define STR(x) std::string(x) + 0 == STR(s).find("a"); + + #define STRING s + if (0 ==

[clang-tools-extra] [clang-tidy] Enhance modernize-use-starts-ends-with to handle substr patterns (PR #116033)

2024-11-21 Thread Julian Schmidt via cfe-commits
@@ -171,10 +182,26 @@ void UseStartsEndsWithCheck::registerMatchers(MatchFinder *Finder) { hasRHS(lengthExprForStringNode("needle") .bind("expr"), this); + + // Case 6: X.substr(0, LEN(Y)) [!=]= Y -> ends_with.

[clang-tools-extra] [clang-tidy] Enhance modernize-use-starts-ends-with to handle substr patterns (PR #116033)

2024-11-21 Thread Julian Schmidt via cfe-commits
@@ -183,40 +210,47 @@ void UseStartsEndsWithCheck::check(const MatchFinder::MatchResult &Result) { const auto *EndsWithFunction = Result.Nodes.getNodeAs("ends_with_fun"); assert(bool(StartsWithFunction) != bool(EndsWithFunction)); + const CXXMethodDecl *Replacemen

[clang-tools-extra] [clang-tidy] Enhance modernize-use-starts-ends-with to handle substr patterns (PR #116033)

2024-11-21 Thread Julian Schmidt via cfe-commits
@@ -240,6 +240,9 @@ void UseStartsEndsWithCheck::check(const MatchFinder::MatchResult &Result) { ReplacementFunction->getName()); // Replace arguments and everything after the function call. + if (FindExpr->getNumArgs() == 0) { +r

[clang-tools-extra] [clang-tidy] Add C++ member function support to custom bugprone-unsafe-functions matches (PR #117165)

2024-12-06 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti edited https://github.com/llvm/llvm-project/pull/117165 ___ 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 C++ member function support to custom bugprone-unsafe-functions matches (PR #117165)

2024-12-06 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti commented: The matching-on-members part looks good, but I don't know about adding the `ShowFullyQualifiedNames` option https://github.com/llvm/llvm-project/pull/117165 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[clang-tools-extra] [clang-tidy] Add C++ member function support to custom bugprone-unsafe-functions matches (PR #117165)

2024-12-06 Thread Julian Schmidt via cfe-commits
@@ -43,7 +43,10 @@ class UnsafeFunctionsCheck : public ClangTidyCheck { private: const std::vector CustomFunctions; - // If true, the default set of functions are reported. + /// If true, the fully qualified name of custom functions will be shown in a + /// note tag. + c

[clang-tools-extra] [clang-tidy][NFC] merge same part matchers in return-const-ref-from-parameter (PR #118985)

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

2024-12-06 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] Add readability-use-span-first-last check (PR #118074)

2024-12-06 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti commented: > wasting effort would not be the problem (it never is; learning is the goal) - > right now i just dont understand the difference, and therefore dont see the > benefit, as far as i see it would introduce more complicated code to still > handle templates.

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

2024-12-06 Thread Julian Schmidt via cfe-commits
5chmidti wrote: Please also add an `ASSERT_FALSE` (or just `ASSERT_TRUE(!opt.has_value())`) with a dereference after, to show that there are false-negatives https://github.com/llvm/llvm-project/pull/115051 ___ cfe-co

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

2024-12-06 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)

2024-12-06 Thread Julian Schmidt via cfe-commits
@@ -27,19 +29,44 @@ class UncheckedOptionalAccessCheck : public ClangTidyCheck { UncheckedOptionalAccessCheck(StringRef Name, ClangTidyContext *Context) : ClangTidyCheck(Name, Context), ModelOptions{ -Options.getLocalOrGlobal("IgnoreSmartPointerDeref

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

2024-12-06 Thread Julian Schmidt via cfe-commits
@@ -27,19 +29,44 @@ class UncheckedOptionalAccessCheck : public ClangTidyCheck { UncheckedOptionalAccessCheck(StringRef Name, ClangTidyContext *Context) : ClangTidyCheck(Name, Context), ModelOptions{ -Options.getLocalOrGlobal("IgnoreSmartPointerDeref

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

2024-12-06 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti commented: > option that is off by default. For all other users the behavior is unchanged, > but we can opt in on our side. > Can we add the option to use in the meantime, while I work on the macro > handling in parallel? That sounds okay to me, even though the opti

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

2024-12-06 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] Add readability-use-span-first-last check (PR #118074)

2024-12-06 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] Add C++ member function support to custom bugprone-unsafe-functions matches (PR #117165)

2025-01-09 Thread Julian Schmidt via cfe-commits
@@ -139,6 +150,12 @@ Options function, and an optional reason, separated by comma. For more information, see :ref:`Custom functions`. +.. option:: ShowFullyQualifiedNames + +When `true`, the fully qualified name of all functions matched by the custom +function

[clang-tools-extra] [clang-tidy] Add C++ member function support to custom bugprone-unsafe-functions matches (PR #117165)

2025-01-09 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti approved this pull request. https://github.com/llvm/llvm-project/pull/117165 ___ 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] optimize cache for config option (PR #121406)

2025-01-09 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti edited https://github.com/llvm/llvm-project/pull/121406 ___ 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] optimize cache for config option (PR #121406)

2025-01-09 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/121406 ___ 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] optimize cache for config option (PR #121406)

2025-01-09 Thread Julian Schmidt via cfe-commits
@@ -337,33 +337,34 @@ FileOptionsBaseProvider::FileOptionsBaseProvider( void FileOptionsBaseProvider::addRawFileOptions( llvm::StringRef AbsolutePath, std::vector &CurOptions) { auto CurSize = CurOptions.size(); - // Look for a suitable configuration file in all parent

[clang] [mutation analyzer] support mutation analysis for pointee (PR #118593)

2025-01-21 Thread Julian Schmidt via cfe-commits
@@ -654,6 +716,83 @@ ExprMutationAnalyzer::Analyzer::findFunctionArgMutation(const Expr *Exp) { return nullptr; } +const Stmt * +ExprMutationAnalyzer::Analyzer::findPointeeValueMutation(const Expr *Exp) { + const auto Matches = match( + stmt(forEachDescendant( +

[clang] [mutation analyzer] support mutation analysis for pointee (PR #118593)

2025-01-21 Thread Julian Schmidt via cfe-commits
@@ -654,6 +716,83 @@ ExprMutationAnalyzer::Analyzer::findFunctionArgMutation(const Expr *Exp) { return nullptr; } +const Stmt * +ExprMutationAnalyzer::Analyzer::findPointeeValueMutation(const Expr *Exp) { + const auto Matches = match( + stmt(forEachDescendant( +

[clang] [mutation analyzer] support mutation analysis for pointee (PR #118593)

2025-01-21 Thread Julian Schmidt via cfe-commits
@@ -112,6 +115,57 @@ AST_MATCHER_P(Stmt, canResolveToExpr, const Stmt *, Inner) { return canExprResolveTo(Exp, Target); } +// use class member to store data can reduce stack usage to avoid stack overflow +// when recursive call. +class ExprPointeeResolve { + const Expr *T

[clang] [mutation analyzer] support mutation analysis for pointee (PR #118593)

2025-01-21 Thread Julian Schmidt via cfe-commits
@@ -112,6 +115,57 @@ AST_MATCHER_P(Stmt, canResolveToExpr, const Stmt *, Inner) { return canExprResolveTo(Exp, Target); } +// use class member to store data can reduce stack usage to avoid stack overflow +// when recursive call. +class ExprPointeeResolve { + const Expr *T

[clang] [mutation analyzer] support mutation analysis for pointee (PR #118593)

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

[clang] [mutation analyzer] support mutation analysis for pointee (PR #118593)

2025-01-21 Thread Julian Schmidt via cfe-commits
@@ -654,6 +716,83 @@ ExprMutationAnalyzer::Analyzer::findFunctionArgMutation(const Expr *Exp) { return nullptr; } +const Stmt * +ExprMutationAnalyzer::Analyzer::findPointeeValueMutation(const Expr *Exp) { + const auto Matches = match( + stmt(forEachDescendant( +

[clang] [mutation analyzer] support mutation analysis for pointee (PR #118593)

2025-01-21 Thread Julian Schmidt via cfe-commits
@@ -654,6 +716,83 @@ ExprMutationAnalyzer::Analyzer::findFunctionArgMutation(const Expr *Exp) { return nullptr; } +const Stmt * +ExprMutationAnalyzer::Analyzer::findPointeeValueMutation(const Expr *Exp) { + const auto Matches = match( + stmt(forEachDescendant( +

[clang] [mutation analyzer] support mutation analysis for pointee (PR #118593)

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

[clang] [mutation analyzer] support mutation analysis for pointee (PR #118593)

2025-01-21 Thread Julian Schmidt via cfe-commits
@@ -1609,4 +1610,349 @@ TEST(ExprMutationAnalyzerTest, ReproduceFailureMinimal) { match(withEnclosingCompound(declRefTo("x")), AST11->getASTContext()); EXPECT_FALSE(isMutated(Results11, AST11.get())); } + +static bool isPointeeMutated(const SmallVectorImpl &Results, +

[clang] [mutation analyzer] support mutation analysis for pointee (PR #118593)

2025-01-21 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti commented: Looks good in general, could you add a small description to the pr? https://github.com/llvm/llvm-project/pull/118593 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/l

[clang-tools-extra] [clang-tidy] Add readability-string-view-substr check (PR #120055)

2025-01-13 Thread Julian Schmidt via cfe-commits
@@ -0,0 +1,217 @@ +//===--- StringViewSubstrCheck.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-string-view-substr check (PR #120055)

2025-01-13 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti commented: You can move even more into the matchers. Here is a mock-up of what I mean (untested): ``` m cxxMemberCallExpr( anyOf( cxxMemberCallExpr( argumentCountIs(1) # is substr, and bind arg 1 ), cxxMemberCallExpr( argumentCoun

[clang-tools-extra] [clang-tidy] Add readability-string-view-substr check (PR #120055)

2025-01-13 Thread Julian Schmidt via cfe-commits
@@ -0,0 +1,217 @@ +//===--- StringViewSubstrCheck.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-string-view-substr check (PR #120055)

2025-01-13 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti edited https://github.com/llvm/llvm-project/pull/120055 ___ 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-23 Thread Julian Schmidt via cfe-commits
5chmidti wrote: > but now templates seem to be skipped completely Template instantiations are skipped, not their definition. The matchers no longer work, because the types you are working with are no longer necessarily concrete types, but instead they can be dependent. And so can be expression

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

2024-12-21 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti closed 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-internal-linkage] fix false positive for consteval function (PR #122141)

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

[clang-tools-extra] [clang-tidy] Switch misc-confusable-identifiers check to a faster algorithm. (PR #130369)

2025-06-19 Thread Julian Schmidt via cfe-commits
@@ -181,42 +160,105 @@ void ConfusableIdentifierCheck::check( if (!ND) return; - IdentifierInfo *NDII = ND->getIdentifier(); + addDeclToCheck(ND, cast(ND->getDeclContext() +->getNonTransparentContext())); + + // Associate template p

[clang-tools-extra] [clang-tidy] Switch misc-confusable-identifiers check to a faster algorithm. (PR #130369)

2025-06-19 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti approved this pull request. LGTM. Thanks for the quite big performance improvement, and sorry this took a bit until it was reviewed. https://github.com/llvm/llvm-project/pull/130369 ___ cfe-commits mailing list cfe-commits@

[clang-tools-extra] [clang-tidy] Switch misc-confusable-identifiers check to a faster algorithm. (PR #130369)

2025-06-19 Thread Julian Schmidt via cfe-commits
@@ -181,42 +160,105 @@ void ConfusableIdentifierCheck::check( if (!ND) return; - IdentifierInfo *NDII = ND->getIdentifier(); + addDeclToCheck(ND, cast(ND->getDeclContext() +->getNonTransparentContext())); + + // Associate template p

[clang-tools-extra] [clang-tidy] Switch misc-confusable-identifiers check to a faster algorithm. (PR #130369)

2025-06-19 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti edited https://github.com/llvm/llvm-project/pull/130369 ___ 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 `performance-explicit-move-constructor` check (PR #122599)

2025-06-20 Thread Julian Schmidt via cfe-commits
5chmidti wrote: > > but this check could check the signatures themselves to be in the expected > > form > > So warning for signatures like `foo(foo&) = default`? Looking at this again, maybe this shouldn't not that route. Other checks already capture some of those problems. What @PiotrZSL me

[clang-tools-extra] [clang-tidy] Add `performance-explicit-move-constructor` check (PR #122599)

2025-06-20 Thread Julian Schmidt via cfe-commits
@@ -0,0 +1,32 @@ +.. title:: clang-tidy - performance-explicit-move-constructor + +performance-explicit-move-constructor += + +Warns when a class defines an explicit move constructor, which may cause +the copy constructor to get called instead.

[clang-tools-extra] [clang-tidy] Add new check `llvm-prefer-static-over-anonymous-namespace` (PR #142839)

2025-06-20 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti approved this pull request. Alright, that makes sense to me. LGTM minus open comments https://github.com/llvm/llvm-project/pull/142839 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/ma

[clang-tools-extra] [clang-tidy] Add new check `llvm-prefer-static-over-anonymous-namespace` (PR #142839)

2025-06-20 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti edited https://github.com/llvm/llvm-project/pull/142839 ___ 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 new check `llvm-prefer-static-over-anonymous-namespace` (PR #142839)

2025-06-20 Thread Julian Schmidt via cfe-commits
@@ -0,0 +1,73 @@ +.. title:: clang-tidy - llvm-prefer-static-over-anonymous-namespace + +llvm-prefer-static-over-anonymous-namespace +=== + +Finds function and variable declarations inside anonymous namespace and +suggests replacing them wit

<    8   9   10   11   12   13   14   >