[clang-tools-extra] [clang-tidy] rewrite matchers in modernize-use-starts-ends-with (PR #112101)

2024-10-12 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank edited https://github.com/llvm/llvm-project/pull/112101 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy] rewrite matchers in modernize-use-starts-ends-with (PR #112101)

2024-10-12 Thread Nicolas van Kempen via cfe-commits
@@ -9,8 +9,10 @@ #include "UseStartsEndsWithCheck.h" #include "../utils/ASTUtils.h" -#include "../utils/OptionsUtils.h" +#include "../utils/Matchers.h" +#include "clang/ASTMatchers/ASTMatchers.h" #include "clang/Lex/Lexer.h" +#include "llvm/ADT/ArrayRef.h" ni

[clang-tools-extra] [clang-tidy] [docs] Replace _not_ in reserved-identifier.rst with *not* (PR #112162)

2024-10-14 Thread Nicolas van Kempen via cfe-commits
nicovank wrote: Rebase past 3484ed9325f30b56717a1b939af4c58dd07848e0 for green CI. https://github.com/llvm/llvm-project/pull/112162 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy] rewrite matchers in modernize-use-starts-ends-with (PR #112101)

2024-10-12 Thread Nicolas van Kempen via cfe-commits
@@ -82,34 +84,25 @@ UseStartsEndsWithCheck::UseStartsEndsWithCheck(StringRef Name, void UseStartsEndsWithCheck::registerMatchers(MatchFinder *Finder) { const auto ZeroLiteral = integerLiteral(equals(0)); - const auto HasStartsWithMethodWithName = [](const std::string &Name

[clang-tools-extra] [clang-tidy] rewrite matchers in modernize-use-starts-ends-with (PR #112101)

2024-10-12 Thread Nicolas van Kempen via cfe-commits
@@ -82,34 +84,25 @@ UseStartsEndsWithCheck::UseStartsEndsWithCheck(StringRef Name, void UseStartsEndsWithCheck::registerMatchers(MatchFinder *Finder) { const auto ZeroLiteral = integerLiteral(equals(0)); - const auto HasStartsWithMethodWithName = [](const std::string &Name

[clang-tools-extra] [clang-tidy] rewrite matchers in modernize-use-starts-ends-with (PR #112101)

2024-10-12 Thread Nicolas van Kempen via cfe-commits
@@ -150,8 +150,8 @@ void test(std::string s, std::string_view sv, sub_string ss, sub_sub_string sss, // CHECK-FIXES: puv.starts_with("a"); puvf.find("a") == 0; - // CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: use starts_with - // CHECK-FIXES: puvf.starts_with("a")

[clang-tools-extra] [llvm] [llvm] add support for mustache templating language (PR #105893)

2024-10-09 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank commented: I like Mustache! Just took a quick look at this following your Discourse post. Do the custom allocators make any significant performance difference (measure)? Wouldn't want to prematurely optimize. They're the kind of thing that make maintenance annoying

[clang-tools-extra] [clang-tidy][performance-move-const-arg] Fix crash when argument type has no definition (PR #111472)

2024-10-09 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank closed https://github.com/llvm/llvm-project/pull/111472 ___ 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] Add type annotations to rename_check.py (PR #108443)

2024-10-09 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank closed https://github.com/llvm/llvm-project/pull/108443 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy][modernize-use-starts-ends-with] Add support for two ends_with patterns (PR #110448)

2024-10-11 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank closed https://github.com/llvm/llvm-project/pull/110448 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy][modernize-use-starts-ends-with] Add support for two ends_with patterns (PR #110448)

2024-10-11 Thread Nicolas van Kempen via cfe-commits
nicovank wrote: Sounds good, thanks! I will go ahead and rebase and merge this. https://github.com/llvm/llvm-project/pull/110448 ___ 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 performance-expensive-flat-container-operation check (PR #112051)

2024-10-11 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank created https://github.com/llvm/llvm-project/pull/112051 Summary: Test Plan: >From 9b2953abd81dab3349a656544c916fe101508ff2 Mon Sep 17 00:00:00 2001 From: Nicolas van Kempen Date: Fri, 11 Oct 2024 17:45:35 -0400 Subject: [PATCH] [clang-tidy] Add new performance

[clang-tools-extra] [clang-tidy] Add new performance-expensive-flat-container-operation check (PR #112051)

2024-10-11 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank edited https://github.com/llvm/llvm-project/pull/112051 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy][modernize-use-starts-ends-with] Add support for two ends_with patterns (PR #110448)

2024-10-11 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank updated https://github.com/llvm/llvm-project/pull/110448 >From 028d68178748806ce2318360260bdc1833b4f2b3 Mon Sep 17 00:00:00 2001 From: Nicolas van Kempen Date: Fri, 11 Oct 2024 17:44:47 -0400 Subject: [PATCH] [clang-tidy][modernize-use-starts-ends-with] Add support f

[clang-tools-extra] [clang-tidy] Add new performance-expensive-flat-container-operation check (PR #112051)

2024-10-11 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank closed https://github.com/llvm/llvm-project/pull/112051 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy][modernize-use-starts-ends-with] Add support for two ends_with patterns (PR #110448)

2024-10-11 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank updated https://github.com/llvm/llvm-project/pull/110448 >From 028d68178748806ce2318360260bdc1833b4f2b3 Mon Sep 17 00:00:00 2001 From: Nicolas van Kempen Date: Fri, 11 Oct 2024 17:44:47 -0400 Subject: [PATCH] [clang-tidy][modernize-use-starts-ends-with] Add support f

[clang-tools-extra] [clang-tidy][modernize-use-starts-ends-with] Add support for two ends_with patterns (PR #105366)

2024-09-29 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank closed https://github.com/llvm/llvm-project/pull/105366 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy][modernize-use-starts-ends-with] Add support for two ends_with patterns (PR #110448)

2024-09-29 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank created https://github.com/llvm/llvm-project/pull/110448 Add support for the following two patterns: ``` haystack.compare(haystack.length() - needle.length(), needle.length(), needle) == 0; haystack.rfind(needle) == (haystack.size() - needle.size()); ``` >From 7f0

[clang-tools-extra] [clang-tidy][modernize-use-starts-ends-with] Add support for two ends_with patterns (PR #110448)

2024-09-29 Thread Nicolas van Kempen via cfe-commits
nicovank wrote: Oops, for this reason my software duplicated #105366 when I meant to just rebase and ping. Sorry. Closing the old one. https://github.com/llvm/llvm-project/pull/110448 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lis

[clang-tools-extra] [clang-tidy][NFC] optimize unused using decls performance (PR #110200)

2024-09-29 Thread Nicolas van Kempen via cfe-commits
@@ -25,6 +25,13 @@ AST_MATCHER_P(DeducedTemplateSpecializationType, refsToTemplatedDecl, return false; } +AST_MATCHER_P(Type, getTagDecl, clang::ast_matchers::internal::Matcher, nicovank wrote: `asTagDecl` maybe? https://github.com/llvm/llvm-project/pull

[clang-tools-extra] [clang-tidy][NFC] optimize unused using decls performance (PR #110200)

2024-09-29 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank approved this pull request. https://github.com/llvm/llvm-project/pull/110200 ___ 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 `P +- BS / sizeof(*P)` opt-outable in `bugprone-sizeof-expression` (PR #111178)

2024-10-05 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank approved this pull request. LGTM, nits. Maybe give a bit of time for others to take a look. https://github.com/llvm/llvm-project/pull/78 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-

[clang-tools-extra] [clang-tidy] Make `P +- BS / sizeof(*P)` opt-outable in `bugprone-sizeof-expression` (PR #111178)

2024-10-05 Thread Nicolas van Kempen via cfe-commits
@@ -0,0 +1,12 @@ +// RUN: %check_clang_tidy %s bugprone-sizeof-expression %t -- \ +// RUN: -config="{CheckOptions: [{key: bugprone-sizeof-expression.WarnOnSizeOfPointerArithmeticWithDivisionScaled, value: 0}]}" nicovank wrote: ```suggestion // RUN: %check_cla

[clang-tools-extra] [clang-tidy] Make `P +- BS / sizeof(*P)` opt-outable in `bugprone-sizeof-expression` (PR #111178)

2024-10-05 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank edited https://github.com/llvm/llvm-project/pull/78 ___ 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 `P +- BS / sizeof(*P)` opt-outable in `bugprone-sizeof-expression` (PR #111178)

2024-10-05 Thread Nicolas van Kempen via cfe-commits
@@ -306,8 +310,13 @@ void SizeofExpressionCheck::registerMatchers(MatchFinder *Finder) { unaryExprOrTypeTraitExpr(ofKind(UETT_AlignOf)), offsetOfExpr())) .bind("sizeof-in-ptr-arithmetic-scale-expr"); + const auto PtrArithmeticIntege

[clang-tools-extra] [clang-tidy] Make `P +- BS / sizeof(*P)` opt-outable in `bugprone-sizeof-expression` (PR #111178)

2024-10-05 Thread Nicolas van Kempen via cfe-commits
@@ -31,6 +31,7 @@ class SizeofExpressionCheck : public ClangTidyCheck { const bool WarnOnSizeOfCompareToConstant; const bool WarnOnSizeOfPointerToAggregate; const bool WarnOnSizeOfPointer; + const bool WarnOnSizeOfPointerArithmeticWithDivisionScaled; nic

[clang-tools-extra] [clang-tidy][performance-move-const-arg] Fix crash when argument type has no definition (PR #111472)

2024-10-07 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank updated https://github.com/llvm/llvm-project/pull/111472 >From 4936acf06c30c1e9a3a300ec712845a4c56d5cd0 Mon Sep 17 00:00:00 2001 From: Nicolas van Kempen Date: Mon, 7 Oct 2024 23:08:44 -0400 Subject: [PATCH] [clang-tidy][performance-move-const-arg] Fix crash when ar

[clang-tools-extra] [clang-tidy][performance-move-const-arg] Fix crash when argument type has no definition (PR #111472)

2024-10-07 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank updated https://github.com/llvm/llvm-project/pull/111472 >From 4936acf06c30c1e9a3a300ec712845a4c56d5cd0 Mon Sep 17 00:00:00 2001 From: Nicolas van Kempen Date: Mon, 7 Oct 2024 23:08:44 -0400 Subject: [PATCH] [clang-tidy][performance-move-const-arg] Fix crash when ar

[clang-tools-extra] [clang-tidy][performance-move-const-arg] Fix crash when argument type has no definition (PR #111472)

2024-10-07 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank created https://github.com/llvm/llvm-project/pull/111472 Fix #111450. When the argument type is forward-declared and there is no definition, `hasMoveConstructor` triggers the assert here: https://github.com/llvm-project/llvm-project/blob/7f65377880ce6a0e5eaa4cb2591

[clang-tools-extra] [clang-tidy][performance-move-const-arg] Fix crash when argument type has no definition (PR #111472)

2024-10-07 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank updated https://github.com/llvm/llvm-project/pull/111472 >From a321d32fd8f2d2ee2c760f7530dd5d9c6e7d4f00 Mon Sep 17 00:00:00 2001 From: Nicolas van Kempen Date: Mon, 7 Oct 2024 23:16:19 -0400 Subject: [PATCH] [clang-tidy][performance-move-const-arg] Fix crash when ar

[clang-tools-extra] [clang-tidy][performance-move-const-arg] Fix crash when argument type has no definition (PR #111472)

2024-10-07 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank updated https://github.com/llvm/llvm-project/pull/111472 >From a321d32fd8f2d2ee2c760f7530dd5d9c6e7d4f00 Mon Sep 17 00:00:00 2001 From: Nicolas van Kempen Date: Mon, 7 Oct 2024 23:16:19 -0400 Subject: [PATCH] [clang-tidy][performance-move-const-arg] Fix crash when ar

[clang-tools-extra] [clang-tidy] Fix for cppcoreguidelines-pro-type-union-access if memLoc is invalid (PR #104540)

2024-10-21 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank edited https://github.com/llvm/llvm-project/pull/104540 ___ 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 for cppcoreguidelines-pro-type-union-access if memLoc is invalid (PR #104540)

2024-10-21 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank approved this pull request. LGTM! Minus alphabetical ordering in release notes. I'll merge this tomorrow to give time to others just in case. FWIW this issue actually triggers a crash/assertion failure when those are enabled: ``` clang-tidy: clang-tools-extra/clang-

[clang-tools-extra] [clang-tidy] Fix for cppcoreguidelines-pro-type-union-access if memLoc is invalid (PR #104540)

2024-10-21 Thread Nicolas van Kempen via cfe-commits
@@ -141,6 +141,10 @@ New check aliases Changes in existing checks ^^ +- Fixed :doc:`cppcoreguidelines-pro-type-union-access + ` check to + report a location even when the member location is not valid. nicovank wrote: Order alphabetic

[clang-tools-extra] [clang-tidy] Fix for cppcoreguidelines-pro-type-union-access if memLoc is invalid (PR #104540)

2024-10-21 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank updated https://github.com/llvm/llvm-project/pull/104540 >From 31ed1cf97be643b3a6c9a05d4e461789c37e2408 Mon Sep 17 00:00:00 2001 From: Konstantin Romanov Date: Fri, 9 Aug 2024 23:40:07 -0400 Subject: [PATCH 1/7] Workaround for cppcoreguidelines-pro-type-union-access

[clang-tools-extra] [clang-tidy] Fix for cppcoreguidelines-pro-type-union-access if memLoc is invalid (PR #104540)

2024-10-21 Thread Nicolas van Kempen via cfe-commits
nicovank wrote: There's a CI failure but looks unrelated. If you have a minute please rebase/merge main to trigger the checks again and hopefully the problem disappears. We can also just keep an eye on the buildbots post-merge tomorrow. https://github.com/llvm/llvm-project/pull/104540

[clang-tools-extra] [clang-tidy][readability-container-contains] Fix matching of non-binaryOperator cases (PR #110386)

2024-10-21 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank updated https://github.com/llvm/llvm-project/pull/110386 >From e1dc2f848ee74fbd2775c4943c6bf03990f7c164 Mon Sep 17 00:00:00 2001 From: Nicolas van Kempen Date: Sun, 29 Sep 2024 14:05:33 -0400 Subject: [PATCH] [clang-tidy][readability-container-contains] Fix matching

[clang-tools-extra] [clang-tidy] support string::contains (PR #110351)

2024-10-05 Thread Nicolas van Kempen via cfe-commits
@@ -30,9 +32,15 @@ void ContainerContainsCheck::registerMatchers(MatchFinder *Finder) { ofClass(cxxRecordDecl(HasContainsMatchingParamType) .bind("call"); + const auto Literal0 = integerLiteral(equals(0)); + const auto Literal1 = integerLiteral(e

[clang-tools-extra] [clang-tidy] support string::contains (PR #110351)

2024-10-05 Thread Nicolas van Kempen via cfe-commits
@@ -50,12 +50,16 @@ struct basic_string { size_type find(const _Type& str, size_type pos = 0) const; size_type find(const C* s, size_type pos = 0) const; size_type find(const C* s, size_type pos, size_type n) const; + size_type find(C ch, size_type pos = 0) const; s

[clang-tools-extra] [clang-tidy] support string::contains (PR #110351)

2024-10-05 Thread Nicolas van Kempen via cfe-commits
@@ -453,3 +458,29 @@ 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 testStringNops(std::string St

[clang-tools-extra] [clang-tidy] support string::contains (PR #110351)

2024-10-05 Thread Nicolas van Kempen via cfe-commits
@@ -32,7 +33,8 @@ void ContainerContainsCheck::registerMatchers(MatchFinder *Finder) { const auto FindCall = cxxMemberCallExpr( - argumentCountIs(1), + anyOf(argumentCountIs(1), +allOf(argumentCountIs(2), hasArgument(1, cxxDefaultArg

[clang-tools-extra] [clang-tidy] support string::contains (PR #110351)

2024-10-05 Thread Nicolas van Kempen via cfe-commits
@@ -50,12 +50,16 @@ struct basic_string { size_type find(const _Type& str, size_type pos = 0) const; size_type find(const C* s, size_type pos = 0) const; size_type find(const C* s, size_type pos, size_type n) const; + size_type find(C ch, size_type pos = 0) const; --

[clang-tools-extra] [clang-tidy] support string::contains (PR #110351)

2024-10-05 Thread Nicolas van Kempen via cfe-commits
@@ -104,6 +108,9 @@ struct basic_string_view { size_type rfind(const C* s, size_type pos, size_type count) const; size_type rfind(const C* s, size_type pos = npos) const; + bool contains(const C *s) const; + bool contains(C s) const; nicovank wrote: ```

[clang-tools-extra] [clang-tidy] support string::contains (PR #110351)

2024-10-05 Thread Nicolas van Kempen via cfe-commits
@@ -29,6 +29,43 @@ struct multimap { bool contains(const Key &K) const; }; +using size_t = decltype(sizeof(int)); + +// Lightweight standin for std::string_view. +template +class basic_string_view { +public: + basic_string_view(); + basic_string_view(const basic_string_vi

[clang-tools-extra] [clang-tidy] support string::contains (PR #110351)

2024-10-05 Thread Nicolas van Kempen via cfe-commits
nicovank wrote: Thanks! Is there still an issue with type stuff? If so, what would be a test case that fails that shouldn't? https://github.com/llvm/llvm-project/pull/110351 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.or

[clang-tools-extra] [clang-tidy] Fix for cppcoreguidelines-pro-type-union-access if memLoc is invalid (PR #104540)

2024-10-22 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank closed https://github.com/llvm/llvm-project/pull/104540 ___ 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 crash in modernize-use-designated-initializers check (PR #113688)

2024-10-29 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank closed https://github.com/llvm/llvm-project/pull/113688 ___ 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 crash in modernize-use-designated-initializers check (PR #113688)

2024-10-29 Thread Nicolas van Kempen via cfe-commits
nicovank wrote: @z1nke I will go ahead and click the merge button. Thanks! https://github.com/llvm/llvm-project/pull/113688 ___ 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 crash in modernize-use-designated-initializers check (PR #113688)

2024-10-28 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank edited https://github.com/llvm/llvm-project/pull/113688 ___ 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 crash in modernize-use-designated-initializers check (PR #113688)

2024-10-27 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank approved this pull request. Looking at it again, this way is also good, no preference. Good to merge 👍 https://github.com/llvm/llvm-project/pull/113688 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.l

[clang-tools-extra] [clang-tidy][readability-container-contains] Fix matching of non-binaryOperator cases (PR #110386)

2024-10-23 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank closed https://github.com/llvm/llvm-project/pull/110386 ___ 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 string::contains (PR #110351)

2024-10-23 Thread Nicolas van Kempen via cfe-commits
nicovank wrote: FYI I'm going to merge #110386 now which will cause conflicts (`binaryOperator` -> `binaryOperation`). https://github.com/llvm/llvm-project/pull/110351 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-

[clang-tools-extra] [clang-tidy] Add modernize-substr-to-starts-with check (PR #116033)

2024-11-13 Thread Nicolas van Kempen via cfe-commits
nicovank wrote: FWIW I think it's a good idea in modernize-use-starts-ends-with documentation to use a table as in [readability-container-contains](https://clang.llvm.org/extra/clang-tidy/checks/readability/container-contains.html). Here is a table with the c

[clang-tools-extra] Add bugprone-undefined-sprintf-overlap (PR #114244)

2024-11-09 Thread Nicolas van Kempen via cfe-commits
@@ -0,0 +1,82 @@ +//===--- UndefinedSprintfOverlapCheck.cpp - clang-tidy ===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apa

[clang-tools-extra] Add bugprone-undefined-sprintf-overlap (PR #114244)

2024-11-09 Thread Nicolas van Kempen via cfe-commits
@@ -0,0 +1,36 @@ +//===--- UndefinedSprintfOverlapCheck.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] Add bugprone-undefined-sprintf-overlap (PR #114244)

2024-11-09 Thread Nicolas van Kempen via cfe-commits
@@ -0,0 +1,82 @@ +//===--- UndefinedSprintfOverlapCheck.cpp - clang-tidy ===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apa

[clang-tools-extra] Add bugprone-undefined-sprintf-overlap (PR #114244)

2024-11-09 Thread Nicolas van Kempen via cfe-commits
@@ -0,0 +1,59 @@ +// RUN: %check_clang_tidy %s bugprone-undefined-sprintf-overlap %t + +using size_t = decltype(sizeof(int)); + +extern "C" int sprintf(char *s, const char *format, ...); +extern "C" int snprintf(char *s, size_t n, const char *format, ...); + +namespace std { + in

[clang-tools-extra] Add bugprone-undefined-sprintf-overlap (PR #114244)

2024-11-09 Thread Nicolas van Kempen via cfe-commits
@@ -0,0 +1,82 @@ +//===--- UndefinedSprintfOverlapCheck.cpp - clang-tidy ===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apa

[clang-tools-extra] Add bugprone-undefined-sprintf-overlap (PR #114244)

2024-11-09 Thread Nicolas van Kempen via cfe-commits
@@ -0,0 +1,82 @@ +//===--- UndefinedSprintfOverlapCheck.cpp - clang-tidy ===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apa

[clang-tools-extra] Add bugprone-undefined-sprintf-overlap (PR #114244)

2024-11-09 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank commented: I have questions regarding the motivation behind adding this check: 1. How common is this bug? 2. What happens in practice at runtime? 3. What are existing ways of detecting this, if any? https://github.com/llvm/llvm-project/pull/114244 _

[clang-tools-extra] Add bugprone-undefined-sprintf-overlap (PR #114244)

2024-11-09 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank edited https://github.com/llvm/llvm-project/pull/114244 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] Add bugprone-undefined-sprintf-overlap (PR #114244)

2024-11-09 Thread Nicolas van Kempen via cfe-commits
@@ -0,0 +1,23 @@ +.. title:: clang-tidy - bugprone-undefined-sprintf-overlap + +bugprone-undefined-sprintf-overlap +== + +Warns if any arguments to the ``sprintf`` family of functions overlap with the +first argument. + +.. code-block:: c++ + +c

[clang-tools-extra] Add bugprone-undefined-sprintf-overlap (PR #114244)

2024-11-09 Thread Nicolas van Kempen via cfe-commits
@@ -0,0 +1,23 @@ +.. title:: clang-tidy - bugprone-undefined-sprintf-overlap + +bugprone-undefined-sprintf-overlap nicovank wrote: Just to throw another option out there, `bugprone-sprintf-argument-overlap`. Others might have opinions. https://github.com/llvm/l

[clang-tools-extra] Add bugprone-undefined-sprintf-overlap (PR #114244)

2024-11-09 Thread Nicolas van Kempen via cfe-commits
@@ -153,6 +153,7 @@ Clang-Tidy Checks :doc:`bugprone-too-small-loop-variable `, :doc:`bugprone-unchecked-optional-access `, :doc:`bugprone-undefined-memory-manipulation `, + :doc:`bugprone-undefined-sprintf-overlap `, "Yes" nicovank wrote: ```sug

[clang-tools-extra] Add bugprone-undefined-sprintf-overlap (PR #114244)

2024-11-09 Thread Nicolas van Kempen via cfe-commits
nicovank wrote: Oops, crossed signals with @5chmidti. Hopefully not too much overlap sorry. https://github.com/llvm/llvm-project/pull/114244 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-com

[clang-tools-extra] Add bugprone-undefined-sprintf-overlap (PR #114244)

2024-11-09 Thread Nicolas van Kempen via cfe-commits
@@ -0,0 +1,36 @@ +//===--- UndefinedSprintfOverlapCheck.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] Add bugprone-undefined-sprintf-overlap (PR #114244)

2024-11-09 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank edited https://github.com/llvm/llvm-project/pull/114244 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy][readability-container-contains] Extend to any class with contains (PR #107521)

2024-09-18 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank closed https://github.com/llvm/llvm-project/pull/107521 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy][readability-container-contains] Use hasOperands when possible (PR #109178)

2024-09-18 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank created https://github.com/llvm/llvm-project/pull/109178 Simplifies two cases and matches two new cases previously missing, `container.end() [!=]= container.find(...)`. I had split this change from #107521 for easier review. >From a8b8ce089e9eeadf1b8b424e426f7372

[clang] [clang-tools-extra] [clang-tidy] Add support for bsl::optional (PR #101450)

2024-09-24 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank edited https://github.com/llvm/llvm-project/pull/101450 ___ 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] Add support for bsl::optional (PR #101450)

2024-09-24 Thread Nicolas van Kempen via cfe-commits
@@ -0,0 +1,38 @@ +#ifndef LLVM_CLANG_TOOLS_EXTRA_TEST_CLANG_TIDY_CHECKERS_INPUTS_BDE_TYPES_NULLABLEVALUE_H_ +#define LLVM_CLANG_TOOLS_EXTRA_TEST_CLANG_TIDY_CHECKERS_INPUTS_BDE_TYPES_NULLABLEVALUE_H_ + +#include "bsl_optional.h" + +/// Mock of `bdbl::NullableValue`. -

[clang] [clang-tools-extra] [clang-tidy] Add support for bsl::optional (PR #101450)

2024-09-24 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank approved this pull request. LGTM. Rebase to fix release notes conflict and I'll merge 👍 https://github.com/llvm/llvm-project/pull/101450 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin

[clang-tools-extra] [clang-tidy] support string::contains (PR #110351)

2024-09-28 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank commented: IMO no need to update release notes: > Improved `readability-container-contains` check to let it work on any class > that has a contains method. But I think an example should be added to [the check documentation](https://github.com/llvm/llvm-project/blob

[clang-tools-extra] [clang-tidy] support string::contains (PR #110351)

2024-09-28 Thread Nicolas van Kempen via cfe-commits
@@ -51,6 +53,12 @@ void ContainerContainsCheck::registerMatchers(MatchFinder *Finder) { const auto Literal0 = integerLiteral(equals(0)); const auto Literal1 = integerLiteral(equals(1)); + const auto StringLikeClass = cxxRecordDecl( + hasAnyName("::std::basic_string"

[clang-tools-extra] [clang-tidy] support string::contains (PR #110351)

2024-09-28 Thread Nicolas van Kempen via cfe-commits
@@ -29,6 +29,43 @@ struct multimap { bool contains(const Key &K) const; }; +using size_t = decltype(sizeof(int)); + +// Lightweight standin for std::string_view. +template +class basic_string_view { +public: + basic_string_view(); + basic_string_view(const basic_string_vi

[clang-tools-extra] [clang-tidy] support string::contains (PR #110351)

2024-09-28 Thread Nicolas van Kempen via cfe-commits
@@ -453,3 +490,15 @@ 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 testStringNops(std::string St

[clang-tools-extra] [clang-tidy] support string::contains (PR #110351)

2024-09-28 Thread Nicolas van Kempen via cfe-commits
@@ -94,12 +102,14 @@ void ContainerContainsCheck::registerMatchers(MatchFinder *Finder) { binaryOperator(hasLHS(Literal1), hasOperatorName(">"), hasRHS(CountCall)) .bind("negativeComparison")); - // Find membership tests based on `find() == end()`. + // Find

[clang-tools-extra] [clang-tidy] support string::contains (PR #110351)

2024-09-28 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank edited https://github.com/llvm/llvm-project/pull/110351 ___ 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 string::contains (PR #110351)

2024-09-28 Thread Nicolas van Kempen via cfe-commits
@@ -32,7 +33,8 @@ void ContainerContainsCheck::registerMatchers(MatchFinder *Finder) { const auto FindCall = cxxMemberCallExpr( - argumentCountIs(1), + anyOf(argumentCountIs(1), +allOf(argumentCountIs(2), hasArgument(1, cxxDefaultArg

[clang-tools-extra] [clang-tidy][readability-container-contains] Fix matching of non-binaryOperator cases (PR #110386)

2024-09-28 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank created https://github.com/llvm/llvm-project/pull/110386 Fix #79437. It works with non-mock `std::map`: ``` # All cases detailed in #79437. > cat tmp.cpp #include bool a(std::map &m, int key) { return m.find(key) != m.end(); } bool b(std::map &m, int key) { return

[clang-tools-extra] [clang-tidy][readability-container-contains] Fix matching of non-binaryOperator cases (PR #110386)

2024-09-29 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank updated https://github.com/llvm/llvm-project/pull/110386 >From e08eed95020b705f040ba55b70cf8d660b817618 Mon Sep 17 00:00:00 2001 From: Nicolas van Kempen Date: Sun, 29 Sep 2024 14:05:33 -0400 Subject: [PATCH] [clang-tidy][readability-container-contains] Fix matching

[clang-tools-extra] [clang-tidy][readability-container-contains] Fix matching of non-binaryOperator cases (PR #110386)

2024-09-29 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank updated https://github.com/llvm/llvm-project/pull/110386 >From e08eed95020b705f040ba55b70cf8d660b817618 Mon Sep 17 00:00:00 2001 From: Nicolas van Kempen Date: Sun, 29 Sep 2024 14:05:33 -0400 Subject: [PATCH] [clang-tidy][readability-container-contains] Fix matching

[clang] [clang-tools-extra] [clang-tidy] Fix performance-unnecessary-value-param (PR #109145)

2024-09-18 Thread Nicolas van Kempen via cfe-commits
nicovank wrote: This test is passing for me even when I revert `ExprMutationAnalyzer.h` changes. Is it standard library or setup specific? https://github.com/llvm/llvm-project/pull/109145 ___ cfe-commits mailing list

[clang] [clang-tools-extra] [clang-tidy] Fix performance-unnecessary-value-param (PR #109145)

2024-09-18 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank edited https://github.com/llvm/llvm-project/pull/109145 ___ 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] Fix performance-unnecessary-value-param (PR #109145)

2024-09-18 Thread Nicolas van Kempen via cfe-commits
nicovank wrote: Ha, TIL that `LLVM_ENABLE_ASSERTIONS` is only in `Debug` mode, not `RelWithDebInfo` which I use in my local build. I assume CI uses `Debug` so this is fine, just wanted to be sure something always breaks if ever this was changed again. Thanks!

[clang] [clang-tools-extra] [clang-tidy] Fix performance-unnecessary-value-param (PR #109145)

2024-09-18 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank approved this pull request. https://github.com/llvm/llvm-project/pull/109145 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy][readability-container-contains] Use hasOperands when possible (PR #109178)

2024-09-19 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank updated https://github.com/llvm/llvm-project/pull/109178 >From 3f5df5d8299a48fe0bf919cd2d52eaa195b1e8ce Mon Sep 17 00:00:00 2001 From: Nicolas van Kempen Date: Thu, 19 Sep 2024 12:35:47 -0400 Subject: [PATCH] [clang-tidy][readability-container-contains] Use hasOperan

[clang-tools-extra] [clang-tidy][readability-container-contains] Use hasOperands when possible (PR #109178)

2024-09-19 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank updated https://github.com/llvm/llvm-project/pull/109178 >From 3f5df5d8299a48fe0bf919cd2d52eaa195b1e8ce Mon Sep 17 00:00:00 2001 From: Nicolas van Kempen Date: Thu, 19 Sep 2024 12:35:47 -0400 Subject: [PATCH] [clang-tidy][readability-container-contains] Use hasOperan

[clang-tools-extra] [clang-tidy][readability-container-contains] Use hasOperands when possible (PR #109178)

2024-09-19 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank closed https://github.com/llvm/llvm-project/pull/109178 ___ 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] Add support for bsl::optional (PR #101450)

2024-09-25 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank closed https://github.com/llvm/llvm-project/pull/101450 ___ 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 crash in modernize-use-designated-initializers check (PR #113688)

2024-10-25 Thread Nicolas van Kempen via cfe-commits
nicovank wrote: I fixed a similar issue in 0aaac4fe194ae2249e1a01f9d6f5eac0d75c5bb2. There's an argument to be made whether this should be in the matchers (`isPOD`, `isAggregate` like here) versus an `hasDefinition` call in the parent before calling those matchers. I am slightly leaning toward

[clang-tools-extra] [clang-tidy] [docs] Replace _not_ in reserved-identifier.rst with *not* (PR #112162)

2024-10-17 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank closed https://github.com/llvm/llvm-project/pull/112162 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy][modernize-use-starts-ends-with] Fix operator rewriting false negative (PR #117837)

2024-11-27 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank closed https://github.com/llvm/llvm-project/pull/117837 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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

2024-11-18 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank commented: Looks good minus nits and IMO ignore any macro issues as commented. https://github.com/llvm/llvm-project/pull/116033 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/l

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

2024-11-18 Thread Nicolas van Kempen via cfe-commits
@@ -71,6 +71,17 @@ struct NotLengthExprForStringNode { ASTContext *Context; }; +static bool isNegativeComparison(const Expr *ComparisonExpr) { nicovank wrote: Nit: place above `NotLengthExprForStringNode` so `lengthExprForStringNode` and `NotLengthExprForS

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

2024-11-18 Thread Nicolas van Kempen via cfe-commits
@@ -183,40 +209,44 @@ 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][NFC] fix typo in ExceptionAnalyzer; `replace count()>0` with `contains` (PR #116635)

2024-11-18 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank approved this pull request. https://github.com/llvm/llvm-project/pull/116635 ___ 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] fix typo in ExceptionAnalyzer; `replace count()>0` with `contains` (PR #116635)

2024-11-18 Thread Nicolas van Kempen via cfe-commits
@@ -449,7 +449,8 @@ void ExceptionAnalyzer::ExceptionInfo::reevaluateBehaviour() { ExceptionAnalyzer::ExceptionInfo ExceptionAnalyzer::throwsException( const FunctionDecl *Func, const ExceptionInfo::Throwables &Caught, llvm::SmallSet &CallStack) { - if (!Func || CallS

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

2024-11-18 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank edited https://github.com/llvm/llvm-project/pull/116033 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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

2024-11-18 Thread Nicolas van Kempen via cfe-commits
@@ -183,40 +209,44 @@ void UseStartsEndsWithCheck::check(const MatchFinder::MatchResult &Result) { const auto *EndsWithFunction = Result.Nodes.getNodeAs("ends_with_fun"); assert(bool(StartsWithFunction) != bool(EndsWithFunction)); + const CXXMethodDecl *Replacemen

<    1   2   3   4   5   >