The InitListExpr subtree is visited twice, this caused the check to do multiple replacements. Added a set to avoid it.
Details
Diff Detail
Event Timeline
Anyway, I just found that this needs a few more changes (it still does duplicated replacementes inside some macros, and I have to find out why), so don't bother with this for now.
clang-tidy/modernize/LoopConvertUtils.cpp | ||
---|---|---|
465 | Yes, because SmallSet doesn't provide a way to iterate over its members. | |
clang-tidy/modernize/LoopConvertUtils.h | ||
211 | I used std::tie here at first, but it didn't work because it tries to bind a RValue to a non-const ref. |
I think this solves the duplication problem. And I think is clearer and cheaper than what I was trying to do before.
clang-tidy/modernize/LoopConvertUtils.cpp | ||
---|---|---|
465 | There should be no need for a while() getExpansionLoc should always go to the most expanded location location. | |
clang-tidy/modernize/LoopConvertUtils.h | ||
280–281 | The result seems to be never used? | |
342 | I don't think putting Set into the name helps. UsageLocations perhaps? |
clang-tidy/modernize/LoopConvertUtils.cpp | ||
---|---|---|
463–470 | Now that I take a step back - shouldn't we go to the *spelling* location to deduplicate? The spelling location is the location that will be edited, after all. |
Note that I think we should add a regression test that will work with the spelling loc but not with the expansion loc.
Something like:
#define A \
<loop1> \ <loop2>
A
Please use std::tie instead of std::make_tuple to avoid copies.