[cfe-dev] [libclang] Getting unqualified version of Type

Łukasz Kucharski via cfe-dev cfe-dev at lists.llvm.org
Mon Feb 12 05:05:51 PST 2018


Is there a way to get "base" type of, well, Type. I see that it's
possible to test for const or volatile, but I don't see a way, to get
the underlying type.

What I am ultimately trying to do is to map member relationships
between classes, and currently the solution is missing some due to
type `A` being different from `const A`.

The only workaround I see is to check with
`clang_isConstQualifiedType` and parse spelling, which does not seem
like a good idea.

This is an example class layout that I have problem with:

```
class A {};

class B {
 A a;
}

class C {
  const A a;
  B* b;
}
```

It's hard to map C->A.

`B` is possitle to obtain through checking `CXType::kind` against
`CXType_Pointer` and `clang_getPointeeType`, so it's not a problem
that `B` and `B*` are different as there is a programatic way to get
it.

Is there a way to do it in current version of libclang? Or, would I
need to manually work with AST.

Regards,
Łukasz.



More information about the cfe-dev mailing list