summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.cpp
diff options
context:
space:
mode:
authorMatthias Gehre <M.Gehre@gmx.de>2015-11-26 22:32:11 +0000
committerMatthias Gehre <M.Gehre@gmx.de>2015-11-26 22:32:11 +0000
commit4241cedb68d61d85dd12b64d6792d0277f9ff4b2 (patch)
tree0d2d5095e679f02f58253ff9bb674d137eaeeebb /clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.cpp
parent2a3ca840e34ea49a96932b822bf772b8d9ec6bec (diff)
downloadbcm5719-llvm-4241cedb68d61d85dd12b64d6792d0277f9ff4b2.tar.gz
bcm5719-llvm-4241cedb68d61d85dd12b64d6792d0277f9ff4b2.zip
[clang-tidy] cppcoreguidelines-pro-bounds-pointer-arithmetic: ignore generated pointer arithmetic
Summary: Inside a range-based for-loop over an array, the compiler generates pointer arithmetic (end = array + size). Don't flag this. Reviewers: alexfh, sbenza, bkramer, aaron.ballman Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D14582 llvm-svn: 254182
Diffstat (limited to 'clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.cpp')
-rw-r--r--clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.cpp14
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);
}
OpenPOWER on IntegriCloud