Author: Nathan James Date: 2021-05-12T13:18:41+01:00 New Revision: 4c59ab34f7bda74296e42ef7ea8d83828cb45558
URL: https://github.com/llvm/llvm-project/commit/4c59ab34f7bda74296e42ef7ea8d83828cb45558 DIFF: https://github.com/llvm/llvm-project/commit/4c59ab34f7bda74296e42ef7ea8d83828cb45558.diff LOG: [clang-tidy][NFC] Simplify a lot of bugprone-sizeof-expression matchers There should be a follow up to this for changing the traversal mode, but some of the tests don't like that. Reviewed By: steveire Differential Revision: https://reviews.llvm.org/D101614 Added: Modified: clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp Removed: ################################################################################ diff --git a/clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp index 8a6f7da36196..44a19b1f824a 100644 --- a/clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp @@ -90,11 +90,8 @@ void SizeofExpressionCheck::registerMatchers(MatchFinder *Finder) { 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 @@ void SizeofExpressionCheck::registerMatchers(MatchFinder *Finder) { 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 @@ void SizeofExpressionCheck::registerMatchers(MatchFinder *Finder) { 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); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits