[cfe-dev] Methods and AST incongruences

Abramo Bagnara abramo.bagnara at gmail.com
Sat Nov 5 15:03:30 PDT 2011


Tracking some related failures in our application I've found some
incongruences in clang AST that likely are bugs.

In the typescript below I see at least two problems:

a) in line marked // 1 the usual ImplicitCastExpr of kind
UserDefinedConversion used to mark implicit call to conversion operator
is missing

b) in line marked // 3 the method referred by MemberExpr is a builtin
with BoundMember kind while in line marked //1 and //2 has function type.

I'm right if I say that we have a bug in line // 1 for issue a) and a
bug in line //1 and //2 for issue b) ?

Once agreed on that (or on something different) we'll proceed to report
the related bugzilla issues and/or to try to fix the confirmed bugs.

$ cat z.cc
struct S {
  operator int();
  int foo();
};

void f() {
  S s;
  int f;
  f = s;        // 1
  int f1 = s;   // 2
  int f2;
  f2 = s.foo(); // 3
}
$ ~/llvm_new/Debug+Asserts/bin/clang -cc1 -ast-dump z.cc
typedef __int128_t __int128_t;
typedef __uint128_t __uint128_t;
struct __va_list_tag {
    struct __va_list_tag;
    unsigned int gp_offset;
    unsigned int fp_offset;
    void *overflow_arg_area;
    void *reg_save_area;
};
typedef struct __va_list_tag __va_list_tag;
typedef __va_list_tag __builtin_va_list[1];
struct S {
    struct S;
    int operator int();
    int foo();
    inline S() throw() (CompoundStmt 0x54da9e8 <z.cc:1:8>)


    inline S(const S &) throw();
};
void f() (CompoundStmt 0x54daea0 <z.cc:6:10, line:13:1>
  (DeclStmt 0x54daa30 <line:7:3, col:6>
    0x54da6e0 "S s =
      (CXXConstructExpr 0x54daa00 <col:5> 'struct S''void (void) throw()')")
  (DeclStmt 0x54daac0 <line:8:3, col:8>
    0x54daa60 "int f")
  (BinaryOperator 0x54dabe8 <line:9:3, col:7> 'int' lvalue '='
    (DeclRefExpr 0x54daad8 <col:3> 'int' lvalue Var 0x54daa60 'f' 'int')
    (CXXMemberCallExpr 0x54dabc0 <col:7> 'int'
      (MemberExpr 0x54dab88 <col:7, <invalid sloc>> 'int (void)'
.operator int 0x54da460
        (DeclRefExpr 0x54dab00 <col:7> 'struct S' lvalue Var 0x54da6e0
's' 'struct S'))))
  (DeclStmt 0x54dad28 <line:10:3, col:13>
    0x54dac20 "int f1 =
      (ImplicitCastExpr 0x54dad10 <col:12> 'int' <UserDefinedConversion>
        (CXXMemberCallExpr 0x54dace8 <col:12> 'int'
          (MemberExpr 0x54dacb0 <col:12, <invalid sloc>> 'int (void)'
.operator int 0x54da460
            (DeclRefExpr 0x54dac80 <col:12> 'struct S' lvalue Var
0x54da6e0 's' 'struct S'))))")
  (DeclStmt 0x54dadb0 <line:11:3, col:9>
    0x54dad50 "int f2")
  (BinaryOperator 0x54dae78 <line:12:3, col:14> 'int' lvalue '='
    (DeclRefExpr 0x54dadc8 <col:3> 'int' lvalue Var 0x54dad50 'f2' 'int')
    (CXXMemberCallExpr 0x54dae50 <col:8, col:14> 'int'
      (MemberExpr 0x54dae18 <col:8, col:10> '<bound member function
type>' .foo 0x54da520
        (DeclRefExpr 0x54dadf0 <col:8> 'struct S' lvalue Var 0x54da6e0
's' 'struct S')))))




More information about the cfe-dev mailing list