[clang-tools-extra] [clang-tidy] Add bugprone-suspicious-stringview-data-usage check (PR #83716)

via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 7 12:01:23 PST 2024


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 6515930b0cc4aa2e11e75728ef6cbeecbe5caec2 431071344df198bd0e9d4a1e5bbef972c84e00c6 -- clang-tools-extra/clang-tidy/bugprone/SuspiciousStringviewDataUsageCheck.cpp clang-tools-extra/clang-tidy/bugprone/SuspiciousStringviewDataUsageCheck.h clang-tools-extra/test/clang-tidy/checkers/bugprone/suspicious-stringview-data-usage.cpp clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
``````````

</details>

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

``````````diff
diff --git a/clang-tools-extra/clang-tidy/bugprone/SuspiciousStringviewDataUsageCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SuspiciousStringviewDataUsageCheck.cpp
index f247da6bc5..52f4c7764e 100644
--- a/clang-tools-extra/clang-tidy/bugprone/SuspiciousStringviewDataUsageCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/SuspiciousStringviewDataUsageCheck.cpp
@@ -62,9 +62,10 @@ void SuspiciousStringviewDataUsageCheck::registerMatchers(MatchFinder *Finder) {
       on(ignoringParenImpCasts(
           matchers::isStatementIdenticalToBoundNode("self"))));
 
-  auto DescendantSizeCall = expr(hasDescendant(expr(SizeCall,
-                                               hasAncestor(expr(AncestorCall).bind("ancestor-size")),
-                                               hasAncestor(expr(equalsBoundNode("parent"), equalsBoundNode("ancestor-size"))))));
+  auto DescendantSizeCall = expr(hasDescendant(
+      expr(SizeCall, hasAncestor(expr(AncestorCall).bind("ancestor-size")),
+           hasAncestor(expr(equalsBoundNode("parent"),
+                            equalsBoundNode("ancestor-size"))))));
 
   Finder->addMatcher(
       cxxMemberCallExpr(
@@ -83,8 +84,7 @@ void SuspiciousStringviewDataUsageCheck::registerMatchers(MatchFinder *Finder) {
                            hasType(qualType(hasCanonicalType(hasDeclaration(
                                recordDecl(unless(matchers::matchesAnyListedName(
                                    AllowedCallees))))))),
-                           unless(DescendantSizeCall))
-                )))),
+                           unless(DescendantSizeCall)))))),
       this);
 }
 

``````````

</details>


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


More information about the cfe-commits mailing list