Distinguish between reference expressions to enum constants and other reference expressions.

Here a simple source code:
--->
enum colors { OCHRE, BURNT_SIENNA, BLUE };
int my_global_int;

int main() {
  my_global_int = OCHRE;
}
---<

the ast vertices relative to `my_global_int' and `OCHRE' are both of type
clang::DeclRefExpr.
I need to distinguish between references to enum constants and references to
other entities.

Being `node' a pointer to a DeclRefExpr, at the moment I use
clang:: EnumConstantDecl:: classof(node-> getDecl());
if it does return true the reference is to a enum constant decl, if it return
false it is not.

I am not sure I understood how this classof & co. functions works,
so I ask: is doing so the best way? is it correct?

Thanks,
pb

classof is an implementation detail. You should use:

  isa<EnumConstantDecl>(node->getDecl())

to determine whether node->getDecl() is an EnumConstantDecl. There's more documentation for the type casting/query functionality of LLVM here:

  http://llvm.org/docs/ProgrammersManual.html#isa

  - Doug