[clang-tools-extra] [clang-tidy] Add a new check 'bugprone-redundant-string-view-conversions' (PR #174288)

via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 6 09:58:39 PST 2026


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp,h -- clang-tools-extra/clang-tidy/performance/StringViewConversionsCheck.cpp clang-tools-extra/clang-tidy/performance/StringViewConversionsCheck.h clang-tools-extra/test/clang-tidy/checkers/performance/string-view-conversions.cpp clang-tools-extra/clang-tidy/performance/PerformanceTidyModule.cpp --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/clang-tools-extra/clang-tidy/performance/StringViewConversionsCheck.cpp b/clang-tools-extra/clang-tidy/performance/StringViewConversionsCheck.cpp
index d1faffc37..bb11f81c7 100644
--- a/clang-tools-extra/clang-tidy/performance/StringViewConversionsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/performance/StringViewConversionsCheck.cpp
@@ -19,8 +19,7 @@ static auto getStringTypeMatcher(StringRef CharType) {
   return hasCanonicalType(hasDeclaration(cxxRecordDecl(hasName(CharType))));
 }
 
-void StringViewConversionsCheck::registerMatchers(
-    MatchFinder *Finder) {
+void StringViewConversionsCheck::registerMatchers(MatchFinder *Finder) {
   // Matchers for std::basic_string[_view] families
   // (includes std::string, std::wstring, std::u8string, etc.)
   const auto IsStdString = getStringTypeMatcher("::std::basic_string");
@@ -96,8 +95,7 @@ void StringViewConversionsCheck::registerMatchers(
       this);
 }
 
-void StringViewConversionsCheck::check(
-    const MatchFinder::MatchResult &Result) {
+void StringViewConversionsCheck::check(const MatchFinder::MatchResult &Result) {
   // Get the full argument expression passed to the function.
   // This has type string_view after implicit conversions.
   const auto *ParamExpr = Result.Nodes.getNodeAs<Expr>("expr");

``````````

</details>


https://github.com/llvm/llvm-project/pull/174288


More information about the cfe-commits mailing list