When the dereference operator returns a value that is trivially
copyable (like a pointer), copy it. After this change, modernize-loop-convert
check can be applied to the whole llvm source code without breaking any build
or test.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
clang-tidy/modernize/LoopConvertCheck.cpp | ||
---|---|---|
556–557 ↗ | (On Diff #34155) | I'd add (non-const): |
658–663 ↗ | (On Diff #34155) | Can you add a comment what FixerKind is in the else, so it's obvious why we don't want to do anything else in here? |
667 ↗ | (On Diff #34155) | Btw, upstream style is to just use implicit null checks; probably not something you wrote, but good to change while we're at it. |
clang-tidy/modernize/LoopConvertCheck.h | ||
28–44 ↗ | (On Diff #34155) | I find it somewhat distressing that the variable order is completely different. Perhaps it's time to pull out a struct that encapsulates the specific attributes of the loop (the bools)? |
clang-tidy/modernize/LoopConvertCheck.cpp | ||
---|---|---|
658–663 ↗ | (On Diff #34155) | What do you mean? We're still inside the "if (FixerKind == LFK_Iterator)". |
Add struct with the parameters of the replacement. Also fix a potential source of crashes from a previous patch.
clang-tidy/modernize/LoopConvertCheck.cpp | ||
---|---|---|
659–664 ↗ | (On Diff #34160) | Yes, but the arrays never return rvalues, and the iterator and pseudoarrays are "handled" in different parts in the code. I think I updated both of them, and I ensured that there was a test for each. |
clang-tidy/modernize/LoopConvertCheck.cpp | ||
---|---|---|
555–564 ↗ | (On Diff #34160) | a) please add a regression test for everything you find during development |
clang-tidy/modernize/LoopConvertCheck.cpp | ||
---|---|---|
659–664 ↗ | (On Diff #34160) | Ah, ok. I think that code is really hard to follow, and we'll want to refactor the flow (not in this patch though). |