diff options
Diffstat (limited to 'clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.cpp')
-rw-r--r-- | clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.cpp index 15ea27a4462..9dcd7c4a370 100644 --- a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.cpp +++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.cpp @@ -22,9 +22,11 @@ void ProBoundsPointerArithmeticCheck::registerMatchers(MatchFinder *Finder) { // Flag all operators +, -, +=, -=, ++, -- that result in a pointer Finder->addMatcher( - binaryOperator(anyOf(hasOperatorName("+"), hasOperatorName("-"), - hasOperatorName("+="), hasOperatorName("-=")), - hasType(pointerType())) + binaryOperator( + anyOf(hasOperatorName("+"), hasOperatorName("-"), + hasOperatorName("+="), hasOperatorName("-=")), + hasType(pointerType()), + unless(hasLHS(ignoringImpCasts(declRefExpr(to(isImplicit())))))) .bind("expr"), this); @@ -36,8 +38,10 @@ void ProBoundsPointerArithmeticCheck::registerMatchers(MatchFinder *Finder) { // Array subscript on a pointer (not an array) is also pointer arithmetic Finder->addMatcher( - arraySubscriptExpr(hasBase(ignoringImpCasts(anyOf(hasType(pointerType()), - hasType(decayedType(hasDecayedType(pointerType()))))))) + arraySubscriptExpr( + hasBase(ignoringImpCasts( + anyOf(hasType(pointerType()), + hasType(decayedType(hasDecayedType(pointerType()))))))) .bind("expr"), this); } |