[cfe-dev] How to distinguish explicitly specified method in call

Andre Vehreschild via cfe-dev cfe-dev at lists.llvm.org
Mon May 16 09:50:24 PDT 2016


Hi George,

thanks for the explanation. I was only looking at the CXXMemberCallExpr
and CallExpr that was inherited. Will try, whether
MemberExpr::hasQualifier has the info I need.

Regards,
	Andre

On Fri, 13 May 2016 16:40:32 -0700
George Burgess IV <george.burgess.iv at gmail.com> wrote:

> Looks like MemberExpr carries that information around with it; you can
> access it via `MemberExpr::hasQualifier` and `MemberExpr::getQualifier`. :)
> 
> On Fri, May 13, 2016 at 4:59 AM, Andre Vehreschild via cfe-dev <
> cfe-dev at lists.llvm.org> wrote:
> 
> > Hi all,
> >
> > suppose I have these classes:
> >
> > #include <iostream>
> > struct A {
> > virtual void method1() {
> >   std::cout << "A::method1()\n";
> > }
> > };
> > struct B: A {
> > void method1() {
> >   std::cout << "B::method1()\n";
> > }
> > };
> > int main() {
> >   A* o = new B();
> >   o->method1();       // <-
> >   o->A::method1();  // <- Look identical in AST dump.
> >   return 0;
> > }
> > In the AST-dump this is printed as (fragment):
> >     |-CXXMemberCallExpr 0x80560210 <line:14:3, col:14> 'void'
> >     | `-MemberExpr 0x805601ec <col:3, col:6> '<bound member function
> > type>' ->method1 0x8055e8b0
> >     |   `-ImplicitCastExpr 0x805601e0 <col:3> 'struct A *' <LValueToRValue>
> >     |     `-DeclRefExpr 0x805601c8 <col:3> 'struct A *' lvalue Var
> > 0x8055fc28 'o' 'struct A *'
> >     |-CXXMemberCallExpr 0x805602a0 <line:15:3, col:17> 'void'
> >     | `-MemberExpr 0x8056026c <col:3, col:9> '<bound member function
> > type>' ->method1 0x8055e8b0
> >     |   `-ImplicitCastExpr 0x80560258 <col:3> 'struct A *' <LValueToRValue>
> >     |     `-DeclRefExpr 0x8056022c <col:3> 'struct A *' lvalue Var
> > 0x8055fc28 'o' 'struct A *'
> >
> > to me both look the same, but clang is able to distinguish them when
> > building the executable. Can you explain how this
> > is done, or where I have to look to get a clue?
> >
> > Your help is very much appreciated.
> >
> > Regards,
> >    Andre
> >
> >
> > _______________________________________________
> > cfe-dev mailing list
> > cfe-dev at lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
> >
> >


-- 
Andre Vehreschild * Email: vehre ad gmx dot de 



More information about the cfe-dev mailing list