[clang-tools-extra] Add ``ignoringParenImpCasts`` in ``hasAnyArgument`` fix#75754 (PR #87268)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 1 10:56:02 PDT 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 9434c083475e42f47383f3067fe2a155db5c6a30 c6035510cd330e99d9c2bfc60de6d76e84c79a37 -- clang-tools-extra/clang-tidy/bugprone/MisplacedOperatorInStrlenInAllocCheck.cpp clang-tools-extra/clang-tidy/bugprone/MisplacedWideningCastCheck.cpp clang-tools-extra/clang-tidy/bugprone/MultipleNewInOneExpressionCheck.cpp clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp clang-tools-extra/clang-tidy/bugprone/StringLiteralWithEmbeddedNulCheck.cpp clang-tools-extra/clang-tidy/bugprone/SuspiciousStringviewDataUsageCheck.cpp clang-tools-extra/clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp clang-tools-extra/clang-tidy/performance/InefficientStringConcatenationCheck.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang-tools-extra/clang-tidy/bugprone/MisplacedWideningCastCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/MisplacedWideningCastCheck.cpp
index b62829a377..f989e92787 100644
--- a/clang-tools-extra/clang-tidy/bugprone/MisplacedWideningCastCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/MisplacedWideningCastCheck.cpp
@@ -42,7 +42,8 @@ void MisplacedWideningCastCheck::registerMatchers(MatchFinder *Finder) {
Finder->addMatcher(varDecl(hasInitializer(Cast)), this);
Finder->addMatcher(returnStmt(hasReturnValue(Cast)), this);
- Finder->addMatcher(callExpr(hasAnyArgument(ignoringParenImpCasts(Cast))), this);
+ Finder->addMatcher(callExpr(hasAnyArgument(ignoringParenImpCasts(Cast))),
+ this);
Finder->addMatcher(binaryOperator(hasOperatorName("="), hasRHS(Cast)), this);
Finder->addMatcher(
binaryOperator(isComparisonOperator(), hasEitherOperand(Cast)), this);
diff --git a/clang-tools-extra/clang-tidy/bugprone/MultipleNewInOneExpressionCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/MultipleNewInOneExpressionCheck.cpp
index b8dbea600f..d304ac0bd6 100644
--- a/clang-tools-extra/clang-tidy/bugprone/MultipleNewInOneExpressionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/MultipleNewInOneExpressionCheck.cpp
@@ -95,18 +95,16 @@ void MultipleNewInOneExpressionCheck::registerMatchers(MatchFinder *Finder) {
Finder->addMatcher(
callExpr(
- hasAnyArgument(
- ignoringParenImpCasts(expr(HasNewExpr1).bind("arg1"))),
- hasAnyArgument(
- ignoringParenImpCasts(expr(HasNewExpr2, unless(equalsBoundNode("arg1"))).bind("arg2"))),
+ hasAnyArgument(ignoringParenImpCasts(expr(HasNewExpr1).bind("arg1"))),
+ hasAnyArgument(ignoringParenImpCasts(
+ expr(HasNewExpr2, unless(equalsBoundNode("arg1"))).bind("arg2"))),
hasAncestor(BadAllocCatchingTryBlock)),
this);
Finder->addMatcher(
cxxConstructExpr(
- hasAnyArgument(
- ignoringParenImpCasts(expr(HasNewExpr1).bind("arg1"))),
- hasAnyArgument(
- ignoringParenImpCasts(expr(HasNewExpr2, unless(equalsBoundNode("arg1"))).bind("arg2"))),
+ hasAnyArgument(ignoringParenImpCasts(expr(HasNewExpr1).bind("arg1"))),
+ hasAnyArgument(ignoringParenImpCasts(
+ expr(HasNewExpr2, unless(equalsBoundNode("arg1"))).bind("arg2"))),
unless(isListInitialization()),
hasAncestor(BadAllocCatchingTryBlock)),
this);
diff --git a/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp
index d322f2488f..264926de70 100644
--- a/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp
@@ -618,10 +618,11 @@ void NotNullTerminatedResultCheck::registerMatchers(MatchFinder *Finder) {
// Note: Sometimes the size of char is explicitly written out.
auto SizeExpr = anyOf(SizeOfCharExpr, integerLiteral(equals(1)));
- auto MallocLengthExpr = allOf(
- callee(functionDecl(
- hasAnyName("::alloca", "::calloc", "malloc", "realloc"))),
- hasAnyArgument(ignoringParenImpCasts(allOf(unless(SizeExpr), expr().bind(DestMallocExprName)))));
+ auto MallocLengthExpr =
+ allOf(callee(functionDecl(
+ hasAnyName("::alloca", "::calloc", "malloc", "realloc"))),
+ hasAnyArgument(ignoringParenImpCasts(
+ allOf(unless(SizeExpr), expr().bind(DestMallocExprName)))));
// - Example: (char *)malloc(length);
auto DestMalloc = anyOf(callExpr(MallocLengthExpr),
diff --git a/clang-tools-extra/clang-tidy/bugprone/StringLiteralWithEmbeddedNulCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/StringLiteralWithEmbeddedNulCheck.cpp
index 18a9dc6c43..37945b8a03 100644
--- a/clang-tools-extra/clang-tidy/bugprone/StringLiteralWithEmbeddedNulCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/StringLiteralWithEmbeddedNulCheck.cpp
@@ -52,7 +52,9 @@ void StringLiteralWithEmbeddedNulCheck::registerMatchers(MatchFinder *Finder) {
this);
// Detect passing a suspicious string literal through an overloaded operator.
- Finder->addMatcher(cxxOperatorCallExpr(hasAnyArgument(ignoringParenImpCasts(StrLitWithNul))), this);
+ Finder->addMatcher(
+ cxxOperatorCallExpr(hasAnyArgument(ignoringParenImpCasts(StrLitWithNul))),
+ this);
}
void StringLiteralWithEmbeddedNulCheck::check(
diff --git a/clang-tools-extra/clang-tidy/bugprone/SuspiciousStringviewDataUsageCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SuspiciousStringviewDataUsageCheck.cpp
index 183d7c4bfb..f71bc6df20 100644
--- a/clang-tools-extra/clang-tidy/bugprone/SuspiciousStringviewDataUsageCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/SuspiciousStringviewDataUsageCheck.cpp
@@ -73,7 +73,8 @@ void SuspiciousStringviewDataUsageCheck::registerMatchers(MatchFinder *Finder) {
hasAnyArgument(
ignoringParenImpCasts(equalsBoundNode("data-call"))),
unless(hasAnyArgument(ignoringParenImpCasts(SizeCall))),
- unless(hasAnyArgument(ignoringParenImpCasts(DescendantSizeCall))),
+ unless(hasAnyArgument(
+ ignoringParenImpCasts(DescendantSizeCall))),
hasDeclaration(namedDecl(
unless(matchers::matchesAnyListedName(AllowedCallees))))),
initListExpr(expr().bind("parent"),
diff --git a/clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp
index 3055948fc3..b95d826654 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp
@@ -177,13 +177,13 @@ void UseEmplaceCheck::registerMatchers(MatchFinder *Finder) {
hasDeclaration(cxxConstructorDecl(ofClass(hasAnyName(SmartPointers))));
// Bitfields binds only to consts and emplace_back take it by universal ref.
- auto BitFieldAsArgument = hasAnyArgument(
- ignoringParenImpCasts(memberExpr(hasDeclaration(fieldDecl(isBitField())))));
+ auto BitFieldAsArgument = hasAnyArgument(ignoringParenImpCasts(
+ memberExpr(hasDeclaration(fieldDecl(isBitField())))));
// Initializer list can't be passed to universal reference.
auto InitializerListAsArgument = hasAnyArgument(
ignoringParenImpCasts(allOf(cxxConstructExpr(isListInitialization()),
- unless(cxxTemporaryObjectExpr()))));
+ unless(cxxTemporaryObjectExpr()))));
// We could have leak of resource.
auto NewExprAsArgument = hasAnyArgument(ignoringParenImpCasts(cxxNewExpr()));
``````````
</details>
https://github.com/llvm/llvm-project/pull/87268
More information about the cfe-commits
mailing list