Howto get from a TypedefDecl an unterlying EnumDecl

Hi All,

not sure if this is the right place to ask my question.

I'm writing an analyzer tool using the clang ASTConsumer. When I'm
analyzing the following piece I don't know how to get back from the
TypedefDeclto the unterlying EnumDecl

typedef enum {
  Illegal = -1,
  Init = 0,

In my ast consumer

void IDB_ASTConsumer::handleDecl (Decl * decl) {
else if (EnumDecl * enumDecl = llvm::dyn_cast<EnumDecl>(decl)) {
EnumDecl 0x1da43360
line:30:1> line:25:9

-EnumConstantDecl 0x1da433f0 <line:26:2, col:9> col:2 Init 'T_ENUM'
`-IntegerLiteral 0x1da433d0 <col:9> 'int' 0
-EnumConstantDecl 0x1da43460 <line:27:2, col:13> col:2 Illegal 'T_ENUM'
`-UnaryOperator 0x1da43448 <col:12, col:13> 'int' prefix '-'
  `-IntegerLiteral 0x1da43430 <col:13> 'int' 1
-EnumConstantDecl 0x1da434a0 <line:28:2> col:2 Run 'T_ENUM'

`-EnumConstantDecl 0x1da434e0 <line:29:2> col:2 Stop 'T_ENUM'
else if (TypedefDecl * typedefDecl = llvm::dyn_cast<TypedefDecl>(decl)) {

TypedefDecl 0x1da43550
line:30:3> col:3 T_ENUM 'enum T_ENUM':'T_ENUM'

Is there a way to access the EnumDecl from the TypdefDecl


Does getUnderlyingType work for you?