llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-tidy

@llvm/pr-subscribers-clang-tools-extra

Author: Donát Nagy (NagyDonat)

<details>
<summary>Changes</summary>

This commit eliminates a redundant matcher subexpression from the 
implementation of the "sizeof-pointer-to-aggregate" part of the clang-tidy 
check `bugprone-sizeof-expression`.

I'm fairly certain that anything that was previously matched by the deleted 
matcher `StructAddrOfExpr` is also covered by the more general 
`PointerToStructExpr` (which remains in the same `anyOf`).

This commit is made to "prepare the ground" for a followup change that would 
merge the functionality of the Clang Static Analyzer checker 
`alpha.core.SizeofPtr` into this clang-tidy check.

---
Full diff: https://github.com/llvm/llvm-project/pull/93024.diff


1 Files Affected:

- (modified) clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp 
(+3-6) 


``````````diff
diff --git a/clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
index a1cffbc666199..f119711638111 100644
--- a/clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
@@ -147,9 +147,6 @@ void SizeofExpressionCheck::registerMatchers(MatchFinder 
*Finder) {
     const auto PointerToArrayExpr = ignoringParenImpCasts(
         hasType(hasCanonicalType(pointerType(pointee(arrayType())))));
 
-    const auto StructAddrOfExpr = unaryOperator(
-        hasOperatorName("&"), hasUnaryOperand(ignoringParenImpCasts(
-                                  hasType(hasCanonicalType(recordType())))));
     const auto PointerToStructType =
         hasUnqualifiedDesugaredType(pointerType(pointee(recordType())));
     const auto PointerToStructExpr = ignoringParenImpCasts(expr(
@@ -171,9 +168,9 @@ void SizeofExpressionCheck::registerMatchers(MatchFinder 
*Finder) {
                                            has(ArrayOfPointersExpr)))))))),
              sizeOfExpr(has(ArrayOfSamePointersZeroSubscriptExpr)));
 
-    Finder->addMatcher(expr(anyOf(sizeOfExpr(has(ignoringParenImpCasts(anyOf(
-                                      ArrayCastExpr, PointerToArrayExpr,
-                                      StructAddrOfExpr, 
PointerToStructExpr)))),
+    Finder->addMatcher(expr(anyOf(sizeOfExpr(has(ignoringParenImpCasts(
+                                      anyOf(ArrayCastExpr, PointerToArrayExpr,
+                                            PointerToStructExpr)))),
                                   sizeOfExpr(has(PointerToStructType))),
                             unless(ArrayLengthExprDenom))
                            .bind("sizeof-pointer-to-aggregate"),

``````````

</details>


https://github.com/llvm/llvm-project/pull/93024
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to