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

2025-01-14 Thread Nicolas van Kempen via cfe-commits
@@ -0,0 +1,785 @@ +//===-- Mustache.cpp --===// +// +// 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] [llvm] [llvm] add support for mustache templating language (PR #105893)

2025-01-13 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank commented: Some comments. Regarding usage of `std::string`: Right now the library takes a `StringRef` through `Template` and `Parser`, and then keeps (2-4?) copies of chunks of the input in `Token` (`RawBody` and `TokenBody`) then `ASTNode` (`RawBody` and `Body`).

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

2025-01-13 Thread Nicolas van Kempen via cfe-commits
@@ -0,0 +1,114 @@ +//===--- Mustache.h -*- 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] [llvm] [llvm] add support for mustache templating language (PR #105893)

2025-01-13 Thread Nicolas van Kempen via cfe-commits
@@ -0,0 +1,785 @@ +//===-- Mustache.cpp --===// +// +// 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] [llvm] [llvm] add support for mustache templating language (PR #105893)

2025-01-13 Thread Nicolas van Kempen via cfe-commits
nicovank wrote: I might have missed it but test re-using `Template` and rendering twice? https://github.com/llvm/llvm-project/pull/105893 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/

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

2025-01-13 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank edited https://github.com/llvm/llvm-project/pull/105893 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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

2025-01-13 Thread Nicolas van Kempen via cfe-commits
@@ -0,0 +1,785 @@ +//===-- Mustache.cpp --===// +// +// 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] [llvm] [llvm] add support for mustache templating language (PR #105893)

2025-01-13 Thread Nicolas van Kempen via cfe-commits
@@ -0,0 +1,785 @@ +//===-- Mustache.cpp --===// +// +// 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] [llvm] [llvm] add support for mustache templating language (PR #105893)

2025-01-13 Thread Nicolas van Kempen via cfe-commits
@@ -0,0 +1,114 @@ +//===--- Mustache.h -*- 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] [llvm] [llvm] add support for mustache templating language (PR #105893)

2025-01-13 Thread Nicolas van Kempen via cfe-commits
@@ -0,0 +1,785 @@ +//===-- Mustache.cpp --===// +// +// 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] [llvm] [llvm] add support for mustache templating language (PR #105893)

2025-01-13 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank edited https://github.com/llvm/llvm-project/pull/105893 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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

2025-01-13 Thread Nicolas van Kempen via cfe-commits
@@ -0,0 +1,114 @@ +//===--- Mustache.h -*- 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] [llvm] [llvm] add support for mustache templating language (PR #105893)

2025-01-13 Thread Nicolas van Kempen via cfe-commits
@@ -0,0 +1,114 @@ +//===--- Mustache.h -*- 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] [llvm] [llvm] add support for mustache templating language (PR #105893)

2025-01-13 Thread Nicolas van Kempen via cfe-commits
@@ -0,0 +1,114 @@ +//===--- Mustache.h -*- 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] [llvm] [llvm] add support for mustache templating language (PR #105893)

2025-01-13 Thread Nicolas van Kempen via cfe-commits
@@ -0,0 +1,785 @@ +//===-- Mustache.cpp --===// +// +// 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] [llvm] [llvm] add support for mustache templating language (PR #105893)

2025-01-13 Thread Nicolas van Kempen via cfe-commits
@@ -0,0 +1,114 @@ +//===--- Mustache.h -*- 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] [llvm] [llvm] add support for mustache templating language (PR #105893)

2025-01-13 Thread Nicolas van Kempen via cfe-commits
@@ -0,0 +1,785 @@ +//===-- Mustache.cpp --===// +// +// 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] [llvm] [llvm] add support for mustache templating language (PR #105893)

2025-01-13 Thread Nicolas van Kempen via cfe-commits
@@ -0,0 +1,785 @@ +//===-- Mustache.cpp --===// +// +// 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] [llvm] [llvm] add support for mustache templating language (PR #105893)

2025-01-13 Thread Nicolas van Kempen via cfe-commits
@@ -0,0 +1,114 @@ +//===--- Mustache.h -*- 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] [llvm] [llvm] add support for mustache templating language (PR #105893)

2025-01-13 Thread Nicolas van Kempen via cfe-commits
@@ -0,0 +1,785 @@ +//===-- Mustache.cpp --===// +// +// 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] [llvm] [llvm] add support for mustache templating language (PR #105893)

