[PATCH] D101614: [clang-tidy][NFC] Simplify a lot of bugprone-sizeof-expression matchers
Nathan James via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed May 12 05:18:55 PDT 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4c59ab34f7bd: [clang-tidy][NFC] Simplify a lot of bugprone-sizeof-expression matchers (authored by njames93).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D101614/new/
https://reviews.llvm.org/D101614
Files:
clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
Index: clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
@@ -90,11 +90,8 @@
const auto IntegerCallExpr = ignoringParenImpCasts(
callExpr(anyOf(hasType(isInteger()), hasType(enumType())),
unless(isInTemplateInstantiation())));
- const auto SizeOfExpr = expr(anyOf(
- sizeOfExpr(
- has(hasUnqualifiedDesugaredType(type().bind("sizeof-arg-type")))),
- sizeOfExpr(has(expr(hasType(
- hasUnqualifiedDesugaredType(type().bind("sizeof-arg-type"))))))));
+ const auto SizeOfExpr = sizeOfExpr(hasArgumentOfType(
+ hasUnqualifiedDesugaredType(type().bind("sizeof-arg-type"))));
const auto SizeOfZero =
sizeOfExpr(has(ignoringParenImpCasts(integerLiteral(equals(0)))));
@@ -184,9 +181,8 @@
Finder->addMatcher(
binaryOperator(matchers::isRelationalOperator(),
hasOperands(ignoringParenImpCasts(SizeOfExpr),
- ignoringParenImpCasts(anyOf(
- integerLiteral(equals(0)),
- integerLiteral(isBiggerThan(0x80000))))))
+ ignoringParenImpCasts(integerLiteral(anyOf(
+ equals(0), isBiggerThan(0x80000))))))
.bind("sizeof-compare-constant"),
this);
}
@@ -207,18 +203,15 @@
const auto ElemType =
arrayType(hasElementType(recordType().bind("elem-type")));
const auto ElemPtrType = pointerType(pointee(type().bind("elem-ptr-type")));
- const auto NumType = hasCanonicalType(
- type(anyOf(ElemType, ElemPtrType, type())).bind("num-type"));
- const auto DenomType = hasCanonicalType(type().bind("denom-type"));
Finder->addMatcher(
- binaryOperator(hasOperatorName("/"),
- hasLHS(expr(ignoringParenImpCasts(
- anyOf(sizeOfExpr(has(NumType)),
- sizeOfExpr(has(expr(hasType(NumType)))))))),
- hasRHS(expr(ignoringParenImpCasts(
- anyOf(sizeOfExpr(has(DenomType)),
- sizeOfExpr(has(expr(hasType(DenomType)))))))))
+ binaryOperator(
+ hasOperatorName("/"),
+ hasLHS(ignoringParenImpCasts(sizeOfExpr(hasArgumentOfType(
+ hasCanonicalType(type(anyOf(ElemType, ElemPtrType, type()))
+ .bind("num-type")))))),
+ hasRHS(ignoringParenImpCasts(sizeOfExpr(
+ hasArgumentOfType(hasCanonicalType(type().bind("denom-type")))))))
.bind("sizeof-divide-expr"),
this);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101614.344778.patch
Type: text/x-patch
Size: 2847 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210512/b0286794/attachment.bin>
More information about the cfe-commits
mailing list