trick/trick_source/codegen/Interface_Code_Gen/FieldVisitor.hh
Alex Lin 14a75508a3 Cleaning up once include variables and copyright cleanup.
Changed all header file once include variables to follow the same naming
convention and not start with any underscores.  Also deleted old
incorrect copyright notices.  Also removed $Id: tags from all files.

Fixes #14.  Fixes #22.
2015-03-23 16:03:14 -05:00

79 lines
2.6 KiB
C++

#ifndef FIELDVISITOR_HH
#define FIELDVISITOR_HH
#include "clang/Frontend/CompilerInstance.h"
#include "clang/AST/RecursiveASTVisitor.h"
#include "PrintAttributes.hh"
class CommentSaver ;
class HeaderSearchDirs ;
class SourceManager ;
class FieldDescription ;
/**
This class is a recursive AST visitor that is called when a Field node inside a class
is found. We are in what type the field is, what the array dimensions are, and the
bitfield lengths. All information is stored in a FieldDescription object.
@author Alexander S. Lin
@date July 2012
*/
class FieldVisitor : public clang::RecursiveASTVisitor<FieldVisitor> {
public:
FieldVisitor(clang::CompilerInstance & in_ci ,
HeaderSearchDirs & in_hsd ,
CommentSaver & cs ,
PrintAttributes & in_pa ,
std::string container_class ,
bool access_spec_found ,
bool inherited ,
bool virtual_inherited ,
unsigned int base_class_offset ) ;
/* VisitDecl and VisitType are here for debug printing. */
bool VisitDecl(clang::Decl *d) ;
bool VisitType(clang::Type *t) ;
/* These routines are called when nodes of the corresponding types are traversed */
bool VisitBuiltinType(clang::BuiltinType *bt);
bool VisitConstantArrayType(clang::ConstantArrayType *a) ;
bool VisitDeclaratorDecl( clang::DeclaratorDecl *dd ) ;
bool VisitElaboratedType( clang::ElaboratedType *et ) ;
bool VisitEnumType( clang::EnumType *et ) ;
bool VisitFieldDecl( clang::FieldDecl *field ) ;
bool VisitPointerType(clang::PointerType *p);
bool VisitRecordType(clang::RecordType *rt);
bool VisitSubstTemplateTypeParmType(clang::SubstTemplateTypeParmType *sttpt);
bool VisitTemplateSpecializationType(clang::TemplateSpecializationType *tst);
bool VisitTemplateTypeParmType(clang::TemplateTypeParmType *ttp);
bool VisitTypedefType(clang::TypedefType *tt);
bool VisitVarDecl( clang::VarDecl *v ) ;
/** Returns the field data */
FieldDescription * get_field_data() ;
private:
/** The compiler's source manager. Holds file/line info for everything. */
clang::CompilerInstance & ci ;
/** Holds all comments */
CommentSaver & cs ;
/** The header search directories */
HeaderSearchDirs & hsd ;
/** attributes printer */
PrintAttributes & pa ;
/** Holds the field information found, usually returned to caller of this visitor. */
FieldDescription * fdes ;
} ;
#endif