summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.cpp')
-rw-r--r--clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.cpp
index d664b6401ae..dfbb51bed12 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.cpp
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.cpp
@@ -21,12 +21,16 @@ void ProBoundsPointerArithmeticCheck::registerMatchers(MatchFinder *Finder) {
if (!getLangOpts().CPlusPlus)
return;
+ const auto AllPointerTypes = anyOf(
+ hasType(pointerType()), hasType(autoType(hasDeducedType(pointerType()))),
+ hasType(decltypeType(hasUnderlyingType(pointerType()))));
+
// Flag all operators +, -, +=, -=, ++, -- that result in a pointer
Finder->addMatcher(
binaryOperator(
anyOf(hasOperatorName("+"), hasOperatorName("-"),
hasOperatorName("+="), hasOperatorName("-=")),
- hasType(pointerType()),
+ AllPointerTypes,
unless(hasLHS(ignoringImpCasts(declRefExpr(to(isImplicit()))))))
.bind("expr"),
this);
@@ -41,7 +45,7 @@ void ProBoundsPointerArithmeticCheck::registerMatchers(MatchFinder *Finder) {
Finder->addMatcher(
arraySubscriptExpr(
hasBase(ignoringImpCasts(
- anyOf(hasType(pointerType()),
+ anyOf(AllPointerTypes,
hasType(decayedType(hasDecayedType(pointerType())))))))
.bind("expr"),
this);
OpenPOWER on IntegriCloud