Inside a range-based for-loop over an array, the compiler
generates pointer arithmetic (end = array + size). Don't flag this.
Details
Details
- Reviewers
aaron.ballman alexfh bkramer sbenza - Commits
- rG4241cedb68d6: [clang-tidy] cppcoreguidelines-pro-bounds-pointer-arithmetic: ignore generated…
rCTE254182: [clang-tidy] cppcoreguidelines-pro-bounds-pointer-arithmetic: ignore generated…
rL254182: [clang-tidy] cppcoreguidelines-pro-bounds-pointer-arithmetic: ignore…
Diff Detail
Diff Detail
- Repository
- rL LLVM
Event Timeline
clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.cpp | ||
---|---|---|
19 ↗ | (On Diff #39957) | This same code exists in ProBoundsArrayToPointerDecayCheck.cpp and should not be duplicated. I kind of wonder whether this belongs in clangTidyUtils, or in the AST matchers. I think for right now, clangTidyUtils because they still seem a little niche. |
Comment Actions
It may be more effective to filter out expressions that operate on implicit variables, e.g. by adding this constraint to the binaryOperator matcher:
unless(hasLHS(ignoringImpCasts(declRefExpr(to(isImplicit())))))
(maybe also for RHS).
The benefit of this would be that it doesn't use hasAncestor/hasDescendant which can be rather expensive.
Comment Actions
Sorry for the delay, I was sick and didn't read mail.
Looks good with a nit. Thanks for the fix!
clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.cpp | ||
---|---|---|
28 ↗ | (On Diff #40448) | nit: Does this still fit to 80 characters? I mean, clang-format, please ;) |