[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cfe-dev
Subject:    Re: [cfe-dev] Get Replacements to FrontendAction
From:       Manuel Klimek via cfe-dev <cfe-dev () lists ! llvm ! org>
Date:       2015-08-30 19:42:05
Message-ID: CAOsfVvkVsyt6xDcO8BcXds1oFMJdYtdSsZWn9UpqrnwDUnfQNQ () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


On Sun, Aug 30, 2015 at 9:35 PM Daniel Dilts <diltsman@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@google.com> wrote:
>
>>
>>
>> On Thu, Aug 27, 2015 at 7:40 PM Daniel Dilts <diltsman@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@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@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@lists.llvm.org
>>>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>>>>>
>>>>
>>>
>

[Attachment #5 (text/html)]

<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Sun, Aug 30, 2015 at 9:35 \
PM Daniel Dilts &lt;<a href="mailto:diltsman@gmail.com">diltsman@gmail.com</a>&gt; \
wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 \
.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I&#39;m manipulating \
the token stream in my action.   I don&#39;t believe that that is possible in AST \
matchers.</div></blockquote><div><br></div><div>Yep, then just implement your own \
FrontendActionFactory - shouldn&#39;t be more than 10 LOC :)</div><div>  \
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"><div class="gmail_extra"><br><div class="gmail_quote">On Sun, \
Aug 30, 2015 at 7:25 AM, Manuel Klimek <span dir="ltr">&lt;<a \
href="mailto:klimek@google.com" target="_blank">klimek@google.com</a>&gt;</span> \
wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px \
#ccc solid;padding-left:1ex"><div dir="ltr"><br><br><div \
class="gmail_quote"><span><div dir="ltr">On Thu, Aug 27, 2015 at 7:40 PM Daniel Dilts \
&lt;<a href="mailto:diltsman@gmail.com" target="_blank">diltsman@gmail.com</a>&gt; \
wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 \
.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>I guess that I \
am doing something wrong.   This is my code:</div><div><br></div><div>   <font \
color="#2b91af" face="Consolas" size="2"><font color="#2b91af" face="Consolas" \
size="2"><font color="#2b91af" face="Consolas" \
size="2">RefactoringTool</font></font></font><font face="Consolas" size="2"><font \
face="Consolas" size="2"> tool(optionsParser.getCompilations(), \
optionsParser.getSourcePathList());</font></font></div><div><font face="Consolas" \
size="2"><font face="Consolas" size="2"> </font></font><font color="#2b91af" \
face="Consolas" size="2"><font color="#2b91af" face="Consolas" size="2"><font \
color="#2b91af" face="Consolas" size="2">  MyAction</font></font></font><font \
face="Consolas" size="2"><font face="Consolas" size="2"> \
action{tool};</font></font><font face="Consolas" size="2"><font face="Consolas" \
size="2"> </font></font></div><div><font face="Consolas">  </font><font \
color="#0000ff" size="2"><font color="#0000ff" size="2"><font color="#0000ff" \
face="Consolas" size="2">auto</font></font></font><font size="2"><font \
face="Consolas" size="2"> a = \
tool.runAndSave(newFrontendActionFactory(&amp;action).get());</font></font></div><div><font \
face="Consolas"><br></font></div><div><font face="Consolas">I am getting an error \
&#39;newASTConsumer&#39;: is not a member of &#39;MyAction&#39;.   It seems to want \
some kind of action factory, not an \
action.</font></div></div></blockquote><div><br></div></span><div>This doesn&#39;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.</div><div>The question is why you need your own action - \
usually you&#39;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(&amp;match_finder).</div><span><div>  </div><blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, \
Aug 26, 2015 at 9:19 PM, Manuel Klimek <span dir="ltr">&lt;<a \
href="mailto:klimek@google.com" target="_blank">klimek@google.com</a>&gt;</span> \
wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px \
#ccc solid;padding-left:1ex"><p dir="ltr">You hand the refactoring tool pointer to \
the Frontend action factory, which then hands it to the Frontend action. </p> \
<br><div class="gmail_quote"><span><div dir="ltr">On Wed, Aug 26, 2015, 6:29 PM  \
Daniel Dilts via cfe-dev &lt;<a href="mailto:cfe-dev@lists.llvm.org" \
target="_blank">cfe-dev@lists.llvm.org</a>&gt; wrote:<br></div></span><blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"><span><div dir="ltr"><div>I have a custom FrontendAction that \
I want to run using RefactoringTool::runAndSave().   runAndSave() takes a \
FrontendActionFactory and doesn&#39;t appear to have a way to pass parameters to the \
produced action.</div><div><br></div><div>How does one get the replacements list from \
RefactoringTool::getReplacements() into their FrontendAction?</div></div></span> \
_______________________________________________<br> cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" \
target="_blank">cfe-dev@lists.llvm.org</a><br> <a \
href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" \
target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br> \
</blockquote></div> </blockquote></div><br></div>
</blockquote></span></div></div>
</blockquote></div><br></div>
</blockquote></div></div>


[Attachment #6 (text/plain)]

_______________________________________________
cfe-dev mailing list
cfe-dev@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic