[PATCH] D24717: Merge deletions that are contained in a larger deletion.

Eric Liu via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 19 08:21:15 PDT 2016


ioeric added a comment.

In https://reviews.llvm.org/D24717#546279, @djasper wrote:

> I actually think this is a good example. So lets assume we'd write a tool to fully quote binary expressions, e.g. that turns
>
>   if (a * b + c * d == 10) ...
>   
>
> into
>
>   if (((a * b) + (c * d)) == 10) ...
>   
>
> So, here, we would be inserting two "(" and two ")" at the same locations. And, as you correctly mention, the order doesn't matter because we are inserting the same string twice. I think this is actually good behavior.


I agree that this is good behavior.

> Deduplication is an interesting concern, but I think we probably want to handle that at a different layer. E.g. in the use case above, deduplicating would be quite fatal :).


Okay, it does make more sense to handle deduplication in a different layer.

So, with this assumption, the implementation should be much easier now: when there is conflict found in `add`, check this condition. If `A` and `B` are `order-dependent` as defined above, we then `merge(getReplacementInChangedCode(B))` into the set.


https://reviews.llvm.org/D24717





More information about the cfe-commits mailing list