<html>
<head></head>
<body>
<p>Hi,</p>
<blockquote class="replyBlock" style="border-left: 2px solid #000083; margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><p>Neither :) Just create an object in main(), and hand a pointer to that object to your callback - then call stuff on it from the match callback.</p>
</blockquote><p>Ok, ok, that was the problem.</p>
<blockquote class="replyBlock" style="border-left: 2px solid #000083; margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div>> <em>1. I create a MatchFinder.<br />> 2. Then, I add two different matchers to the same callback.<br />> 3. I call run. <br />><br />> My questions are:<br />> 1. How many times is called the run method? Every time the MatchFinder finds a node to match?</em></div><div><em><br /></em></div><div>Yes, each time either matcher accepts a node.<em><br /></em></div><div>> <em>2. The object callback I add to MatchFinder is created more than once? When it is deleted?</em></div><div><em><br /></em></div><div>You (the user) are the one responsible for creating and destroying the callback object. Usually what we do is allocate it on the stack (and pass it the appropriate arguments, of course), and then pass its address to MatchFinder. MatchFinder doesn't create, copy or delete your callback object, so it is safe to store state in the callback.<em><br /> </em></div><div>> <em>Could you explain better "if the second matcher has no deps on the information collected by matcher1"?</em></div><div><em><br /></em></div><div>deps = dependencies<em><br /></em></div><div><em><br /></em></div><div>Gabor</div></blockquote><p>Thanks for your answers Gabor.</p>
<br/>
<p>I have decided to follow up the advice of Manuel and I have created a MatchFinder object with all the matchers and a single MatchCallback object. So now, I'm in my run() method and I want to know which matcher was bound. So I think the only way to know this is to ask:<br/>
if (Result.Nodes.getNodeAs<clang::CXXConstructorDecl>("matcher1")){<br /> ...<br /> }<br /> else if(Result.Nodes.getNodeAs<clang::CXXRecordDecl>("matcher2")){<br /> ... <br /> }<br/>
Notice that I'm retrieving different classes of nodes (clang::CXXConstructorDecl, clang::CXXRecordDecl...) In spite of this fact, I want to process all the nodes in the same way except from a subtle difference and I was asking myself if there is a better way I can do something like this:<br/>
if (Result.Nodes.getNodeAs<clang::CXXConstructorDecl>("matcher1")){<br />   ...<br />  process(Result.Nodes.getNodeAs<clang::CXXConstructorDecl>("matcher1"))<br/>
}<br /> else if(Result.Nodes.getNodeAs<clang::CXXRecordDecl>("matcher2")){<br />  ...<br />  process(Result.Nodes.getNodeAs<clang::CXXRecordDecl>("matcher2"))<br /> }<br /> ...</p>
<p>template<typename T><br /> void process(const T* Node){<br /> ...<br /> }</p>
<p>Regards,</p>
<p>Pedro</p>
<br/>
<br/>
<div dir="ltr"><div>Hi,</div><div>> <em>1. I create a MatchFinder.<br />> 2. Then, I add two different matchers to the same callback.<br />> 3. I call run. <br />><br />> My questions are:<br />> 1. How many times is called the run method? Every time the MatchFinder finds a node to match?</em></div><div><em><br /></em></div><div>Yes, each time either matcher accepts a node.<em><br /></em></div><div>> <em>2. The object callback I add to MatchFinder is created more than once? When it is deleted?</em></div><div><em><br /></em></div><div>You (the user) are the one responsible for creating and destroying the callback object. Usually what we do is allocate it on the stack (and pass it the appropriate arguments, of course), and then pass its address to MatchFinder. MatchFinder doesn't create, copy or delete your callback object, so it is safe to store state in the callback.<em><br /> </em></div><div>> <em>Could you explain better "if the second matcher has no deps on the information collected by matcher1"?</em></div><div><em><br /></em></div><div>deps = dependencies<em><br /></em></div><div><em><br /></em></div><div>Gabor</div></div><p><br /><br />2013/5/8 Pedro Delgado Perez <span dir="ltr"><<a href="https://webmail-alum.uca.es/webmerlin/compose.do?destinatario=pedro.delgadoperez@mail.uca.es" target="vEmailIDmailTo">pedro.delgadoperez@mail.uca.es</a>></span><br/>
Hi,<br/>
Thanks for all your support. I'm going to respond all your contributions little by little:</p>
<div class="im"><blockquote style="border-left: 2px solid #000083; margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><p><span style="font-size: 12.727272033691406px;">You can execute Matcher1 first, and when it returns, you start executing Matcher2. I'm not sure what your problem is exactly. (Of course, this will also mean that you will traverse the whole AST twice, which can potentially be very expensive.)</span></p>
</blockquote></div><p>Ok. What I don't understand quite well is the order in the execution.<br/>
1. I create a MatchFinder.<br /> 2. Then, I add two different matchers to the same callback.<br /> 3. I call run. <br/>
My questions are:<br /> 1. How many times is called the run method? Every time the MatchFinder finds a node to match?<br /> 2. The object callback I add to MatchFinder is created more than once? When it is deleted? The problem is that I create the object callback with an argument (a constructor method with an argument, not the default constructor) and store it in a variable member. However, when the run method executes, the value of the variable member is lost and I can't understand the problem.</p>
<div class="im"><br /><blockquote style="border-left: 2px solid #000083; margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><p><span style="font-size: 12.727272033691406px;">Sorry, missed the comment in one of your more recent emails. So you basically want all matches by matcher1 to be found before all matchers by matcher2. I think the easiest way to do this is just have two MatchFinder classes. Add matcher1 and its callback to the first MatchFinder and call run(). Add matcher2 and its callback to the second MatchFinder and call run() after the first run() returns. You won't have to reparse the file but you will have to traverse the AST twice. There's not much you can do about this given the order you want. However, if the second matcher has no deps on the information collected by matcher1 you could just get away with a single MatchFinder and two callbacks that just store their finds in two vectors which you process after run returns</span></p>
</blockquote><blockquote style="border-left: 2px solid #000083; margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><p><span style="font-size: 12.727272033691406px;">I'm not sure what order you're interested in but you can create two match callbacks one to use for each matcher. The callbacks will be called in the order the nodes are found in the tree by doing a depth-first pre-order traversal as is usual for RecursiveASTVisitor. If both matchers match a given node, the callbacks are called in the order they are registered. </span><br style="font-size: 12.727272033691406px;" /> <br style="font-size: 12.727272033691406px;" /><span style="font-size: 12.727272033691406px;">What sort of order are you looking for? </span></p>
</blockquote></div><p>I understand what you have explained until you say "two callbacks". Why could I want to have two different callbacks? Could you explain better "<span style="font-size: 12.727272033691406px;">if the second matcher </span><span style="font-size: 12.727272033691406px;">has no deps on the information collected by matcher1"?</span></p>
<div class="im"><blockquote style="border-left: 2px solid #000083; margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br /><div style="font-size: 12.727272033691406px;">What is often faster is to produce a superset of the information needed during the traversal / match phase, and then combine / filter the results after everything's done...</div></blockquote></div><div>That is a good solution, I suppose. I will have to study my case more in detail to determine whether this fit my problem or not. But, do you store all that information in global variables or in the callback object?</div><div class="im"><br /> <br /><p>.</p>
<blockquote style="border-left: 2px solid #000083; margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><p><span style="font-size: 12.727272033691406px;">You can just count how many times your match callback is called and then print that number after run() returns. </span></p>
</blockquote></div><p>Again, my problem is that I don't $when the match callback is called. <br/>
I hope I can end up getting the usage of all this with your help.<br/>
Pedro.</p>
<div><em>El dia 08 may 2013 12:10, Gábor Kozár <<a href="https://webmail-alum.uca.es/webmerlin/compose.do?destinatario=kozargabor@gmail.com" target="vEmailIDmailTo">kozargabor@gmail.com</a>> escribió:</em></div><div dir="ltr"><div>Hi,</div><div><div class="h5"><div>> <em>Ok, this also helps, but the problem is that I need to print something when all the nodes have been matched. So, is there a way I can check within onStartOfTranslationUnit() method if we have reached the end? I have just found this:</em></div><div><em><br /></em></div><div>onStartOfTranslationUnit() is - obviously - called at the start of each TU. I.e. this will be called after the previous TU has been completed, i.e. all nodes in it have been matched.<em><br /></em></div><div>> <em>clang::ast_matchers::MatchFinder::ParsingDoneTestCallback</em></div><div><em><br /></em></div><div>This is for testing purposes only, it's not recommended to use it.<em><br /></em></div><div>> <em>So, what you are saying is that I can't control the order the nodes are matched?</em></div><div><em><br /></em></div><div>No, you can't. You'll have to implement a RecursiveASTVisitor manually if you need this fine control.<em><br /> </em></div><div>> <em>What I'm trying to explain is that I need all the nodes bound with Matcher1 are treated before the execution of nodes bound with Matcher2 starts.</em></div><div><em><br /></em></div><div>You can execute Matcher1 first, and when it returns, you start executing Matcher2. I'm not sure what your problem is exactly. (Of course, this will also mean that you will traverse the whole AST twice, which can potentially be very expensive.)</div><div><em><br /></em></div><div>Gabor<em><br /></em></div></div></div></div><p><br /><br /></p>
<div class="gmail_quote"><div><div class="h5">2013/5/8 Pedro Delgado Perez <span dir="ltr"><<a href="https://webmail-alum.uca.es/webmerlin/compose.do?destinatario=pedro.delgadoperez@mail.uca.es" target="vEmailIDmailTo">pedro.delgadoperez@mail.uca.es</a>></span></div></div><blockquote class="gmail_quote" style="margin: 0 0 0 .8ex; border-left: 1px #ccc solid; padding-left: 1ex;"><div><div><div class="h5"><p>Hi,</p>
<div><blockquote style="border-left: 2px solid #000083; margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div>You collect information about the matches into e.g. a vector, and you can use the MatchCallback's onStartOfTranslationUnit to process the previous TU's matches.<em><br /> </em></div></blockquote></div><p>Ok, this also helps, but the problem is that I need to print something when <strong>all the nodes</strong> have been matched. So, is there a way I can check within onStartOfTranslationUnit() method if we have reached the end? I have just found this:<br/>
clang::ast_matchers::MatchFinder::ParsingDoneTestCallback<br/>
This is the implementation of the class:<br/>
<span>class </span><a title="Called when parsing is finished. Intended for testing only." href="http://fossies.org/dox/clang-3.2.src/classclang_1_1ast__matchers_1_1MatchFinder_1_1ParsingDoneTestCallback.html" target="_blank">ParsingDoneTestCallback</a> {</p>
<div><a name="13e855393759f756_13e835036b2d5d74_l00100" target="_blank"></a>  <span>public</span>:</div><div><a name="13e855393759f756_13e835036b2d5d74_l00101" target="_blank"></a><span> </span> <span>virtual</span> <a href="http://fossies.org/dox/clang-3.2.src/classclang_1_1ast__matchers_1_1MatchFinder_1_1ParsingDoneTestCallback.html#ab6018406e1835b0dcc7fa982e0836a55" target="_blank">~ParsingDoneTestCallback</a>();</div><div><a name="13e855393759f756_13e835036b2d5d74_l00102" target="_blank"></a><span> </span> <span>virtual</span> <span>void</span> <a href="http://fossies.org/dox/clang-3.2.src/classclang_1_1ast__matchers_1_1MatchFinder_1_1ParsingDoneTestCallback.html#a818b643aaad117bb86bcda80bba32ceb" target="_blank">run</a>() = 0;</div><div><a name="13e855393759f756_13e835036b2d5d74_l00103" target="_blank"></a>};</div><br /><p>Maybe I could redefine the run method. Do you think this may be my solution?</p>
<div><blockquote style="border-left: 2px solid #000083; margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div>So the matchers run regardless of whether you ever access the bound nodes. What this means is that your run() method will be called for every match, with the appropriate nodes bound to the names you defined. So a MatchResult only contains information about one single match (i.e. a subtree of the AST, if you will). Hope this clears things up.</div></blockquote></div><p>Um... I'm a bit mixed up at this moment. So, what you are saying is that I can't control the order the nodes are matched? For me that would be a problem because I need to keep an order in the execution. What I'm trying to explain is that I need all the nodes bound with Matcher1 are treated before the execution of nodes bound with Matcher2 starts.<br/>
Thanks,<br/>
Pedro.</p>
<div><em>El dia 07 may 2013 22:10, Gábor Kozár <<a href="https://webmail-alum.uca.es/webmerlin/compose.do?destinatario=kozargabor@gmail.com" target="vEmailIDmailTo">kozargabor@gmail.com</a>> escribió:</em></div></div></div><div><div><blockquote style="border-left: 2px solid #000083; margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div dir="ltr"><div>Hi,</div><div class="im"><div>><em>1. Imagine that I need to print something after all the nodes have been matched. For example, the number of nodes matched. How can I do that? </em></div><div><em><br /> </em></div></div><div class="im"><div>You collect information about the matches into e.g. a vector, and you can use the MatchCallback's onStartOfTranslationUnit to process the previous TU's matches.<em><br /></em></div></div><div class="im"><div>> <em>How does the 'run' method behave in this case? I mean that I don't know if it retrieves, one by one, all the nodes in applyMatch1 and ,after that, all the nodes in applyMatch2 or it matches one in applyMatch1 and then other in applyMatch2 in each iteration.</em></div><div><em><br /></em></div></div><div class="im"><div>So the matchers run regardless of whether you ever access the bound nodes. What this means is that your run() method will be called for every match, with the appropriate nodes bound to the names you defined. So a MatchResult only contains information about one single match (i.e. a subtree of the AST, if you will). Hope this clears things up.</div><div>Gabor</div></div></div><div class="gmail_extra"><br /><br /><div class="gmail_quote"><div class="im">2013/5/7 Pedro Delgado Perez <span dir="ltr"><<a href="https://webmail-alum.uca.es/webmerlin/compose.do?destinatario=pedro.delgadoperez@mail.uca.es" target="vEmailIDmailTo">pedro.delgadoperez@mail.uca.es</a>></span></div><blockquote class="gmail_quote" style="margin: 0 0 0 .8ex; border-left: 1px #ccc solid; padding-left: 1ex;"><div><div class="im"><p>Hi again,<br/>
Sorry to make so much questions, but I hope a good structure of my tool will save me a lot of time in future.<br/>
I'm using something like this in <a href="http://clang.llvm.org/docs/LibASTMatchersTutorial.html" target="_blank">http://clang.llvm.org/docs/LibASTMatchersTutorial.html</a>:</p>
<br /><pre style="overflow-x: auto; overflow-y: hidden; border: thin dotted #0c3762; margin: 0px 0px 12px; padding: 0.8em; background-color: #f0f0f0; color: #333333;"><span style="color: #007020; font-weight: bold;">class</span> <span style="color: #0e84b5; font-weight: bold;">LoopPrinter</span> <span style="color: #666666;">:</span> <span style="color: #007020; font-weight: bold;">public</span> <span>MatchFinder</span><span style="color: #666666;">::</span><span>MatchCallback</span> <span>{</span><span style="color: #007020; font-weight: bold;">public</span> <span style="color: #666666;">:</span>  <span style="color: #007020; font-weight: bold;">virtual</span> <span style="color: #902000;">void</span> <span>run</span><span>(</span><span style="color: #007020; font-weight: bold;">const</span> <span>MatchFinder</span><span style="color: #666666;">::</span><span>MatchResult</span> <span style="color: #666666;">&</span><span>Result</span><span>)</span> <span>{</span>    <span style="color: #007020; font-weight: bold;">if</span> <span>(</span><span style="color: #007020; font-weight: bold;">const</span> <span>ForStmt</span> <span style="color: #666666;">*</span><span>FS</span> <span style="color: #666666;">=</span> <span>Result</span><span>.</span><span>Nodes</span><span>.</span><span>getNodeAs</span><span style="color: #666666;"><</span><span>clang</span><span style="color: #666666;">::</span><span>ForStmt</span><span style="color: #666666;">></span><span>(</span><span style="color: #4070a0;">"forLoop"</span><span>))</span>      <span>FS</span><span style="color: #666666;">-></span><span>dump</span><span>();</span>  <span>}</span><span>};</span></pre><br /><p>So, now I have two questions:<br/>
1. Imagine that I need to print something after <strong>all</strong> the nodes have been matched. For example, the number of nodes matched. How can I do that? </p>
</div><p>2. Imagine that I have two methods within the run method to separate two kind of nodes I want to bind. Something like this:</p>
<div class="im"><br /> <br /><pre style="color: #333333; font-size: 11.818181991577148px; margin: 0px 0px 12px; overflow-x: auto; overflow-y: hidden; border: thin dotted #0c3762; padding: 0.8em; background-color: #f0f0f0;"><span style="color: #007020; font-weight: bold;"><br /> class</span> <span style="color: #0e84b5; font-weight: bold;">LoopPrinter</span> <span style="color: #666666;">:</span> <span style="color: #007020; font-weight: bold;">public</span> <span>MatchFinder</span><span style="color: #666666;">::</span><span>MatchCallback</span> <span>{</span><span style="color: #007020; font-weight: bold;">public</span> <span style="color: #666666;">:</span>  <span style="color: #007020; font-weight: bold;">virtual</span> <span style="color: #902000;">void</span> <span>run</span><span>(</span><span style="color: #007020; font-weight: bold;">const</span> <span>MatchFinder</span><span style="color: #666666;">::</span><span>MatchResult</span> <span style="color: #666666;">&</span><span>Result</span><span>)</span> <span>{</span>    <span>applyMatch1();<br /> </span>    applyMatch2();  <span>}<br /><br /></span>void <span style="color: #000000;">applyMatch1(){<br /> <span style="color: #007020; font-weight: bold;">if</span> <span>(</span><span style="color: #007020; font-weight: bold;">const</span> <span>ForStmt</span> <span style="color: #666666;">*</span><span>FS</span> <span style="color: #666666;">=</span> <span>Result</span><span>.</span><span>Nodes</span><span>.</span><span>getNodeAs</span><span style="color: #666666;"><</span><span>clang</span><span style="color: #666666;">::</span><span>ForStmt</span><span style="color: #666666;">></span><span>(</span><span style="color: #4070a0;">"forLoop__1"</span><span>))</span><span style="white-space: pre-wrap;"><br /> </span></span>}<br /><br />void apply2(){</pre><pre style="color: #333333; font-size: 11.818181991577148px; margin: 0px 0px 12px; overflow-x: auto; overflow-y: hidden; border: thin dotted #0c3762; padding: 0.8em;"><span style="color: #000000;"><span style="color: #007020; font-weight: bold;">if</span> <span>(</span><span style="color: #007020; font-weight: bold;">const</span> <span>ForStmt</span> <span style="color: #666666;">*</span><span>FS</span> <span style="color: #666666;">=</span> <span>Result</span><span>.</span><span>Nodes</span><span>.</span><span>getNodeAs</span><span style="color: #666666;"><</span><span>clang</span><span style="color: #666666;">::</span><span>ForStmt</span><span style="color: #666666;">></span><span>(</span><span style="color: #4070a0;">"forLoop_2"</span><span>))</span></span></pre><pre style="color: #333333; font-size: 11.818181991577148px; margin: 0px 0px 12px; overflow-x: auto; overflow-y: hidden; border: thin dotted #0c3762; padding: 0.8em; background-color: #f0f0f0;">}<br /><span>};</span></pre><br /> </div><div class="im"><p>How does the 'run' method behave in this case? I mean that I don't know if it retrieves, one by one, all the nodes in applyMatch1 and ,after that, all the nodes in applyMatch2 or it matches one in applyMatch1 and then other in applyMatch2 in each iteration. I hope you can understand me because this is very important in my case.<br/>
Thanks in advance.<br/>
Pedro</p>
</div><div><div><div class="im"><br /><br /><div><em>El dia 06 may 2013 22:32, "Vane, Edwin" <<a href="https://webmail-alum.uca.es/webmerlin/compose.do?destinatario=edwin.vane@intel.com" target="vEmailIDmailTo">edwin.vane@intel.com</a>> escribió:</em></div></div><blockquote style="border-left: 2px solid #000083; margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="im"><p>Given your description, I'm not sure matchers are what you want. If you just want to print information on certain types of nodes, you could use a RecursiveASTVisitor for that.<br/>
However, if what you're looking for is a little more complex then matchers may be what you want after all.<br/>
As for the two classes, you want to use tooling::MatchFinder as shown in the tutorial. The other is just an implementation detail of the match finding code.<br/>
newASTConsumer() is a function that's required to be defined for objects passed to newFrontendActionFactory(). You don't need to implement it. It's implemented by MatchFinder. Again, it's an implementation detail you don't need to worry about at this point.<br/>
The use of ASTConsumers is not necessary if you're using MatchFinder and ClangTool as described in the tutorial. MatchFinder is an abstraction around RecursiveASTVisitor so all that stuff in RecursiveASTVisitor you'd normally have to use is actually hidden away.<br/>
I think you should first decide which route you want to go: MatchFinder or RecursiveASTVisitor. The first question I'd ask is: how hard is it to find the nodes I want to print info on in the AST. If all I want is every for loop that's easy. If I want for loops within member functions of a specific class, that's hard and an excellent use case for ASTMatchers.</p>
</div><div><div class="h5"><blockquote style="border-left: 2px solid #000083; margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><p>-----Original Message-----<br />From: <a href="https://webmail-alum.uca.es/webmerlin/compose.do?destinatario=cfe-dev-bounces@cs.uiuc.edu" target="vEmailIDmailTo">cfe-dev-bounces@cs.uiuc.edu</a> [<a href="https://webmail-alum.uca.es/webmerlin/compose.do?destinatario=cfe-dev-bounces@cs.uiuc.edu" target="vEmailIDmailTo">mailto:cfe-dev-bounces@cs.uiuc.edu</a>] On<br /> Behalf Of Pedro Delgado Perez<br />Sent: Monday, May 06, 2013 12:58 PM<br />To: <a href="https://webmail-alum.uca.es/webmerlin/compose.do?destinatario=klimek@google.com" target="vEmailIDmailTo">klimek@google.com</a>; <a href="https://webmail-alum.uca.es/webmerlin/compose.do?destinatario=kozargabor@gmail.com" target="vEmailIDmailTo">kozargabor@gmail.com</a><br /> Cc: <a href="https://webmail-alum.uca.es/webmerlin/compose.do?destinatario=cfe-dev@cs.uiuc.edu" target="vEmailIDmailTo">cfe-dev@cs.uiuc.edu</a><br />Subject: Re: [cfe-dev] ASTMatchers: isVirtual and isOverride<br/>
Hi,<br/>
I need your help again. Look, in my tool I was trying to use the syntax that's<br />shown here:<br/>
<a href="http://clang.llvm.org/docs/LibASTMatchersTutorial.html" target="_blank">http://clang.llvm.org/docs/LibASTMatchersTutorial.html</a><br/>
Namely I'm referring to this part:<br/>
int main(int argc, const char **argv) {<br />CommonOptionsParser OptionsParser(argc, argv);<br />ClangTool Tool(OptionsParser.getCompilations(),<br />OptionsParser.getSourcePathList());<br/>
LoopPrinter Printer;<br />MatchFinder Finder;<br />Finder.addMatcher(LoopMatcher, &Printer);<br/>
return Tool.run(newFrontendActionFactory(&Finder));<br />}<br/>
However, now I want to create a object "Printer" with different features<br />depending on the arguments provided in command line. So I was thinking on<br />implement a factory method pattern to create a different LoopPrinter object:<br /> class OptionsFactory {<br />public:<br />LoopPrinter getOption() {<br />if(...)<br />return LoopPrinter(attribute1, attribute2);<br />else<br />return LoopPrinter(attribute1);<br />}<br />};<br/>
I was searching for a better solution and there are some things that I can't<br />completely understand.<br/>
- Why are there two classes MatchFinder:<br /><a href="http://clang.llvm.org/doxygen/classclang_1_1tooling_1_1MatchFinder.html" target="_blank">http://clang.llvm.org/doxygen/classclang_1_1tooling_1_1MatchFinder.html</a><br /> <a href="http://clang.llvm.org/doxygen/classclang_1_1ast__matchers_1_1MatchFinder" target="_blank">http://clang.llvm.org/doxygen/classclang_1_1ast__matchers_1_1MatchFinder</a>.<br />html<br/>
- What the method in ast_matchers:MatchFinder<br/>
clang::ASTConsumer<br /><<a href="http://clang.llvm.org/doxygen/classclang_1_1ASTConsumer.html%3E" target="_blank">http://clang.llvm.org/doxygen/classclang_1_1ASTConsumer.html></a> *<br/>
newASTConsumer<br /><<a href="http://clang.llvm.org/doxygen/classclang_1_1ast__matchers_1_1MatchFinder" target="_blank">http://clang.llvm.org/doxygen/classclang_1_1ast__matchers_1_1MatchFinder</a><br />.html#a4807049e6e39572d19ff127406df3d81> ()<br/>
is used for? I see we can 'associate' an ASTConsumer to the Frontend as in:<br /><a href="http://clang.llvm.org/docs/RAVFrontendAction.html" target="_blank">http://clang.llvm.org/docs/RAVFrontendAction.html</a><br/>
but, is this possible using Matchers? Would it have any sense to create an<br />ASTConsumer in my class OptionsFactory?<br/>
I have improved a lot since you last helped me, but clang is too big!<br/>
By the way, do you know how to use CommandLine? I posted a new thread<br/>
<a href="http://lists.cs.uiuc.edu/pipermail/cfe-dev/2013-May/029473.html" target="_blank">http://lists.cs.uiuc.edu/pipermail/cfe-dev/2013-May/029473.html</a><br/>
If you know how to solve that problem, please, let me know.<br/>
Thanks in advance,<br/>
Pedro.</p>
<br /><p>El dia 27 abr 2013 18:39, Manuel Klimek <<a href="https://webmail-alum.uca.es/webmerlin/compose.do?destinatario=klimek@google.com" target="vEmailIDmailTo">klimek@google.com</a>> escribió:<br/>
On Sat, Apr 27, 2013 at 6:36 PM, Gábor Kozár<br /><<a href="https://webmail-alum.uca.es/webmerlin/compose.do?destinatario=kozargabor@gmail.com" target="vEmailIDmailTo">kozargabor@gmail.com</a>> wrote:</p>
<br /> <br /><p>2013/4/27 Manuel Klimek <<a href="https://webmail-alum.uca.es/webmerlin/compose.do?destinatario=klimek@google.com" target="vEmailIDmailTo">klimek@google.com</a>></p>
<br /><p>Just use the empty string for binding and getNodeAs :)</p>
<br /><p>That would potentially lead to confusion when there are more<br />nodes bound, but the programmer forgot to supply the proper name. In my<br />suggestion, the parameterless getNodeAs would have an assert to check there is<br /> exactly one node bound (and whose name is the default name).<br/>
If you put everything behind constants, I think it'll be easy enough to see<br />what's happening - and that's a generally good strategy anyway, as you get a<br />compile error if you mistype...<br />Thus, I think it'd not add enough value to special case the interface.</p>
<br /> <br /> <br /><p>2013/4/27 Manuel Klimek <<a href="https://webmail-alum.uca.es/webmerlin/compose.do?destinatario=klimek@google.com" target="vEmailIDmailTo">klimek@google.com</a>></p>
<br /><p>On Sat, Apr 27, 2013 at 6:28 PM, Gábor Kozár<br /><<a href="https://webmail-alum.uca.es/webmerlin/compose.do?destinatario=kozargabor@gmail.com" target="vEmailIDmailTo">kozargabor@gmail.com</a>> wrote:<br/>
Hi,<br />2013/4/26 Pedro Delgado Perez<br /><<a href="https://webmail-alum.uca.es/webmerlin/compose.do?destinatario=pedro.delgadoperez@mail.uca.es" target="vEmailIDmailTo">pedro.delgadoperez@mail.uca.es</a>></p>
<br /><p>Hehehe... I found the problem with<br />this. I was binding wrongly the matcher! I used a id in the matcher thas was<br />different from the id in the function that retrieves the nodes... I think this will be<br />a typical mistake for newbies...<br/>
Ah, yes, that happens a lot to me as well. Now<br />that I think about it, it might be worthwhile adding a parameterless .bind() and<br />.getNodeAs<T>() for situations where only one node is bound. Should be fairly<br /> trivial, but also not all that useful...<br/>
Just use the empty string for binding and getNodeAs :)</p>
<br /> <br /><p>2013/4/26 Pedro Delgado Perez<br /><<a href="https://webmail-alum.uca.es/webmerlin/compose.do?destinatario=pedro.delgadoperez@mail.uca.es" target="vEmailIDmailTo">pedro.delgadoperez@mail.uca.es</a>></p>
<br /><p>Thanks both! Now I can see all this<br />much clearer and I have the enough knowledge to start out with clang.</p>
<br /><p>You're welcome. Good luck!</p>
<br /><p>2013/4/25 Manuel Klimek <<a href="https://webmail-alum.uca.es/webmerlin/compose.do?destinatario=klimek@google.com" target="vEmailIDmailTo">klimek@google.com</a>></p>
<br /><p>And btw thanks a lot for all the great user support you're giving<br />here!</p>
<br /><p>Thank you, I'm happy to help. Clang is a great project!<br/>
As soon as the university term is over, I'm also planning on trying to<br />contribute code-wise, mainly to the Static Analyzer but I guess also on just about<br />anything that catches my attention. :) I'm quite excited - this is going to be the<br /> first open source project I contribute to.<br />Gabor</p>
</blockquote></div></div></blockquote></div></div></div></blockquote></div></div></blockquote></div></div></div></blockquote></div><p> </p>
</body>
</html>