This patch fixes incorrect array name generation for a cppcoreguidelines-pro-bounds-constant-array-index warning.
Motivation: https://bugs.llvm.org/show_bug.cgi?id=38510.
Details
- Reviewers
aaron.ballman JonasToth omtcyfz
Diff Detail
- Repository
- rCTE Clang Tools Extra
- Build Status
Buildable 26780 Build 26779: arc lint + arc unit
Event Timeline
For now I just updated tests. The problem is in BaseRange definition, as it holds EndLoc and BeginLoc pointing to the beginning of ArrayExpression base https://github.com/llvm-mirror/clang-tools-extra/blob/e0441f6939da38f26bea9c1d75bb33024daa4e40/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp#L78. I'm investigating this.
Thank you for working on this!
Could you please run the check over LLVM or any other significant codebase once you have the fix implemented and report if the transformation still breaks code?
Sorry for the long delay!
I have one question about a slighty different code constellation.
std::optional<std::array<int, 4>> my_array; for(int i = 0; i < 42; ++i) (*my_array)[i] = 42;
Will this be fixed properly?
for(int i = 0; i < 42; ++i) gsl::at(*my_array, i) = 42;
If the braces in (*my_array) would be moved into the function that is ok as well.
This is just of general interest and should not block this patch in my opinion, as its a different bug.