2025-01-13 Thread Nicolas van Kempen via cfe-commits
@@ -0,0 +1,785 @@ +//===-- Mustache.cpp --===// +// +// 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] [llvm] [llvm] add support for mustache templating language (PR #105893)

2025-01-13 Thread Nicolas van Kempen via cfe-commits
@@ -0,0 +1,114 @@ +//===--- Mustache.h -*- 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] [llvm] [llvm] add support for mustache templating language (PR #105893)

2025-01-09 Thread Nicolas van Kempen via cfe-commits
@@ -0,0 +1,114 @@ +//===--- Mustache.h -*- 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] fix incorrect argument names in documentation for ExtraArgs and ExtraArgsBefore (PR #120963)

2024-12-24 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank approved this pull request. LGTM, thanks! https://github.com/llvm/llvm-project/pull/120963 ___ 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 incorrect argument names in documentation for ExtraArgs and ExtraArgsBefore (PR #120963)

2024-12-23 Thread Nicolas van Kempen via cfe-commits
nicovank wrote: Sync with [ClangTidyMain.cpp](https://github.com/llvm/llvm-project/blob/d36836de0183b9b1939cc679d153e3b313e55c76/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp#L57-L58)? https://github.com/llvm/llvm-project/blob/d36836de0183b9b1939cc679d153e3b313e55c76/clang-tools-extra/cla

[clang-tools-extra] [clang-tidy][doc] align the title style in clang-tidy/index.rst (PR #119938)

2024-12-13 Thread Nicolas van Kempen via cfe-commits
@@ -9,7 +9,7 @@ See also: .. toctree:: :maxdepth: 1 - The list of clang-tidy checks + The List of Clang-Tidy Checks nicovank wrote: Maybe? ```suggestion List of Clang-Tidy Checks ``` https://github.com/llvm/llvm-project/pull/119938

[clang-tools-extra] [clang-tidy][doc] align the title style in clang-tidy/index.rst (PR #119938)

2024-12-13 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank approved this pull request. Ctrl+F -ing for lowercase `clang-tidy` reveals a couple more places where it should maybe be updated: lines 331, 350 and 352 (`` :program:`clang-tidy` ``?). It's very minor anyway. https://github.com/llvm/llvm-project/pull/119938

[clang-tools-extra] [clang-tidy][doc] align the title style in clang-tidy/index.rst (PR #119938)

2024-12-13 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank edited https://github.com/llvm/llvm-project/pull/119938 ___ 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][NFC] extract common global options in doc (PR #119842)

2024-12-13 Thread Nicolas van Kempen via cfe-commits
@@ -10,6 +10,7 @@ See also: :maxdepth: 1 The list of clang-tidy checks + The list of clang-tidy global options Clang-tidy IDE/Editor Integrations Getting Involved External Clang-Tidy Examples nicovank wrote: Just a drive-by comment, n

[clang-tools-extra] Re-add path normalization that was removed in 315561c86778 (PR #118718)

2024-12-04 Thread Nicolas van Kempen via cfe-commits
nicovank wrote: I see, thanks for looking into it! To be honest I think `file_name_re` could be removed, `--source-filter` already takes in a regex and filters files based on it, which is more clear. The `files` arguments could just be taken as-is as a list of file paths (or maybe optionally d

[clang-tools-extra] Re-add path normalization that was removed in 315561c86778 (PR #118718)

2024-12-04 Thread Nicolas van Kempen via cfe-commits
nicovank wrote: Is there a reason to bring it back? Is it causing issues? IIRC this was on purpose because from `os.path.abspath`: > On most platforms, this is equivalent to calling the function > [normpath()](https://docs.python.org/3/library/os.path.html#os.path.normpath) > as follows: normpa

[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][modernize-use-starts-ends-with] Fix operator rewriting false negative (PR #117837)

2024-11-26 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank created https://github.com/llvm/llvm-project/pull/117837 In C++20, `operator!=` can be rewritten by negating `operator==`. This is the case for `std::string`, where `operator!=` is not provided hence relying on this rewriting. Cover this case by matching `binaryOp

[clang-tools-extra] [clang-tidy][modernize-use-starts-ends-with] Fix minor mistake in error message (PR #116132)

2024-11-26 Thread Nicolas van Kempen via cfe-commits
nicovank wrote: Incorporated in #116033. https://github.com/llvm/llvm-project/pull/116132 ___ 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 minor mistake in error message (PR #116132)

2024-11-26 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank closed https://github.com/llvm/llvm-project/pull/116132 ___ 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-22 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-22 Thread Nicolas van Kempen via cfe-commits
@@ -183,38 +210,43 @@ 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-22 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank approved this pull request. LGTM minus 1 nit. Thanks! 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-22 Thread Nicolas van Kempen 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-22 Thread Nicolas van Kempen 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-22 Thread Nicolas van Kempen via cfe-commits
@@ -183,40 +210,45 @@ 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 Nicolas van Kempen via cfe-commits
@@ -183,40 +210,45 @@ 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 Nicolas van Kempen via cfe-commits
nicovank wrote: @hjanuschka Let's give it another day or so then I’ll go ahead and click merge if there are no other comments 👍 https://github.com/llvm/llvm-project/pull/116033 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm

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

2024-11-20 Thread Nicolas van Kempen via cfe-commits
=?utf-8?q?Félix-Antoine?= Constantin Message-ID: In-Reply-To: nicovank wrote: Just for discussion: 1. Almost equivalent to `sed -i -E 's/-f[[:alnum:][:punct:]]*//g; s/-Werror//g' compile_commands.json`? 2. What if a `-f...` argument is needed while others should be ignored? The regex might

[clang-tools-extra] [clang-tidy][NFC] fix typo in ExceptionAnalyzer; `replace count()>0` with `contains` (PR #116635)

2024-11-19 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 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
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

[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 approved this pull request. LGMT! Thanks! 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
@@ -265,4 +255,57 @@ 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-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
@@ -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][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] 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] 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] 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
@@ -171,10 +182,25 @@ void UseStartsEndsWithCheck::registerMatchers(MatchFinder *Finder) { hasRHS(lengthExprForStringNode("needle") .bind("expr"), this); + + Finder->addMatcher( nicovank wrote: Nit for consist

[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) { + if (const auto *BO = llvm::dyn_cast(ComparisonExpr)) { +return BO->getOpcode() == BO_NE; + } + + if (const auto *Op = llvm:

[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) { + if (const auto *BO = llvm::dyn_cast(ComparisonExpr)) { +return BO->getOpcode() == BO_NE; + } nicovank wrote

[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
@@ -243,8 +243,9 @@ Changes in existing checks ``NULL``/``__null`` (but not ``0``) when used with a templated type. - Improved :doc:`modernize-use-starts-ends-with - ` check to handle two cases - that can be replaced with ``ends_with`` + ` check to handle two new

[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] 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-17 Thread Nicolas van Kempen via cfe-commits
@@ -36,221 +36,224 @@ void test(std::string s, std::string_view sv, sub_string ss, sub_sub_string sss, string_like sl, string_like_camel slc, prefer_underscore_version puv, prefer_underscore_version_flip puvf) { s.find("a") == 0; - // CHECK-MESSAGES: :[[

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

2024-11-17 Thread Nicolas van Kempen via cfe-commits
@@ -30,6 +30,17 @@ struct NotLengthExprForStringNode { IntegerLiteralSizeNode->getValue().getZExtValue(); } + if (const auto *DeclRefNode = Node.get()) { +if (const auto *VD = dyn_cast(DeclRefNode->getDecl())) { + if (VD->hasInit() &&

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

2024-11-17 Thread Nicolas van Kempen via cfe-commits
@@ -171,10 +182,64 @@ void UseStartsEndsWithCheck::registerMatchers(MatchFinder *Finder) { hasRHS(lengthExprForStringNode("needle") .bind("expr"), this); + + Finder->addMatcher( + cxxOperatorCallExpr( + hasAnyOper

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

2024-11-17 Thread Nicolas van Kempen via cfe-commits
@@ -171,10 +182,64 @@ void UseStartsEndsWithCheck::registerMatchers(MatchFinder *Finder) { hasRHS(lengthExprForStringNode("needle") .bind("expr"), this); + + Finder->addMatcher( + cxxOperatorCallExpr( + hasAnyOper

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

2024-11-17 Thread Nicolas van Kempen via cfe-commits
@@ -171,10 +182,64 @@ void UseStartsEndsWithCheck::registerMatchers(MatchFinder *Finder) { hasRHS(lengthExprForStringNode("needle") .bind("expr"), this); + + Finder->addMatcher( + cxxOperatorCallExpr( + hasAnyOper

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

2024-11-17 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank requested changes to this pull request. 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-17 Thread Nicolas van Kempen via cfe-commits
@@ -25,6 +25,7 @@ class UseStartsEndsWithCheck : public ClangTidyCheck { UseStartsEndsWithCheck(StringRef Name, ClangTidyContext *Context); void registerMatchers(ast_matchers::MatchFinder *Finder) override; void check(const ast_matchers::MatchFinder::MatchResult &Result)

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

2024-11-17 Thread Nicolas van Kempen via cfe-commits
@@ -171,10 +182,64 @@ void UseStartsEndsWithCheck::registerMatchers(MatchFinder *Finder) { hasRHS(lengthExprForStringNode("needle") .bind("expr"), this); + + Finder->addMatcher( + cxxOperatorCallExpr( + hasAnyOper

[clang-tools-extra] [clang-tidy][modernize-use-starts-ends-with] Fix minor mistake in error message (PR #116132)

2024-11-16 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank updated https://github.com/llvm/llvm-project/pull/116132 >From 5c52bea612c677352d555ce8100d222f149414d0 Mon Sep 17 00:00:00 2001 From: Nicolas van Kempen Date: Sat, 16 Nov 2024 15:41:00 -0500 Subject: [PATCH] [clang-tidy][modernize-use-starts-ends-with] Fix minor mi

[clang-tools-extra] [clang-tidy][modernize-use-starts-ends-with] Fix minor mistake in error message (PR #116132)

2024-11-16 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank updated https://github.com/llvm/llvm-project/pull/116132 >From 5c52bea612c677352d555ce8100d222f149414d0 Mon Sep 17 00:00:00 2001 From: Nicolas van Kempen Date: Sat, 16 Nov 2024 15:41:00 -0500 Subject: [PATCH] [clang-tidy][modernize-use-starts-ends-with] Fix minor mi

[clang-tools-extra] [clang-tidy][modernize-use-starts-ends-with] Fix minor mistake in error message (PR #116132)

2024-11-16 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank updated https://github.com/llvm/llvm-project/pull/116132 >From 56fd8556333a86a63903ffd370d307cf9484fd5a Mon Sep 17 00:00:00 2001 From: Nicolas van Kempen Date: Sat, 16 Nov 2024 15:35:13 -0500 Subject: [PATCH] [clang-tidy][modernize-use-starts-ends-with] Fix minor mi

[clang-tools-extra] [clang-tidy][modernize-use-starts-ends-with] Fix minor mistake in error message (PR #116132)

2024-11-16 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank updated https://github.com/llvm/llvm-project/pull/116132 >From 56fd8556333a86a63903ffd370d307cf9484fd5a Mon Sep 17 00:00:00 2001 From: Nicolas van Kempen Date: Sat, 16 Nov 2024 15:35:13 -0500 Subject: [PATCH] [clang-tidy][modernize-use-starts-ends-with] Fix minor mi

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

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

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

2024-11-15 Thread Nicolas van Kempen via cfe-commits
@@ -0,0 +1,724 @@ +//===-- Mustache.cpp --===// +// +// 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] [llvm] [llvm] add support for mustache templating language (PR #105893)

2024-11-15 Thread Nicolas van Kempen via cfe-commits
@@ -0,0 +1,724 @@ +//===-- Mustache.cpp --===// +// +// 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] [llvm] [llvm] add support for mustache templating language (PR #105893)

2024-11-15 Thread Nicolas van Kempen via cfe-commits
@@ -0,0 +1,724 @@ +//===-- Mustache.cpp --===// +// +// 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] [llvm] [llvm] add support for mustache templating language (PR #105893)

2024-11-15 Thread Nicolas van Kempen via cfe-commits
@@ -0,0 +1,724 @@ +//===-- Mustache.cpp --===// +// +// 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-15 Thread Nicolas van Kempen via cfe-commits
@@ -189,7 +203,54 @@ void UseStartsEndsWithCheck::check(const MatchFinder::MatchResult &Result) { if (ComparisonExpr->getBeginLoc().isMacroID()) return; - const bool Neg = ComparisonExpr->getOpcode() == BO_NE; + bool Neg; + if (const auto *BO = llvm::dyn_cast(Compari

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

2024-11-15 Thread Nicolas van Kempen via cfe-commits
@@ -0,0 +1,724 @@ +//===-- Mustache.cpp --===// +// +// 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] [llvm] [llvm] add support for mustache templating language (PR #105893)

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

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

2024-11-15 Thread Nicolas van Kempen via cfe-commits
@@ -0,0 +1,724 @@ +//===-- Mustache.cpp --===// +// +// 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] [llvm] [llvm] add support for mustache templating language (PR #105893)

2024-11-15 Thread Nicolas van Kempen via cfe-commits
@@ -0,0 +1,724 @@ +//===-- Mustache.cpp --===// +// +// 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] [llvm] [llvm] add support for mustache templating language (PR #105893)

2024-11-15 Thread Nicolas van Kempen via cfe-commits
@@ -0,0 +1,724 @@ +//===-- Mustache.cpp --===// +// +// 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] [llvm] [llvm] add support for mustache templating language (PR #105893)

2024-11-15 Thread Nicolas van Kempen via cfe-commits
@@ -0,0 +1,724 @@ +//===-- Mustache.cpp --===// +// +// 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] [llvm] [llvm] add support for mustache templating language (PR #105893)

2024-11-15 Thread Nicolas van Kempen via cfe-commits
@@ -0,0 +1,724 @@ +//===-- Mustache.cpp --===// +// +// 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] [llvm] [llvm] add support for mustache templating language (PR #105893)

2024-11-15 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank commented: I stopped halfway, but a performance tip to save copies: If the constructor or method is going to "own" the data: pass by value and move (some would recommend two overloads, IMO the extra verbosity is not worth the insignificant performance gain). I wrote

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

2024-11-15 Thread Nicolas van Kempen via cfe-commits
@@ -0,0 +1,724 @@ +//===-- Mustache.cpp --===// +// +// 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] [llvm] [llvm] add support for mustache templating language (PR #105893)

2024-11-15 Thread Nicolas van Kempen via cfe-commits
@@ -0,0 +1,724 @@ +//===-- Mustache.cpp --===// +// +// 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] [llvm] [llvm] add support for mustache templating language (PR #105893)

2024-11-15 Thread Nicolas van Kempen via cfe-commits
@@ -0,0 +1,724 @@ +//===-- Mustache.cpp --===// +// +// 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] [llvm] [llvm] add support for mustache templating language (PR #105893)

2024-11-15 Thread Nicolas van Kempen via cfe-commits
https://github.com/nicovank edited https://github.com/llvm/llvm-project/pull/105893 ___ 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-15 Thread Nicolas van Kempen via cfe-commits
@@ -171,10 +171,24 @@ void UseStartsEndsWithCheck::registerMatchers(MatchFinder *Finder) { hasRHS(lengthExprForStringNode("needle") .bind("expr"), this); + Finder->addMatcher( nicovank wrote: For consisten

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

2024-11-15 Thread Nicolas van Kempen via cfe-commits
@@ -59,6 +59,7 @@ struct basic_string { _Type& insert(size_type pos, const _Type& str); _Type& insert(size_type pos, const C* s); _Type& insert(size_type pos, const C* s, size_type n); + _Type substr(size_type pos = 0, size_type count = npos) const; nico

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

2024-11-15 Thread Nicolas van Kempen via cfe-commits
@@ -266,3 +266,37 @@ 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(); } + +void test_substr() { +std::string str("hello world"); +std::string prefix = "hello

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

2024-11-15 Thread Nicolas van Kempen via cfe-commits
@@ -244,7 +244,10 @@ Changes in existing checks - Improved :doc:`modernize-use-starts-ends-with ` check to handle two cases - that can be replaced with ``ends_with`` + that can be replaced with ``ends_with`` and detect patterns using ``substr`` + that can be replaced with

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

2024-11-15 Thread Nicolas van Kempen via cfe-commits
@@ -189,7 +203,54 @@ void UseStartsEndsWithCheck::check(const MatchFinder::MatchResult &Result) { if (ComparisonExpr->getBeginLoc().isMacroID()) return; - const bool Neg = ComparisonExpr->getOpcode() == BO_NE; + bool Neg; + if (const auto *BO = llvm::dyn_cast(Compari

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

2024-11-15 Thread Nicolas van Kempen via cfe-commits
@@ -266,3 +266,37 @@ 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(); } + +void test_substr() { +std::string str("hello world"); +std::string prefix = "hello

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

2024-11-15 Thread Nicolas van Kempen via cfe-commits
@@ -7,26 +7,39 @@ Checks for common roundabout ways to express ``starts_with`` and ``ends_with`` and suggests replacing with the simpler method when it is available. Notably, this will work with ``std::string`` and ``std::string_view``. -.. code-block:: c++ +The check handle

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

2024-11-15 Thread Nicolas van Kempen via cfe-commits
@@ -7,26 +7,39 @@ Checks for common roundabout ways to express ``starts_with`` and ``ends_with`` and suggests replacing with the simpler method when it is available. Notably, this will work with ``std::string`` and ``std::string_view``. -.. code-block:: c++ +The check handle

  1   2   3   4   5   >