Search code examples
c++clangllvmllvm-clanglibtooling

CXXRecords getNameAsString, how to get full name?


 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..


Solution

  • 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.