30#include "cling/Interpreter/LookupHelper.h"
31#include "cling/Utils/AST.h"
32#include "clang/AST/Attr.h"
42 :
TClingDeclInfo(nullptr), fInterp(interp), fFirstTime(true), fDescend(false), fTitle(
"")
48 const clang::TypedefNameDecl *TdefD)
49 :
TClingDeclInfo(TdefD), fInterp(interp), fFirstTime(true), fDescend(false), fTitle(
"")
65 fIter = clang::DeclContext::decl_iterator();
70 const char lastChar =
name[strlen(
name) - 1];
71 if (lastChar ==
'*' || lastChar ==
'&' || !strncmp(
name,
"const ", 6))
75 const cling::LookupHelper& lh =
fInterp->getLookupHelper();
76 clang::QualType QT = lh.findType(
name,
77 gDebug > 5 ? cling::LookupHelper::WithDiagnostics
78 : cling::LookupHelper::NoDiagnostics);
83 gDebug > 5 ? cling::LookupHelper::WithDiagnostics
84 : cling::LookupHelper::NoDiagnostics);
90 const clang::TypedefType *td = QT->getAs<clang::TypedefType>();
96 fDecl = td->getDecl();
110 clang::PrintingPolicy Policy(
fDecl->getASTContext().getPrintingPolicy());
111 llvm::raw_string_ostream stream(buf);
112 llvm::dyn_cast<clang::NamedDecl>(
fDecl)
113 ->getNameForDiagnostic(stream, Policy,
false);
115 Error(
"TClingTypedefInfo::InternalNext",
"Next called but iteration not prepared for %s!",buf.c_str());
120 cling::Interpreter::PushTransactionRAII pushedT(
fInterp);
140 clang::DeclContext *dc = llvm::cast<clang::DeclContext>(*
fIter);
141 fIter = dc->decls_begin();
157 if (llvm::isa<clang::TypedefNameDecl>(*
fIter)) {
162 clang::Decl::Kind dk =
fIter->getKind();
163 if ((dk == clang::Decl::Namespace) || (dk == clang::Decl::CXXRecord) ||
164 (dk == clang::Decl::ClassTemplateSpecialization)) {
188 const clang::TypedefNameDecl *td = llvm::dyn_cast<clang::TypedefNameDecl>(
fDecl);
189 clang::QualType qt = td->getUnderlyingType().getCanonicalType();
201 clang::ASTContext &context =
fDecl->getASTContext();
202 const clang::TypedefNameDecl *td = llvm::dyn_cast<clang::TypedefNameDecl>(
fDecl);
205 clang::QualType qt = td->getUnderlyingType();
206 if (qt->isDependentType()) {
211 if (
const clang::RecordType *rt = qt->getAs<clang::RecordType>()) {
212 if (!rt->getDecl()->getDefinition()) {
219 cling::Interpreter::PushTransactionRAII pushedT(
fInterp);
222 clang::CharUnits::QuantityType quantity =
223 context.getTypeSizeInChars(qt).getQuantity();
225 return static_cast<int>(quantity);
237 TTHREAD_TLS_DECL( std::string, truename);
239 const clang::TypedefNameDecl *td = llvm::dyn_cast<clang::TypedefNameDecl>(
fDecl);
242 clang::QualType underlyingType = td->getUnderlyingType();
243 if (underlyingType->isBooleanType()) {
246 const clang::ASTContext &ctxt =
fInterp->getCI()->getASTContext();
249 return truename.c_str();
263 const clang::TypedefNameDecl *td = llvm::cast<clang::TypedefNameDecl>(
fDecl);
264 const clang::ASTContext &ctxt = td->getASTContext();
284 if (
const TypedefNameDecl *TND = llvm::dyn_cast<TypedefNameDecl>(
GetDecl())) {
286 if (AnnotateAttr *A = TND->getAttr<AnnotateAttr>()) {
287 fTitle = A->getAnnotation().str();
292 else if (!
GetDecl()->isFromASTFile()) {
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
const clang::Decl * fDecl
virtual bool IsValid() const
long Property(long property, clang::QualType &qt) const
virtual const clang::Decl * GetDecl() const
const char * TrueName(const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
Get the name of the underlying type of the current typedef.
long Property() const
Return a bit mask of metadata about the current typedef.
clang::DeclContext::decl_iterator fIter
TClingTypedefInfo(cling::Interpreter *interp)
const char * Name() const override
Get the name of the current typedef.
void Init(const char *name)
Lookup named typedef and reset the iterator to point to it.
int InternalNext()
Increment the iterator, return true if new position is valid.
int Next()
Increment the iterator.
int Size() const
Return the size in bytes of the underlying type of the current typedef.
std::vector< clang::DeclContext::decl_iterator > fIterStack
cling::Interpreter * fInterp
std::string InsertStd(const char *tname)