12 #ifndef ROOT_TMetaUtils
13 #define ROOT_TMetaUtils
19 #include <unordered_set>
31 class ClassTemplateDecl;
32 class ClassTemplateSpecializationDecl;
33 class CompilerInstance;
34 class CXXBaseSpecifier;
51 class TemplateArgument;
52 class TemplateArgumentList;
53 class TemplateParameterList;
56 class TypedefNameDecl;
57 struct PrintingPolicy;
81 namespace TMetaUtils {
84 class AnnotatedRecordDecl;
90 static const std::string
separator(
"@@@");
91 static const std::string
iotype(
"iotype");
92 static const std::string
name(
"name");
93 static const std::string
pattern(
"pattern");
94 static const std::string
ioname(
"ioname");
95 static const std::string
comment(
"comment");
96 static const std::string
nArgsToKeep(
"nArgsToKeep");
97 static const std::string
persistent(
"persistent");
98 static const std::string
transient(
"transient");
105 const cling::Interpreter &interp,
107 std::ostream& dictStream,
108 bool isAutoStreamer);
120 class TNormalizedCtxtImpl;
141 bool replace =
false);
162 const int *pgDebug = 0);
168 virtual bool IsDeclaredScope(
const std::string &base,
bool &isInlined);
195 const clang::RecordDecl *decl,
198 bool rRequestNoInputOperator,
199 bool rRequestOnlyTClass,
200 int rRequestedVersionNumber,
201 const cling::Interpreter &interpret,
205 const clang::RecordDecl *decl,
206 const char *requestName,
209 bool rRequestNoInputOperator,
210 bool rRequestOnlyTClass,
211 int rRequestedVersionNumber,
212 const cling::Interpreter &interpret,
217 const clang::RecordDecl *decl,
218 const char *requestedName,
221 bool rRequestNoInputOperator,
222 bool rRequestOnlyTClass,
223 int rRequestedVersionNumber,
224 const cling::Interpreter &interpret,
229 const clang::RecordDecl *decl,
230 const char *requestedName,
231 unsigned int nTemplateArgsToSkip,
234 bool rRequestNoInputOperator,
235 bool rRequestOnlyTClass,
236 int rRequestedVersionNumber,
237 const cling::Interpreter &interpret,
270 operator clang::RecordDecl
const *()
const {
297 const clang::CXXRecordDecl *
GetType()
const;
314 const std::string& propName,
315 std::string& propValue);
319 const std::string& propName,
323 bool RequireCompleteType(
const cling::Interpreter &interp,
const clang::CXXRecordDecl *cl);
331 const cling::Interpreter &interpret,
343 const clang::FunctionDecl*
ClassInfo__HasMethod(
const clang::DeclContext *cl,
char const*,
const cling::Interpreter& interp);
350 const clang::NamedDecl &forcontext,
351 const clang::QualType &qti,
354 const cling::Interpreter &interp,
358 bool IsBase(
const clang::CXXRecordDecl *cl,
const clang::CXXRecordDecl *base,
const clang::CXXRecordDecl *context,
const cling::Interpreter &interp);
361 bool IsBase(
const clang::FieldDecl &
m,
const char* basename,
const cling::Interpreter &interp);
379 bool HasNewMerge(clang::CXXRecordDecl
const*,
const cling::Interpreter&);
382 bool HasOldMerge(clang::CXXRecordDecl
const*,
const cling::Interpreter&);
385 bool hasOpaqueTypedef(clang::QualType instanceType,
const TNormalizedCtxt &normCtxt);
388 bool hasOpaqueTypedef(
const AnnotatedRecordDecl &cl,
const cling::Interpreter &interp,
const TNormalizedCtxt &normCtxt);
401 const cling::Interpreter&,
bool diagnose);
410 void GetQualifiedName(std::string &qual_name,
const clang::QualType &
type,
const clang::NamedDecl &forcontext);
428 void GetQualifiedName(std::string &qual_name,
const AnnotatedRecordDecl &annotated);
434 void GetQualifiedName(std::string &qual_name,
const clang::RecordDecl &recordDecl);
446 void WritePointersSTL(
const AnnotatedRecordDecl &cl,
const cling::Interpreter &interp,
const TNormalizedCtxt &normCtxt);
449 int GetClassVersion(
const clang::RecordDecl *cl,
const cling::Interpreter &interp);
473 std::string
TrueName(
const clang::FieldDecl &
m);
477 const cling::Interpreter &
gInterp,
483 const AnnotatedRecordDecl &cl,
484 const clang::CXXRecordDecl *decl,
485 const cling::Interpreter &interp,
487 const TNormalizedCtxt &normCtxt);
494 const cling::Interpreter &
gInterp,
499 const AnnotatedRecordDecl &cl,
500 const cling::Interpreter &interp,
501 const TNormalizedCtxt &normCtxt,
502 std::ostream& finalString,
508 const AnnotatedRecordDecl &cl,
509 const clang::CXXRecordDecl *decl,
510 const cling::Interpreter &interp,
511 const TNormalizedCtxt &normCtxt,
513 bool& needCollectionProxy);
517 const clang::CXXRecordDecl* clxx,
518 const cling::Interpreter &interp,
519 const TNormalizedCtxt &normCtxt);
523 const clang::CXXRecordDecl* clxx,
524 const cling::Interpreter &interp,
525 const TNormalizedCtxt &normCtxt);
529 llvm::StringRef
GetFileName(
const clang::Decl& decl,
530 const cling::Interpreter& interp);
539 const char* moduleFileName,
540 const char* headers[]);
563 clang::QualType
GetNormalizedType(
const clang::QualType &
type,
const cling::Interpreter &interpreter,
const TNormalizedCtxt &normCtxt);
570 void GetNormalizedName(std::string &norm_name,
const clang::QualType &
type,
const cling::Interpreter &interpreter,
const TNormalizedCtxt &normCtxt);
575 const clang::TypeDecl* typeDecl,
576 const cling::Interpreter &interpreter);
581 clang::QualType
GetTypeForIO(
const clang::QualType& templateInstanceType,
582 const cling::Interpreter &interpreter,
583 const TNormalizedCtxt &normCtxt,
589 std::pair<std::string,clang::QualType>
GetNameTypeForIO(
const clang::QualType& templateInstanceType,
590 const cling::Interpreter &interpreter,
591 const TNormalizedCtxt &normCtxt,
596 llvm::StringRef
GetComment(
const clang::Decl &decl, clang::SourceLocation *loc = 0);
600 llvm::StringRef
GetClassComment(
const clang::CXXRecordDecl &decl, clang::SourceLocation *loc,
const cling::Interpreter &interpreter);
616 Redecl = Redecl->getMostRecentDecl();
617 while (Redecl && !Redecl->hasAttrs())
618 Redecl = Redecl->getPreviousDecl();
647 bool IsOfType(
const clang::CXXRecordDecl &cl,
const std::string&
type,
const cling::LookupHelper& lh);
668 clang::ClassTemplateDecl*& ctd,
669 clang::ClassTemplateSpecializationDecl*& ctsd);
677 std::list<std::pair<std::string,bool> >&);
680 std::list<std::pair<std::string,bool> >&);
684 std::list<std::pair<std::string,unsigned int> >& enclosingSc);
694 void ReplaceAll(std::string& str,
const std::string& from,
const std::string& to,
bool recurse=
false);
700 static unsigned int gNumberOfWarningsAndErrors = 0;
701 return gNumberOfWarningsAndErrors;
711 inline void LevelPrint(
bool prefix,
int level,
const char *location,
const char *fmt, va_list ap)
716 const char *
type = 0;
731 if (!location || !location[0]) {
732 if (prefix) fprintf(stderr,
"%s: ", type);
733 vfprintf(stderr, (
const char*)
va_(fmt), ap);
735 if (prefix) fprintf(stderr,
"%s in <%s>: ", type, location);
736 else fprintf(stderr,
"In <%s>: ", location);
737 vfprintf(stderr, (
const char*)
va_(fmt), ap);
751 inline void Error(
const char *location,
const char *
va_(fmt), ...)
754 va_start(ap,
va_(fmt));
761 inline void SysError(
const char *location,
const char *
va_(fmt), ...)
764 va_start(ap,
va_(fmt));
771 inline void Info(
const char *location,
const char *
va_(fmt), ...)
774 va_start(ap,
va_(fmt));
781 inline void Warning(
const char *location,
const char *
va_(fmt), ...)
784 va_start(ap,
va_(fmt));
791 inline void Fatal(
const char *location,
const char *
va_(fmt), ...)
794 va_start(ap,
va_(fmt));
803 bool EndsWith(
const std::string &theString,
const std::string &theSubstring);
806 bool BeginsWith(
const std::string &theString,
const std::string &theSubstring);
809 namespace AST2SourceTools {
812 const std::string
Decls2FwdDecls(
const std::vector<const clang::Decl*> &decls,
813 bool (*ignoreFiles)(
const clang::PresumedLoc&) ,
814 const cling::Interpreter& interp);
818 const clang::TemplateParameterList& tmplParamList,
819 const cling::Interpreter& interpreter);
825 const clang::RecordDecl*
EncloseInScopes(
const clang::Decl& decl, std::string& defString);
829 const cling::Interpreter& interpreter,
830 std::string& defString,
831 bool acceptStl=
false);
835 const cling::Interpreter& interpreter,
836 std::string& defString);
838 int GetDefArg(
const clang::ParmVarDecl&
par, std::string& valAsString,
const clang::PrintingPolicy& pp);
842 const cling::Interpreter& interpreter,
843 std::string& defString);
846 const cling::Interpreter& interpreter,
847 std::string& fwdDeclString,
848 std::unordered_set<std::string>* fwdDeclSet=
nullptr);
856 #endif // ROOT_TMetaUtils
R__EXTERN Int_t gErrorIgnoreLevel
cling::Interpreter * gInterp
Type
enumeration specifying the integration types.
typedef void((*Func_t)())