https://github.com/nicovank updated
https://github.com/llvm/llvm-project/pull/72385
>From 316b45d612c63f8eea8f847d1cd39992898516f3 Mon Sep 17 00:00:00 2001
From: Nicolas van Kempen
Date: Wed, 15 Nov 2023 01:13:10 -0800
Subject: [PATCH] [clang-tidy] Add new modernize-use-starts-ends-with check
carlosgalvezp wrote:
Apologies for the late reply, need to fix my mail filter so I don't miss the
notifications!
IMHO either modernize or readability are suitable categories. Performance can
vary/be negligible depending on context I suppose?
https://github.com/llvm/llvm-project/pull/72385
nicovank wrote:
Ping. @carlosgalvezp could you please weigh in? modernize / performance? Anyone
else?
I have no real preference either way. Now that modernize is fully integrated in
Clang-Tidy, I don't think historical reasons should lead to modernize
overbloat. If this check was only
EugeneZelenko wrote:
Historically, `modernize` was separate binary which was merged with
`Clang-tidy`. Its intend was to simplify migration to features added in newer
versions of C++. Even if performance/readability are affected, code migration
to newer standards is primary advantage.
PiotrZSL wrote:
Problem that I see with "modernize" category is that it overlap with other
categories, for example modernize-make-shared is mainly a performance check,
modernize-redundant-void-arg is an readability check. We basically lack
category for code design (rule of 5, limiting
EugeneZelenko wrote:
@firewave, @carlosgalvezp: What do you think?
https://github.com/llvm/llvm-project/pull/72385
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
nicovank wrote:
@EugeneZelenko We've had this discussion, see here and the couple comments
below: https://github.com/llvm/llvm-project/pull/72385#issuecomment-1812801402.
I guess I can rename one more time if there is consensus.
https://github.com/llvm/llvm-project/pull/72385
EugeneZelenko wrote:
I think `modernize` is better fit for this check.
https://github.com/llvm/llvm-project/pull/72385
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/nicovank updated
https://github.com/llvm/llvm-project/pull/72385
>From 0dc3f43049ca8558442ee2a6fbaf15da1510a9a3 Mon Sep 17 00:00:00 2001
From: Nicolas van Kempen
Date: Wed, 15 Nov 2023 01:13:10 -0800
Subject: [PATCH] [clang-tidy] Add new performance-use-starts-ends-with
nicovank wrote:
Updates. I've been running into issues when the begin location of the entire
expression is a macro. The prefix removal, which should include the macro text,
is not working as I expect it to. If you know of any checks that have similar
logic I can take a look and copy. I just
https://github.com/nicovank updated
https://github.com/llvm/llvm-project/pull/72385
>From e0074d270f2b78f8202c822a61a0d723e1adb2a3 Mon Sep 17 00:00:00 2001
From: Nicolas van Kempen
Date: Wed, 15 Nov 2023 01:13:10 -0800
Subject: [PATCH] [clang-tidy] Add new performance-use-starts-ends-with
https://github.com/nicovank updated
https://github.com/llvm/llvm-project/pull/72385
>From 22caf9b39e927e61eaef0499266dd7ab8e252ba0 Mon Sep 17 00:00:00 2001
From: Nicolas van Kempen
Date: Wed, 15 Nov 2023 01:13:10 -0800
Subject: [PATCH] [clang-tidy] Add new performance-use-starts-ends-with
@@ -0,0 +1,109 @@
+//===--- UseStartsEndsWithCheck.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:
@@ -0,0 +1,109 @@
+//===--- UseStartsEndsWithCheck.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:
https://github.com/PiotrZSL commented:
Looks good. Minor cleanup and could land.
https://github.com/llvm/llvm-project/pull/72385
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -0,0 +1,37 @@
+//===--- UseStartsEndsWithCheck.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:
@@ -0,0 +1,37 @@
+//===--- UseStartsEndsWithCheck.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:
@@ -0,0 +1,151 @@
+// RUN: %check_clang_tidy -std=c++20 %s performance-use-starts-ends-with %t --
\
+// RUN: -- -isystem %clang_tidy_headers
+
+#include
+
+std::string foo(std::string);
+std::string bar();
+
+#define A_MACRO(x, y) ((x) == (y))
+#define STR(x) std::string(x)
+
@@ -0,0 +1,109 @@
+//===--- UseStartsEndsWithCheck.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:
https://github.com/nicovank updated
https://github.com/llvm/llvm-project/pull/72385
>From 7a9703f27897af0846d272ca7393bc72eff11e55 Mon Sep 17 00:00:00 2001
From: Nicolas van Kempen
Date: Wed, 15 Nov 2023 01:13:10 -0800
Subject: [PATCH] [clang-tidy] Add new performance-use-starts-ends-with
@@ -0,0 +1,109 @@
+//===--- UseStartsEndsWithCheck.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:
@@ -12,4 +12,4 @@
typedef __PTRDIFF_TYPE__ ptrdiff_t;
typedef __SIZE_TYPE__ size_t;
-#endif _STDDEF_H_
+#endif // _STDDEF_H_
nicovank wrote:
This was just issuing a warning in some tests.
https://github.com/llvm/llvm-project/pull/72385
nicovank wrote:
Major changes:
- Now matching on any class that has a `starts_with`, `startsWith`, or
`startswith` function. This is done in order (prioritising functions in
subclasses, but this could be changed). Experimenting on making this an option,
not sure it's worth it without
https://github.com/nicovank updated
https://github.com/llvm/llvm-project/pull/72385
>From ddac6dc91c443bf81d4b6cc3f75686ea56801094 Mon Sep 17 00:00:00 2001
From: Nicolas van Kempen
Date: Wed, 15 Nov 2023 01:13:10 -0800
Subject: [PATCH] [clang-tidy] Add new performance-use-starts-ends-with
@@ -0,0 +1,105 @@
+//===--- StringFindStartswithCheck.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:
@@ -8,6 +8,10 @@ corresponding ``std::string_view`` methods) result is compared
with 0, and
suggests replacing with ``absl::StartsWith()``. This is both a readability and
performance issue.
+``starts_with`` was added as a built-in function on those types in C++20. If
@@ -0,0 +1,106 @@
+//===--- UseStartsEndsWithCheck.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:
https://github.com/PiotrZSL deleted
https://github.com/llvm/llvm-project/pull/72385
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -0,0 +1,106 @@
+//===--- UseStartsEndsWithCheck.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:
@@ -0,0 +1,106 @@
+//===--- UseStartsEndsWithCheck.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:
@@ -0,0 +1,106 @@
+//===--- UseStartsEndsWithCheck.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:
@@ -31,6 +30,10 @@ class StringFindStartswithCheck : public ClangTidyCheck {
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
void check(const ast_matchers::MatchFinder::MatchResult ) override;
void storeOptions(ClangTidyOptions::OptionMap ) override;
+
@@ -0,0 +1,106 @@
+//===--- UseStartsEndsWithCheck.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:
@@ -0,0 +1,106 @@
+//===--- UseStartsEndsWithCheck.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:
@@ -0,0 +1,106 @@
+//===--- UseStartsEndsWithCheck.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:
https://github.com/nicovank updated
https://github.com/llvm/llvm-project/pull/72385
>From 96e00378116ca5fbfad6edb220e86326dc4f9897 Mon Sep 17 00:00:00 2001
From: Nicolas van Kempen
Date: Wed, 15 Nov 2023 01:13:10 -0800
Subject: [PATCH] [clang-tidy] Add new performance-use-starts-ends-with
https://github.com/nicovank edited
https://github.com/llvm/llvm-project/pull/72385
___
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/72385
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
38 matches
Mail list logo