15 #ifndef ROOT__RSCANNER_H__ 16 #define ROOT__RSCANNER_H__ 20 #include "clang/AST/AST.h" 21 #include "clang/AST/ASTContext.h" 22 #include "clang/AST/DeclGroup.h" 23 #include "clang/AST/DeclFriend.h" 24 #include "clang/AST/Type.h" 25 #include "clang/AST/RecursiveASTVisitor.h" 27 #include "llvm/IR/Module.h" 32 class ClassTemplatePartialSpecializationDecl;
33 class ClassTemplateDecl;
46 class RScanner:
public clang::RecursiveASTVisitor<RScanner>
53 fDecl(decl), fRuleIndex(index), fRequestOnlyTClass(rRequestOnlyTClass){}
57 operator clang::NamespaceDecl
const *()
const {
return fDecl; }
60 const clang::NamespaceDecl *
fDecl;
66 typedef std::vector<ROOT::TMetaUtils::AnnotatedRecordDecl>
ClassColl_t;
71 typedef void (*DeclCallback)(
const char *
type);
74 enum class EScanType : char {kNormal, kTwoPasses, kOnePCM};
78 const cling::Interpreter &interpret,
91 bool VisitEnumDecl(clang::EnumDecl* D);
92 bool VisitFieldDecl(clang::FieldDecl* D);
93 bool VisitFunctionDecl(clang::FunctionDecl* D);
94 bool VisitNamespaceDecl(clang::NamespaceDecl* D);
95 bool VisitRecordDecl(clang::RecordDecl* D);
96 bool VisitTypedefNameDecl(clang::TypedefNameDecl* D);
97 bool VisitVarDecl(clang::VarDecl* D);
99 bool TreatRecordDeclOrTypedefNameDecl(clang::TypeDecl* typeDecl);
101 bool TraverseDeclContextHelper(clang::DeclContext *DC);
105 DeclCallback SetRecordDeclCallback(DeclCallback callback);
108 void Scan(
const clang::ASTContext &
C);
111 bool GetDeclName(clang::Decl* D, std::string&
name)
const;
112 bool GetDeclQualName(
const clang::Decl* D, std::string& qual_name)
const;
113 bool GetFunctionPrototype(clang::Decl* D, std::string& prototype)
const;
121 ClassColl_t fSelectedClasses;
136 const clang::RecordDecl*,
138 const clang::TypedefNameDecl*,
139 unsigned int indexOffset=0);
140 std::string ConvTemplateArguments(
const clang::TemplateArgumentList& list)
const;
141 std::string ConvTemplateName(clang::TemplateName&
N)
const;
142 std::string ConvTemplateParameterList(clang::TemplateParameterList* list)
const;
143 std::string ConvTemplateParams(clang::TemplateDecl* D)
const;
144 void DeclInfo(clang::Decl* D)
const;
145 std::string ExprToStr(clang::Expr* expr)
const;
146 std::string FuncParameterList(clang::FunctionDecl* D)
const;
147 std::string FuncParameters(clang::FunctionDecl* D)
const;
148 std::string GetEnumName(clang::EnumDecl* D)
const;
149 std::string GetLocation(clang::Decl* D)
const;
150 std::string
GetName(clang::Decl* D)
const;
151 std::string GetSrcLocation(clang::SourceLocation
L)
const;
152 unsigned int FuncModifiers(clang::FunctionDecl* D)
const;
154 unsigned int VarModifiers(clang::VarDecl* D)
const;
155 unsigned int Visibility(clang::Decl* D)
const;
156 unsigned int VisibilityModifiers(clang::AccessSpecifier access)
const;
157 void ShowError(
const std::string &msg,
const std::string &location =
"")
const;
158 void ShowInfo(
const std::string &msg,
const std::string &location =
"")
const;
159 void ShowTemplateInfo(
const std::string &msg,
const std::string &location =
"")
const;
160 void ShowWarning(
const std::string &msg,
const std::string &location =
"")
const;
163 void UnexpectedDecl(clang::Decl* D,
const std::string &txt =
"")
const;
164 void UnimplementedDecl(clang::Decl* D,
const std::string &txt =
"");
165 void UnimportantDecl(clang::Decl* D,
const std::string &txt =
"")
const;
166 void UnknownDecl(clang::Decl* D,
const std::string &txt =
"")
const;
167 void UnknownType(clang::QualType qual_type)
const;
168 void UnsupportedDecl(clang::Decl* D,
const std::string &txt =
"")
const;
169 void UnsupportedType(clang::QualType qual_type)
const;
173 static const int fgDeclLast = clang::Decl::Var;
174 static const int fgTypeLast = clang::Type::TemplateTypeParm;
175 bool fDeclTable [ fgDeclLast+1 ];
178 bool fTypeTable [ fgTypeLast+1 ];
std::string GetName(const std::string &scope_name)
NamespaceColl_t fSelectedNamespaces
bool TraverseStmt(clang::Stmt *)
RooArgList L(const RooAbsArg &v1)
static std::map< clang::Decl *, std::string > fgAnonymousEnumMap
const clang::NamespaceDecl * fDecl
static std::map< clang::Decl *, std::string > fgAnonymousClassMap
static int fgAnonymousEnumCounter
ROOT::TMetaUtils::TNormalizedCtxt & fNormCtxt
unsigned int fVerboseLevel
SelectionRules & fSelectionRules
static const char * fgClangDeclKey
VariableColl_t fSelectedVariables
static int fgAnonymousClassCounter
FunctionColl_t fSelectedFunctions
bool TraverseClassTemplatePartialSpecializationDecl(clang::ClassTemplatePartialSpecializationDecl *)
The class representing the collection of selection rules.
std::vector< clang::FunctionDecl * > FunctionColl_t
RooCmdArg ShowError(Bool_t flag)
const cling::Interpreter & fInterpreter
std::vector< clang::VarDecl * > VariableColl_t
bool operator<(const AnnotatedNamespaceDecl &right)
const clang::NamespaceDecl * GetNamespaceDecl() const
std::vector< clang::EnumDecl * > EnumColl_t
DeclsSelRulesMap_t fDeclSelRuleMap
Type
enumeration specifying the integration types.
bool shouldVisitTemplateInstantiations() const
const clang::SourceManager * fSourceManager
std::map< clang::Decl *, const BaseSelectionRule * > DeclsSelRulesMap_t
Print a TSeq at the prompt:
std::set< clang::RecordDecl * > fselectedRecordDecls
EnumColl_t fSelectedEnums
bool RequestOnlyTClass() const
AnnotatedNamespaceDecl(clang::NamespaceDecl *decl, long index, bool rRequestOnlyTClass)
typedef void((*Func_t)())
std::vector< ROOT::TMetaUtils::AnnotatedRecordDecl > ClassColl_t
std::vector< AnnotatedNamespaceDecl > NamespaceColl_t
static const char * fgClangFuncKey
const DeclsSelRulesMap_t & GetDeclsSelRulesMap() const
DeclCallback fRecordDeclCallback
static int fgBadClassCounter
std::vector< clang::TypedefNameDecl * > TypedefColl_t
TypedefColl_t fSelectedTypedefs