[cfe-dev] Finding where a type for a template argument originates
Gabor Kozar
kozargabor at gmail.com
Mon Dec 22 09:40:58 PST 2014
Consider the following code:
> template<typename T> void f() {}
>
> template<typename T> void g() { f<T>(); }
>
> void h() { g<int>(); }
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().
I was hoping there was already an existing solution in clang for this,
but I could not find one.
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.
What's the easiest way to do this? Thank you!
---
Best regards,
Gábor 'ShdNx' Kozár http://gaborkozar.me
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20141222/746c8f38/attachment.html>
More information about the cfe-dev
mailing list