[cfe-dev] AST for DeclRefExpr of NonTypeTemplateParm
Mikhail Ramalho via cfe-dev
cfe-dev at lists.llvm.org
Wed Apr 27 12:02:05 PDT 2016
Thank you for the fast answer! I was struggling with this for a couple of
days already! I was already checking isDependentContext() for functions and
methods, but completely forgot about that on VarDecls!
2016-04-27 18:23 GMT+01:00 Reid Kleckner <rnk at google.com>:
> On Wed, Apr 27, 2016 at 10:09 AM, Mikhail Ramalho via cfe-dev <
> cfe-dev at lists.llvm.org> wrote:
>> 1. How can I ignore any non instantiated varDecl?
> Check if the variable lives in a dependent DeclContext, something like
>> 2. How can I get the instantiated VarDecl? (Actually, the opposite of the
>> first question).
>> I mean, somewhere there must be a VarDecl with
>> a SubstNonTypeTemplateParmExpr, right?
> If you instantiate it, then yes, it will be there. Changing the last line
> of your program to 'return *A<&B::c>::p;' adds this AST node to the dump:
> `-VarDecl 0xcc3f08 parent 0xcc2380 prev 0xcc2698 <line:5:1, col:23> col:19
> used p 'const char *' cinit
> `-SubstNonTypeTemplateParmExpr 0xcc4110 <col:23> 'const char *'
> `-UnaryOperator 0xcc40f0 <col:23> 'const char *' prefix '&'
> `-DeclRefExpr 0xcc40c8 <col:23> 'const char' lvalue Var 0xcc20b0 'c'
> 'const char'
>> 3. Is it possible to generate the AST without any template? I'm only
>> interested in the instantiated templates. It seems a long shot, but who
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cfe-dev