The cppcoreguidelines-pro-bounds-pointer-arithmetic warns on all occassion where
pointer arithmetic is used, but does not check values where the pointer types
is deduced via `auto`. This patch adjusts this behaviour and solved
PR36489.
Details
- Reviewers
alexfh aaron.ballman hokein ilya-biryukov - Commits
- rG369e4fd353af: [clang-tidy] fix PR36489 - respect deduced pointer types from auto as well
rL337710: [clang-tidy] fix PR36489 - respect deduced pointer types from auto as well
rCTE337710: [clang-tidy] fix PR36489 - respect deduced pointer types from auto as well
Diff Detail
- Repository
- rCTE Clang Tools Extra
Event Timeline
clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.cpp | ||
---|---|---|
24 ↗ | (On Diff #153297) | Can anyOf be pushed inside hasType? (hasType(anyOf(pointerType(), autoType(...)))) |
clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.cpp | ||
---|---|---|
24 ↗ | (On Diff #153297) | Unfortunatly no. It is ambigous then. |
test/clang-tidy/cppcoreguidelines-pro-bounds-pointer-arithmetic-pr36489.cpp | ||
---|---|---|
4 ↗ | (On Diff #153297) | decltype(getPtr()) actually breaks the code. I have to look into this, but tomorrow or on the weekend. |
- fix decltype deduction with new matcher
I had to introduce a new matcher in clang for DecltypeType to reach its
underlying type. It would be better to have hasType resolve all these issues
but i dont know how much work that would be.
We can discuss that in the patch for the matcher i guess.
I don't think we want to modify hasType() -- that would strip off too much type information if it automatically reached through to the underlying type. However, we may want to consider adding something like hasUnderlyingType() that checks the matcher against each level of type sugar. I'm not certain this would be required for your patch, however.
I don't think we want to modify hasType() -- that would strip off too much type information if it automatically reached through to the underlying type. However, we may want to consider adding something like hasUnderlyingType() that checks the matcher against each level of type sugar. I'm not certain this would be required for your patch, however.
Yes, an additional facility that does not care how the type got produced (auto, decltype, written, template, ...) and just finds all places with that type.
Spurious whitespace change.