The qualified name of a base class

Hello,
I have the following classes in the input to my clang analyzer checker:

namespace bases{
class base0{
int x;
…};

template
class base1{
private:
int x;
public:
void print_member(){
std::cout << x << std::endl;
}
};

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 as follows:

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<class bases::base 0>” 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. ***

Any idea how to solve this?
Thanks,
Sitvanit