[cfe-dev] How to distinguish explicitly specified method in call
George Burgess IV via cfe-dev
cfe-dev at lists.llvm.org
Fri May 13 16:40:32 PDT 2016
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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160513/11f4381d/attachment.html>
More information about the cfe-dev
mailing list