[cfe-dev] Written name of conversion operator

Abramo Bagnara abramo.bagnara at gmail.com
Thu Jun 3 23:54:27 PDT 2010


typedef int i1;
typedef int i2;
struct S {
  operator i1() {
    return 0;
  }
};
int f() {
  S a;
  return a;
  return a.operator i1();
  return a.operator i2();
}

template <typename T>
struct R {
  int f(T x) {
    return x.operator i1();
  }
};

We have attempted to extract from AST the name of operator written in
the source but we have failed:

- using the DeclarationName we get the "wrong" name each time the name
is not the one of the canonical type

- using the TypeSourceInfo of CXXConversionDecl should be always correct
for operator declaration, but it fails on operator call if the name
specified in the call is different from the one in the declaration

Is there a know way to obtain the written name?




More information about the cfe-dev mailing list