17 Aug 2012 15:23
Visiting anonymous unions
Hi,
I am writing a source-to-source transformation tool and I need a way
to check if function contains at least one anonymous union inside. My
current way is the following:
class AnonymousUnionChecker : public
clang::RecursiveASTVisitor<AnonymousUnionChecker>
{
bool foundAnonUnion;
public:
AnonymousUnionChecker() {}
bool VisitRecordType(RecordType *T)
{
RecordDecl *D = T->getDecl();
if (D->isUnion() && !D->getIdentifier())
{
foundAnonUnion = true;
return false;
}
return true;
}
bool CanFindInside(clang::Stmt* stmt) // for functions' bodies
{
foundAnonUnion = false;
TraverseStmt(stmt);
return foundAnonUnion;
(Continue reading)
RSS Feed