[cfe-dev] Final AST

Lukas Vogel lukedirtwalkerdev at gmail.com
Sun Jun 23 11:36:40 PDT 2013


Sorry for the late answer a simplified extract of the code which gives an
UnresolvedMemberExpr is this

class  AdapterManager {
public:
using AdapterCreationFunction = void* (*)(void* adaptee);

template<class Adapter> Adapter* someTestFunc();


private:
using TypeIdType = std::size_t;

template <class type>
static TypeIdType typeId();


static QHash<TypeIdType, AdapterCreationFunction> defaultAdapters;
};

template <class type> AdapterManager::TypeIdType AdapterManager::typeId()
{
return typeid(type).hash_code();
}

template<class Adapter> Adapter* AdapterManager::someTestFunc()
{
return defaultAdapters.find( typeId<Adapter>() );
}


in the body of someTestFunc() find is an unresolvedMemberExpr the dump
looks like this:

UnresolvedMemberExpr 0x15b2808 '<bound member function type>' lvalue

`-DeclRefExpr 0x1583020

'QHash<TypeIdType, AdapterCreationFunction>':'class QHash<unsigned long,
void *(*)(void *)>' lvalue Var 0x15824f0 'defaultAdapters'
'QHash<TypeIdType, AdapterCreationFunction>':'class QHash<unsigned long,
void *(*)(void *)>'


However if I enter a value instead of the typeId function it is no more
unresolved.
So I guess this is normal behavior (because of template stuff) and
therefore the description is wrong?


2013/6/17 James Dennett <james.dennett at gmail.com>

> On Mon, Jun 17, 2013 at 12:35 AM, Manuel Klimek <klimek at google.com> wrote:
> > On Fri, Jun 14, 2013 at 1:39 PM, Lukas Vogel <
> lukedirtwalkerdev at gmail.com>
> > wrote:
> >>
> >> Hi,
> >>
> >> I'm currently writing a Tool using libtooling & RecursiveAstVisitor.
> >> In the AST I come across quite a lot of Unresolved expressions and I
> >> looked through the documentation of UnresolvedMemberExpr
> >> [UnresolvedMemberExpr] there it says that those nodes will be resolved
> in
> >> the final AST.
> >> Is there any possibility to get this final AST and run the tool over
> this?
> >> Or to what does this refer?
> >
> >
> > The AST you see with libtooling should be the final AST :) Are you
> running
> > over incomplete code (that is, code that doesn't compile)?
> >
> > Can you paste a reproduction?
>
> I've not checked, but I'd assume that there are plenty of unresolved
> nodes in parsed templates (as opposed to their instantiations).
> Likely the documentation could be improved.
>
> -- James
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130623/fecbd9fc/attachment.html>


More information about the cfe-dev mailing list