From QualType to clang::NamedDecl?

Hi all:

I am wondering if there is an interface for locating clang::NamedDecl for a QualType?

example:

struct foo { int a; int b; };

void bar(struct foo param);

From ASTConsumer::HandleTopLevelDecl, I can get a QualType of struct foo as a paramter from function bar, so how do I track back to the definition of foo, which has a type of clang::NamedDecl?

Use Ty->getAsTagDecl() to get the TagDecl if it is one.