Get EnumDecl from Sema

I would like to get an EnumDecl in Sema::ActOnIdExpression. I know the name of the enumeration type. How would I go about finding it? I assume it is somewhere in the ASTContext, but I can’t find it.

You can use Sema::LookupName to do arbitrary name lookup. If you know the expression references the enum, you might be able to navigate the AST to find it that way.

How do I create the DeclarationName or DeclarationNameInfo to use Sema::LookupName? I know the name of the enum type, but I cannot see how to create one of those using a string literal. I keep running into IdentifierInfo which only has a default constructor.

IdentifierInfo’s are just uniqued strings that track properties like whether the identifer was every a macro or keyword, etc. The preprocessor has an IdentifierTable and you can do something like ‘PP.getIdentifierTable().get(“MyEnum”)’ to get one.