Decide in Clang if the visited CXXRecordDecl is class, struct or union

abstract-syntax-tree, c++, clang

Solution

Just use the `isStruct`, `isClass`, and `isUnion` member functions, or call `getTagKind` to get a `TagKind` value you can `switch` on if you prefer. They're in the `TagDecl` base class.

Problem

I use Clang to build up an AST from C++ source code and RecursiveASTVisitor to traverse the tree. I would like to decide at a visited declaration of record if it is class, struct or union. I have an overridden function VisitCXXRecordDecl(clang::CXXRecordDecl). In this function I can check any information about CXXRecordDecl that the class offers, but I have no idea how to get thie information. Can Anyone help me?

Original source