2
 namespace A {
     namespace B {
         class C {
             class D {
             };
         };
     }
 }

CXXRecords for D with getNameAsString would return D.
How can I get the fullname ::A::B::C::D ?

I tried to recursively call getParent but I couldn't get the namespaces..

KoKuToru
  • 4,055
  • 2
  • 20
  • 21

2 Answers2

4

After lots of searching and trying i found

QualType::getAsString(cl->getASTContext().getTypeDeclType(const_cast<CXXRecordDecl*>(cl)).split())

As useable solution, it will output class A::B::C::D.
For namespace using std; vector<int> g; it will output class std::vector<int>.

Having only std::vector would be nice, but simple string manipulation will solve this problem.

KoKuToru
  • 4,055
  • 2
  • 20
  • 21
0

Assuming your RecordDecl pointer variable is named recordDecl, you can simply use recordDecl->getQualifiedNameAsString()

Justin
  • 447
  • 4
  • 10
  • 33