<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" id="owaParaStyle"></style><style type="text/css"></style><style type="text/css"></style>
</head>
<body fpstyle="1" ocsi="0">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">Hi,
<div><br>
</div>
<div>the location of the function declaration/definition appears to be easier to construct and would work fine for me.</div>
<div><br>
</div>
<div>Thanks,</div>
<div>Manuel</div>
<div><br>
<div style="font-family: Times New Roman; color: #000000; font-size: 16px">
<hr tabindex="-1">
<div id="divRpF261233" style="direction: ltr;"><font face="Tahoma" size="2" color="#000000"><b>From:</b> Manuel Klimek [klimek@google.com]<br>
<b>Sent:</b> Wednesday, November 21, 2012 10:10 AM<br>
<b>To:</b> Holtgrewe, Manuel<br>
<b>Cc:</b> cfe-dev@cs.uiuc.edu<br>
<b>Subject:</b> Re: [cfe-dev] Finding all references to a function overload or type.<br>
</font><br>
</div>
<div></div>
<div>
<div style="font-family:arial,helvetica,sans-serif; font-size:10pt">On Wed, Nov 21, 2012 at 10:02 AM, Holtgrewe, Manuel
<span dir="ltr"><<a href="mailto:manuel.holtgrewe@fu-berlin.de" target="_blank">manuel.holtgrewe@fu-berlin.de</a>></span> wrote:<br>
<div class="gmail_extra">
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div>
<div style="direction:ltr; font-size:10pt; font-family:Tahoma">ping
<div><br>
</div>
<div>Maybe I should elaborate a bit further.</div>
<div><br>
</div>
<div>Given the program [1] (written as a string in the test), I would like to find out from which contextes the function overload bar(Foo<T, Tick> const &) is called.</div>
<div><br>
</div>
<div>I tried dumping parts of the AST and from that it appears that it is not directly possible to see the instantiation points. Is it possible to see a "concrete AST" with instantiated class and function templates?</div>
</div>
</div>
</blockquote>
<div><br>
</div>
<div>What's your "key" for the overload of bar in this case?</div>
<div>Possible keys:</div>
<div>a) the location of the function declaration / definition</div>
<div>b) the parameter list</div>
<div><br>
</div>
<div>Cheers,</div>
<div>/Manuel</div>
<div> </div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div>
<div style="direction:ltr; font-size:10pt; font-family:Tahoma">
<div><br>
</div>
<div>Thanks,</div>
<div>Manuel</div>
<div><br>
</div>
<div>[1] <a href="https://github.com/holtgrewe/func_references/blob/master/src/test.cpp#L114" target="_blank">https://github.com/holtgrewe/func_references/blob/master/src/test.cpp#L114</a></div>
<div><br>
<div>
<div style="font-size:16px; font-family:Times New Roman">
<hr>
<div style="direction:ltr"><font face="Tahoma" color="#000000"><b>From:</b> <a href="mailto:cfe-dev-bounces@cs.uiuc.edu" target="_blank">
cfe-dev-bounces@cs.uiuc.edu</a> [<a href="mailto:cfe-dev-bounces@cs.uiuc.edu" target="_blank">cfe-dev-bounces@cs.uiuc.edu</a>] on behalf of Holtgrewe, Manuel [<a href="mailto:manuel.holtgrewe@fu-berlin.de" target="_blank">manuel.holtgrewe@fu-berlin.de</a>]<br>
<b>Sent:</b> Monday, November 19, 2012 9:11 AM<br>
<b>To:</b> <a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a>
<div>
<div class="h5"><br>
<b>Subject:</b> Re: [cfe-dev] Finding all references to a function overload or type.<br>
</div>
</div>
</font><br>
</div>
<div>
<div class="h5">
<div></div>
<div>
<div style="direction:ltr; font-size:10pt; font-family:Tahoma">
<div style="direction:ltr; font-size:10pt; font-family:Tahoma">Thank you for your answer.
<div><br>
</div>
<div>I was able to write a small test program with an <span style="">RecursiveASTVisitor [1] by using some example code I found on github.</span></div>
<div><br>
</div>
<div>However, now I'm stuck. I could not find out how to find out that the function overload bar(Foo<int, Tick> const &) is called from the AST.</div>
<div><br>
</div>
<div>Can someone help me with this and point me into the right direction again?</div>
<div><br>
</div>
<div>Thanks,</div>
<div>Manuel</div>
<div><br>
</div>
<div>[1] <a href="https://github.com/holtgrewe/func_references/blob/master/src/test.cpp" target="_blank">https://github.com/holtgrewe/func_references/blob/master/src/test.cpp</a></div>
<div><br>
<div style="font-size:16px; font-family:Times New Roman">
<hr>
<div style="direction:ltr"><font face="Tahoma" color="#000000"><b>From:</b> Manuel Klimek [<a href="mailto:klimek@google.com" target="_blank">klimek@google.com</a>]<br>
<b>Sent:</b> Thursday, November 15, 2012 5:12 PM<br>
<b>To:</b> Holtgrewe, Manuel<br>
<b>Cc:</b> <a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a><br>
<b>Subject:</b> Re: [cfe-dev] Finding all references to a function overload or type.<br>
</font><br>
</div>
<div></div>
<div>
<div style="font-family:arial,helvetica,sans-serif; font-size:10pt">On Thu, Nov 15, 2012 at 12:47 AM, Holtgrewe, Manuel
<span dir="ltr"><<a href="mailto:manuel.holtgrewe@fu-berlin.de" target="_blank">manuel.holtgrewe@fu-berlin.de</a>></span> wrote:<br>
<div class="gmail_extra">
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left-width:1px; border-left-color:rgb(204,204,204); border-left-style:solid; padding-left:1ex">
Dear all,<br>
<br>
I would like to use the clang infrastructure (libclang, libtooling, ...) to find all references to a function overload or a type in a program. This should also work if the program has templates.<br>
<br>
Consider the following example:<br>
<br>
void f(int i)<br>
{}<br>
<br>
template <typename T><br>
void f(T x)<br>
{<br>
  X<T> y;<br>
}<br>
<br>
template <typename T><br>
struct X<br>
{};<br>
<br>
template <><br>
struct X<long><br>
{};<br>
<br>
main ()<br>
{<br>
  f(3.0);<br>
  f(1);<br>
  f(1l);<br>
<br>
  return 0;<br>
}<br>
<br>
For example, I would like to find all occurences of the overload "void f(int i)" (result should be the line with "f(1)" or all occurences of the specialization "X<long>" (in the line with "X<T> y" when f is called with a long value.<br>
<br>
Is this possible with clang? If so, can anyone point me in the right direction?<br>
</blockquote>
<div><br>
</div>
<div>Yes. Start here: <a href="http://clang.llvm.org/docs/Tooling.html" target="_blank">http://clang.llvm.org/docs/Tooling.html</a></div>
<div><br>
</div>
<div>Cheers,</div>
<div>/Manuel</div>
<div> </div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left-width:1px; border-left-color:rgb(204,204,204); border-left-style:solid; padding-left:1ex">
<br>
Thanks,<br>
Manuel<br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript">var new_nav = new function() {};var x;for (x in navigator) {eval("new_nav." + x + " = navigator." + x + ";");}new_nav.userAgent = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_8; en-us) AppleWebKit/531.21.8 (KHTML, like Gecko) Version/4.0.4 Safari/5";new_nav.vendor = "Apple, Inc.";new_nav.platform = "MacIntel";window.navigator = new_nav;</script><script type="text/javascript">var new_nav = new function() {};var x;for (x in navigator) {eval("new_nav." + x + " = navigator." + x + ";");}new_nav.userAgent = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_8; en-us) AppleWebKit/531.21.8 (KHTML, like Gecko) Version/4.0.4 Safari/5";new_nav.vendor = "Apple, Inc.";new_nav.platform = "MacIntel";window.navigator = new_nav;</script>
</body>
</html>