[PATCH] D24383: Add addOrMerge interface to tooling::Replacements.

Daniel Jasper via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 12 13:55:46 PDT 2016


djasper added a comment.

The problem is that it is implicit behavior, that's not easy to understand. What's worse is that the behavior of add and merge would fundamentally be reverse. If you add two inserts at the same location, the first one would come first. If you merge them, the second one would come first.

And you parentheses example is actually a good one. The tool you would write for that would insert the parentheses pair-wise, e.g. in an ASTMatchFinder callback. Without extra effort, the opening parentheses and the closing parentheses would be inserted in the same order, which is wrong. Doesn't matter as they are identical, but assume you'd want to add () and [].. You'd likely end up with "([...)]".

We should definitely provide ways to support such use cases, but I think the default behavior should for now be to report an error.


https://reviews.llvm.org/D24383





More information about the cfe-commits mailing list