@@ -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
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`).
@@ -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
@@ -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
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/
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
@@ -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
@@ -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
@@ -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
@@ -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
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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
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
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
@@ -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
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
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
@@ -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
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
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
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
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
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
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
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
@@ -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
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
@@ -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
@@ -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
@@ -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
@@ -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
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
=?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
@@ -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
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
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
@@ -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
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
@@ -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 ==
@@ -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
@@ -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
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
@@ -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
@@ -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
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
@@ -171,10 +182,25 @@ void UseStartsEndsWithCheck::registerMatchers(MatchFinder
*Finder) {
hasRHS(lengthExprForStringNode("needle")
.bind("expr"),
this);
+
+ Finder->addMatcher(
nicovank wrote:
Nit for consist
@@ -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:
@@ -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
@@ -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
@@ -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
@@ -71,6 +71,17 @@ struct NotLengthExprForStringNode {
ASTContext *Context;
};
+static bool isNegativeComparison(const Expr *ComparisonExpr) {
nicovank wrote:
Nit: place above `NotLengthExprForStringNode` so `lengthExprForStringNode` and
`NotLengthExprForS
@@ -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: :[[
@@ -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() &&
@@ -171,10 +182,64 @@ void UseStartsEndsWithCheck::registerMatchers(MatchFinder
*Finder) {
hasRHS(lengthExprForStringNode("needle")
.bind("expr"),
this);
+
+ Finder->addMatcher(
+ cxxOperatorCallExpr(
+ hasAnyOper
@@ -171,10 +182,64 @@ void UseStartsEndsWithCheck::registerMatchers(MatchFinder
*Finder) {
hasRHS(lengthExprForStringNode("needle")
.bind("expr"),
this);
+
+ Finder->addMatcher(
+ cxxOperatorCallExpr(
+ hasAnyOper
@@ -171,10 +182,64 @@ void UseStartsEndsWithCheck::registerMatchers(MatchFinder
*Finder) {
hasRHS(lengthExprForStringNode("needle")
.bind("expr"),
this);
+
+ Finder->addMatcher(
+ cxxOperatorCallExpr(
+ hasAnyOper
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
@@ -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)
@@ -171,10 +182,64 @@ void UseStartsEndsWithCheck::registerMatchers(MatchFinder
*Finder) {
hasRHS(lengthExprForStringNode("needle")
.bind("expr"),
this);
+
+ Finder->addMatcher(
+ cxxOperatorCallExpr(
+ hasAnyOper
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
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
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
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
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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
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
@@ -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
@@ -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
@@ -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
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
@@ -171,10 +171,24 @@ void UseStartsEndsWithCheck::registerMatchers(MatchFinder
*Finder) {
hasRHS(lengthExprForStringNode("needle")
.bind("expr"),
this);
+ Finder->addMatcher(
nicovank wrote:
For consisten
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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 - 100 of 403 matches
Mail list logo