<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body><div>Consider the following code:<br></div>
<div> </div>
<blockquote><div>template<typename T><br></div>
<div>void f() {}<br></div>
<div><br>template<typename T></div>
<div>void g() { f<T>(); }<br></div>
<div><br>void h() { g<int>(); }<br></div>
</blockquote><div> </div>
<div>Given the FunctionDecl representing f<int> (the specialization) and knowing that I'm interested in template argument at index 0, I would like to find the point where the type for the template argument originally came from. So in the above example, I would like to find the CallExpr to g<int> in h().<br></div>
<div> </div>
<div>I was hoping there was already an existing solution in clang for this, but I could not find one.<br></div>
<div> </div>
<div>My best idea is to, going backwards, search for CallExpr-s pointing to
the function, and then figure out if that CallExpr is inside a template
function or a method inside a class template, and determine whether in
the template the corresponding CallExpr points to an OverloadExpr, whose
template argument list I could check... but this is pretty complicated.<br></div>
<div> </div>
<div>What's the easiest way to do this?<br></div>
<div>Thank you!<br></div>
<div> </div>
<div id="sig19426269"><div class="signature">---<br></div>
<div class="signature">Best regards,<br></div>
<div class="signature"> </div>
<div class="signature">Gábor 'ShdNx' Kozár<br></div>
<div class="signature"><a href="http://gaborkozar.me">http://gaborkozar.me</a><br></div>
<div class="signature"> </div>
</div>
<div> </div>
</body>
</html>