[cfe-dev] (no subject)

Eric Liu via cfe-dev cfe-dev at lists.llvm.org
Mon Nov 14 03:30:28 PST 2016


A common way is to use the file path in a replacement, i.e.
`Replaces[R.getFilePath()].add(R)`. Note that clang::tooling::Replacements
<https://github.com/llvm-mirror/clang/blob/master/include/clang/Tooling/Core/Replacement.h#L146>
is now implemented as a class instead of a std::set.

In general, `formatAndApplyAllReplacements` is a function you would use to
apply changes while format changed code *after* you've got all replacements.
A sample usage can be found in clang-move
<https://github.com/llvm-mirror/clang-tools-extra/blob/master/clang-move/tool/ClangMoveMain.cpp#L137>.
And I think the interface's comment does explain its purpose. Which
specific part did you find confusing? I'm happy to improve the doc :)

- Eric
On Mon, Nov 14, 2016 at 12:04 PM Manuel Klimek <klimek at google.com> wrote:

> +eric
>
>
> On Sat, Nov 12, 2016 at 10:45 AM Steven Lu via cfe-dev <
> cfe-dev at lists.llvm.org> wrote:
>
> I've updated clang from revision 254425 to 286122, and RefactoringTool::getReplacements()
> now produces a map of files to replacements.
>
> My original code implements a MatchFinder::MatchCallback which takes a
> pointer to the return value of RefactoringTool::getReplacements() and
> simply inserts Replacements, now it is not clear how I am to perform the
> insertion, I cannot tell now if there is some canonical way to determine
> the filename string to save a particular Replacement under.
>
> I have also found the function formatAndApplyAllReplacements which I'm
> having trouble finding doc/instructions for and seems to be a highest-level
> function that I should use, but it doesnt seem to help address this
> problem.
>
> I wonder if someone could do a quick rundown of how to use the interface
> in a proper way.
>
> Thanks
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20161114/5c77c5c9/attachment.html>


More information about the cfe-dev mailing list