<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Mon, Mar 14, 2016 at 4:24 PM David Blaikie <<a href="mailto:dblaikie@gmail.com">dblaikie@gmail.com</a>> 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 class="gmail_extra"><div class="gmail_quote">On Mon, Mar 14, 2016 at 7:57 AM, mats petersson via cfe-dev <span dir="ltr"><<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div>Sorry about earlier message - premature "send"... :(<br><br></div>So, surely this is rather hard to do. <br><br></div>If you write match this: `class T; T* ptr = new T;`, what should it match? Only the exact class called `T`? Or, the opposite extreme, any assignment of new of any type, e.g "int *ptr = new int;"? What about "const X* p = new Y;"? Or "std::vector<int*> a = { new int, new int }"?  What do you want to do with `T* ptr{new T};` - it does essentially the same thing, but syntactially and semantically, it's not identical - I'd expect the AST is not identical - and if it is when you didn't want to match that, it's a problem [although not solvable, since the AST is the same].<br><br></div>Of course these examples are mostly nonsense and can be solved in other ways, I'm just trying to point out that "matching something" often means distinguishing "This is what I want to match, this I don't care about" - so, do you care if the type is `const` or not, do you care if the type is a `class` or `struct` vs. `int` etc? Do you care if it's exactly an assignment, or anything that "kind of assigns".<br><br></div>What I'm trying to say is that it would probably produce something to start from, but I'm not convinced it is THAT much help, since you still have to apply some fuzz and modify the code to do what you ACTUALLY want to do. <br></div></div></blockquote><div><br></div></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>One way to address this would be to allow multiple expressions and generate the most specific matcher that matches all those expressions. Still wouldn't catch all cases, but might help make the first pass a little closer to what you want.</div></div></div></div></blockquote><div><br></div><div>And I have existence proof that this approach works well for simpler ASTs (Java), but it's hard to say whether it would work equally well in C++</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><br>--<br></div>Mats<br></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On 14 March 2016 at 14:48, mats petersson <span dir="ltr"><<a href="mailto:mats@planetcatfish.com" target="_blank">mats@planetcatfish.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Sure<br></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On 14 March 2016 at 14:11, Manuel Klimek via cfe-dev <span dir="ltr"><<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><span><div dir="ltr">On Mon, Mar 14, 2016 at 2:50 PM David Come via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
I have been playing a bit with lib ASTMatcher and it is very tedious to use.<br>
My workflow is to dump the AST  for the relevant code and translate it<br>
into matchers, using clang-query to make sure it works.<br>
<br>
I was wandering is there was any tool (or proposal, work in progress...)<br>
for automating this work.<br>
The end goal would be give it some C++ code as input and have the<br>
corresponding matcher in output.<br></blockquote><div><br></div></span><div>Unfortunately there is no such tool. Would be awesome to have, though :)</div><span><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Thanks,<br>
David<br>
_______________________________________________<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></span></div></div>
<br>_______________________________________________<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>
<br></blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div><br>_______________________________________________<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>
<br></blockquote></div></div></div></blockquote></div></div>