Qualified name for a template base class

I am trying to do class hierarchy analysis by adding a checker to clang analyzer but when the base class is a template I do not get the base full qualified name.

For example:
I have the following classes:

namespace bases{
class base0{


class base1{

class derived : public base1{


In my code in VisitRecordDecl(CXXRecordDecl decl) where decl is the declaration of class “derived” I iterate over the bases of derived:

for (CXXBaseSpecifier *it = decl->bases->begin(); it!=decl->bases_end(); it++){
QualType qual_type = it->getType();
std::cout << qual_type.getAsString();

qual_type.getAsString() gives “base1” for the base of bases::derived. How can I get the full qualified name bases::base1?

The same happens when the derived and base classes are defined in different namespaces.

For example

using namespace bases;
namespace bases2{
class derived2 : public base1


I still get only base1 instead of bases::base1.
Note that for the template argument the full qualified name is given.

The problem happens only when the base is a template.