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 --
clang/test/Analysis/Checkers/WebKit/memory-unsafe-cast-redecl.cpp
clang/lib/StaticAnalyzer/Checkers/WebKit/MemoryUnsafeCastChecker.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/lib/StaticAnalyzer/Checkers/WebKit/MemoryUnsafeCastChecker.cpp
b/clang/lib/StaticAnalyzer/Checkers/WebKit/MemoryUnsafeCastChecker.cpp
index 7199cff7b..42f2c43bf 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/MemoryUnsafeCastChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/MemoryUnsafeCastChecker.cpp
@@ -134,8 +134,7 @@ AST_MATCHER_P2(Expr, isCRTPCast, std::string, BaseID,
std::string, DerivedID) {
if (ArgType.isNull())
continue;
const auto *ArgDecl = ArgType->getAsCXXRecordDecl();
- if (ArgDecl &&
- ArgDecl->getCanonicalDecl() == Derived->getCanonicalDecl())
+ if (ArgDecl && ArgDecl->getCanonicalDecl() ==
Derived->getCanonicalDecl())
return false;
}
return true;
@@ -164,8 +163,9 @@ void MemoryUnsafeCastChecker::checkASTCodeBody(const Decl
*D,
// Match downcasts from base type to derived type and warn
auto MatchExprPtr = allOf(
hasSourceExpression(hasTypePointingTo(cxxRecordDecl().bind(BaseNode))),
-
hasTypePointingTo(cxxRecordDecl(isDerivedFrom(isSameDeclAsBoundNode(BaseNode)))
- .bind(DerivedNode)),
+ hasTypePointingTo(
+ cxxRecordDecl(isDerivedFrom(isSameDeclAsBoundNode(BaseNode)))
+ .bind(DerivedNode)),
unless(anyOf(hasTypePointingTo(templateTypeParmDecl()),
allOf(hasSourceExpression(cxxThisExpr()),
isCRTPCast(BaseNode, DerivedNode)))));
@@ -175,26 +175,27 @@ void MemoryUnsafeCastChecker::checkASTCodeBody(const Decl
*D,
ignoringImpCasts(hasType(objcObjectPointerType(pointee(hasDeclaration(
objcInterfaceDecl(isDerivedFrom(isSameDeclAsBoundNode(BaseNode)))
.bind(DerivedNode)))))));
- auto MatchExprRefTypeDef =
- allOf(hasSourceExpression(hasType(hasUnqualifiedDesugaredType(recordType(
- hasDeclaration(decl(cxxRecordDecl().bind(BaseNode))))))),
- hasType(hasUnqualifiedDesugaredType(recordType(hasDeclaration(
-
decl(cxxRecordDecl(isDerivedFrom(isSameDeclAsBoundNode(BaseNode)))
- .bind(DerivedNode)))))),
- unless(anyOf(hasType(templateTypeParmDecl()),
- allOf(hasSourceExpression(isThisOrDerefThis()),
- isCRTPCast(BaseNode, DerivedNode)))));
- auto MatchExprPtrVoidCast = allOf(
- anyOf(hasSourceExpression(explicitCastExpr(
- hasType(pointerType(pointee(voidType()))),
- hasSourceExpression(ignoringImpCasts(
- hasTypePointingTo(cxxRecordDecl().bind(BaseNode)))))),
- hasSourceExpression(
- callExpr(hasType(pointerType(pointee(voidType()))),
- hasAnyArgument(ignoringImpCasts(hasTypePointingTo(
- cxxRecordDecl().bind(BaseNode))))))),
-
hasTypePointingTo(cxxRecordDecl(isDerivedFrom(isSameDeclAsBoundNode(BaseNode)))
- .bind(DerivedNode)));
+ auto MatchExprRefTypeDef = allOf(
+ hasSourceExpression(hasType(hasUnqualifiedDesugaredType(
+ recordType(hasDeclaration(decl(cxxRecordDecl().bind(BaseNode))))))),
+ hasType(hasUnqualifiedDesugaredType(recordType(hasDeclaration(
+ decl(cxxRecordDecl(isDerivedFrom(isSameDeclAsBoundNode(BaseNode)))
+ .bind(DerivedNode)))))),
+ unless(anyOf(hasType(templateTypeParmDecl()),
+ allOf(hasSourceExpression(isThisOrDerefThis()),
+ isCRTPCast(BaseNode, DerivedNode)))));
+ auto MatchExprPtrVoidCast =
+ allOf(anyOf(hasSourceExpression(explicitCastExpr(
+ hasType(pointerType(pointee(voidType()))),
+ hasSourceExpression(ignoringImpCasts(
+
hasTypePointingTo(cxxRecordDecl().bind(BaseNode)))))),
+ hasSourceExpression(callExpr(
+ hasType(pointerType(pointee(voidType()))),
+ hasAnyArgument(ignoringImpCasts(hasTypePointingTo(
+ cxxRecordDecl().bind(BaseNode))))))),
+ hasTypePointingTo(
+ cxxRecordDecl(isDerivedFrom(isSameDeclAsBoundNode(BaseNode)))
+ .bind(DerivedNode)));
auto ExplicitCast =
explicitCastExpr(anyOf(MatchExprPtr, MatchExprRefTypeDef,
@@ -216,8 +217,9 @@ void MemoryUnsafeCastChecker::checkASTCodeBody(const Decl
*D,
auto MatchCallPtrVoidArgCast = callExpr(
hasAnyArgument(anyOf(VoidPtrCast,
explicitCastExpr(hasSourceExpression(VoidPtrCast)))),
-
hasTypePointingTo(cxxRecordDecl(isDerivedFrom(isSameDeclAsBoundNode(BaseNode)))
- .bind(DerivedNode)));
+ hasTypePointingTo(
+ cxxRecordDecl(isDerivedFrom(isSameDeclAsBoundNode(BaseNode)))
+ .bind(DerivedNode)));
auto CallArgCast = stmt(MatchCallPtrVoidArgCast);
auto MatchesCallArgCast = match(stmt(forEachDescendant(CallArgCast)),
*D->getBody(), AM.getASTContext());
@@ -229,22 +231,23 @@ void MemoryUnsafeCastChecker::checkASTCodeBody(const Decl
*D,
hasSourceExpression(
hasTypePointingTo(cxxRecordDecl().bind(FromCastNode))),
hasTypePointingTo(cxxRecordDecl().bind(ToCastNode)),
- unless(anyOf(hasTypePointingTo(cxxRecordDecl(
-
isSameOrDerivedFrom(isSameDeclAsBoundNode(FromCastNode)))),
- hasSourceExpression(hasTypePointingTo(cxxRecordDecl(
-
isSameOrDerivedFrom(isSameDeclAsBoundNode(ToCastNode))))))));
+ unless(anyOf(
+ hasTypePointingTo(cxxRecordDecl(
+ isSameOrDerivedFrom(isSameDeclAsBoundNode(FromCastNode)))),
+ hasSourceExpression(hasTypePointingTo(cxxRecordDecl(
+ isSameOrDerivedFrom(isSameDeclAsBoundNode(ToCastNode))))))));
auto MatchExprPtrObjCUnrelatedTypes = allOf(
hasSourceExpression(ignoringImpCasts(hasType(objcObjectPointerType(
pointee(hasDeclaration(objcInterfaceDecl().bind(FromCastNode))))))),
ignoringImpCasts(hasType(objcObjectPointerType(
pointee(hasDeclaration(objcInterfaceDecl().bind(ToCastNode)))))),
unless(anyOf(
- ignoringImpCasts(hasType(
- objcObjectPointerType(pointee(hasDeclaration(objcInterfaceDecl(
-
isSameOrDerivedFrom(isSameDeclAsBoundNode(FromCastNode)))))))),
- hasSourceExpression(ignoringImpCasts(hasType(
- objcObjectPointerType(pointee(hasDeclaration(objcInterfaceDecl(
-
isSameOrDerivedFrom(isSameDeclAsBoundNode(ToCastNode))))))))))));
+ ignoringImpCasts(hasType(objcObjectPointerType(
+ pointee(hasDeclaration(objcInterfaceDecl(isSameOrDerivedFrom(
+ isSameDeclAsBoundNode(FromCastNode)))))))),
+ hasSourceExpression(ignoringImpCasts(hasType(objcObjectPointerType(
+ pointee(hasDeclaration(objcInterfaceDecl(isSameOrDerivedFrom(
+ isSameDeclAsBoundNode(ToCastNode))))))))))));
auto MatchExprRefTypeDefUnrelated = allOf(
hasSourceExpression(hasType(hasUnqualifiedDesugaredType(recordType(
hasDeclaration(decl(cxxRecordDecl().bind(FromCastNode))))))),
@@ -252,11 +255,11 @@ void MemoryUnsafeCastChecker::checkASTCodeBody(const Decl
*D,
recordType(hasDeclaration(decl(cxxRecordDecl().bind(ToCastNode)))))),
unless(anyOf(
hasType(hasUnqualifiedDesugaredType(
- recordType(hasDeclaration(decl(cxxRecordDecl(
-
isSameOrDerivedFrom(isSameDeclAsBoundNode(FromCastNode)))))))),
+ recordType(hasDeclaration(decl(cxxRecordDecl(isSameOrDerivedFrom(
+ isSameDeclAsBoundNode(FromCastNode)))))))),
hasSourceExpression(hasType(hasUnqualifiedDesugaredType(
- recordType(hasDeclaration(decl(cxxRecordDecl(
-
isSameOrDerivedFrom(isSameDeclAsBoundNode(ToCastNode))))))))))));
+ recordType(hasDeclaration(decl(cxxRecordDecl(isSameOrDerivedFrom(
+ isSameDeclAsBoundNode(ToCastNode))))))))))));
auto ExplicitCastUnrelated =
explicitCastExpr(anyOf(MatchExprPtrUnrelatedTypes,
``````````
</details>
https://github.com/llvm/llvm-project/pull/231833
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits