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
Event Timeline
clang-tidy/modernize/LoopConvertCheck.cpp | ||
---|---|---|
555–556 | I'd add (non-const): | |
659–664 | 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 | 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 | ||
35–49 | 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 | ||
---|---|---|
659–664 | 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 | 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 | a) please add a regression test for everything you find during development |
clang-tidy/modernize/LoopConvertCheck.cpp | ||
---|---|---|
659–664 | Ah, ok. I think that code is really hard to follow, and we'll want to refactor the flow (not in this patch though). |
Add a comment.