[cfe-dev] Distinguish between reference expressions to enum constants and other reference expressions.
Paolo Bolzoni
bolzoni at cs.unipr.it
Mon Feb 16 01:51:29 PST 2009
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
More information about the cfe-dev
mailing list