[cfe-dev] Question about ASTMatchers
Manuel Klimek
klimek at google.com
Thu Feb 20 00:53:55 PST 2014
hasAncestor(decl(anyOf(recordDecl(
isTemplateInstantiation()),
functionDecl(isTemplateInstantiation()))
should do what you want.
On Wed, Feb 19, 2014 at 11:01 PM, Christian Schafmeister <
chris.schaf at verizon.net> wrote:
>
> If I match a varDecl() that is in a method of a template class I get a
> match for the template and instantiated templates
> - is there a way to tell the difference by matching some difference in the
> ancestors of the varDecl node?
>
> I get a match for the translate::from_object<T> a0(*args); varDecl in the
> method activate (see below) that has this type:
> from_object<type-parameter-0-0, struct std::__1::integral_constant<_Bool,
> true> >
>
> I also get a match that I think is from the instantiation
> TestFunctoid<int> j(“test”) in tinyFunc - it has this type: "struct
> translate::from_object<int, std::true_type>"
>
> There is a clear difference in the name - but I was looking for something
> that didn’t feel like a hack.
>
> Are there differences in the AST class node for TestFunctoid when it is a
> template class vs when it is an instantiated template class?
>
>
>
> #include <stdio.h>
> #include <core/foundation.h>
> #include <core/object.h>
> #include <core/holder.h>
>
> namespace asttooling {
>
>
> template<typename T>
> class TestFunctoid : public core::Functoid {
> public:
>
> TestFunctoid(const string& name) : core::Functoid(name) {};
> core::T_mv activate( core::const_ActivationFrame_spREF
> closedOverFrame, int numArgs, ArgArray args )
> {
> translate::from_object<T> a0(*args);
> printf( "Address of a0= %p\n", &a0);
> return Values0<core::T_O>();
> }
> };
>
>
>
> void tinyFunc()
> {
> TestFunctoid<int> j("test");
> TinyStruct x(10);
> tinyFunc(x);
> printf("Hi there, this is tinyFunc\n");
> }
>
> };
>
> Christian Schafmeister
> Associate Professor
> Chemistry Department
> Temple University
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140220/44e84299/attachment.html>
More information about the cfe-dev
mailing list