[PATCH] D13516: Fix overlapping replacements in clang-tidy.

Daniel Jasper via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 14 08:26:03 PDT 2015


djasper added a comment.

There might be an even easier algorithm:

What if we put all start and end points into a single sorted list. Identical start points are sorted by decreasing end points and identical end points are sorted by increasing start points. Now do a single sweep and simply count the total number of starts vs. the total number of ends, call this C (if you encounter a start point, ++C, if you encounter an end point, --C). If you encounter a start-point and C != 0, mark the interval and corresponding Fixit as inapplicable. Similarly if you encounter an end point and C != 1, mark the fixit as inapplicable. Basically, this does a single sweep over all fixits and marks the ones as bad that have either their start point or their endpoint within a different interval.

(Take this as an additional idea, if you have an existing algorithm that you like better, I am fine with keeping that. Just wanted to give my additional thoughts).


http://reviews.llvm.org/D13516





More information about the cfe-commits mailing list