[cfe-dev] Get Replacements to FrontendAction

Manuel Klimek via cfe-dev cfe-dev at lists.llvm.org
Sun Aug 30 12:42:05 PDT 2015


On Sun, Aug 30, 2015 at 9:35 PM Daniel Dilts <diltsman at gmail.com> wrote:

> I'm manipulating the token stream in my action.  I don't believe that that
> is possible in AST matchers.
>

Yep, then just implement your own FrontendActionFactory - shouldn't be more
than 10 LOC :)


>
> On Sun, Aug 30, 2015 at 7:25 AM, Manuel Klimek <klimek at google.com> wrote:
>
>>
>>
>> On Thu, Aug 27, 2015 at 7:40 PM Daniel Dilts <diltsman at gmail.com> wrote:
>>
>>> I guess that I am doing something wrong.  This is my code:
>>>
>>>   RefactoringTool tool(optionsParser.getCompilations(),
>>> optionsParser.getSourcePathList());
>>>  MyAction action{tool};
>>>  auto a = tool.runAndSave(newFrontendActionFactory(&action).get());
>>>
>>> I am getting an error 'newASTConsumer': is not a member of 'MyAction'.
>>> It seems to want some kind of action factory, not an action.
>>>
>>
>> This doesn't work, because we need to be able to create multiple actions
>> - if you want to pass something to the action, you need to implement your
>> own FrontendActionFactory.
>> The question is why you need your own action - usually you'll want to use
>> an ASTMatchFinder with your own callback, in which case you hand the tool
>> to the callback, register the callback, and then use
>> newFrontendActionFactory(&match_finder).
>>
>>
>>>
>>> On Wed, Aug 26, 2015 at 9:19 PM, Manuel Klimek <klimek at google.com>
>>> wrote:
>>>
>>>> You hand the refactoring tool pointer to the Frontend action factory,
>>>> which then hands it to the Frontend action.
>>>>
>>>> On Wed, Aug 26, 2015, 6:29 PM Daniel Dilts via cfe-dev <
>>>> cfe-dev at lists.llvm.org> wrote:
>>>>
>>>>> I have a custom FrontendAction that I want to run using
>>>>> RefactoringTool::runAndSave().  runAndSave() takes a FrontendActionFactory
>>>>> and doesn't appear to have a way to pass parameters to the produced action.
>>>>>
>>>>> How does one get the replacements list from
>>>>> RefactoringTool::getReplacements() into their FrontendAction?
>>>>> _______________________________________________
>>>>> 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/20150830/eac0ca04/attachment.html>


More information about the cfe-dev mailing list