26#include "TClingUtils.h"
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();
190 if (qt.isConstQualified()) {
194 if (qt->isArrayType()) {
195 qt = llvm::cast<clang::ArrayType>(qt)->getElementType();
198 else if (qt->isReferenceType()) {
200 qt = llvm::cast<clang::ReferenceType>(qt)->getPointeeType();
203 else if (qt->isPointerType()) {
205 if (qt.isConstQualified()) {
208 qt = llvm::cast<clang::PointerType>(qt)->getPointeeType();
211 else if (qt->isMemberPointerType()) {
212 qt = llvm::cast<clang::MemberPointerType>(qt)->getPointeeType();
217 if (qt->isBuiltinType()) {
220 if (qt.isConstQualified()) {
234 clang::ASTContext &context =
fDecl->getASTContext();
235 const clang::TypedefNameDecl *td = llvm::dyn_cast<clang::TypedefNameDecl>(
fDecl);
236 clang::QualType qt = td->getUnderlyingType();
237 if (qt->isDependentType()) {
242 if (
const clang::RecordType *rt = qt->getAs<clang::RecordType>()) {
243 if (!rt->getDecl()->getDefinition()) {
250 cling::Interpreter::PushTransactionRAII pushedT(
fInterp);
253 clang::CharUnits::QuantityType quantity =
254 context.getTypeSizeInChars(qt).getQuantity();
256 return static_cast<int>(quantity);
268 TTHREAD_TLS_DECL( std::string, truename);
270 const clang::TypedefNameDecl *td = llvm::dyn_cast<clang::TypedefNameDecl>(
fDecl);
271 clang::QualType underlyingType = td->getUnderlyingType();
272 if (underlyingType->isBooleanType()) {
275 const clang::ASTContext &ctxt =
fInterp->getCI()->getASTContext();
278 return truename.c_str();
292 const clang::TypedefNameDecl *td = llvm::cast<clang::TypedefNameDecl>(
fDecl);
293 const clang::ASTContext &ctxt = td->getASTContext();
294 ROOT::TMetaUtils::GetFullyQualifiedTypeName(
fNameCache, ctxt.getTypedefType(td), *
fInterp);
313 if (
const TypedefNameDecl *TND = llvm::dyn_cast<TypedefNameDecl>(
GetDecl())) {
314 if ( (TND = ROOT::TMetaUtils::GetAnnotatedRedeclarable(TND)) ) {
315 if (AnnotateAttr *
A = TND->getAttr<AnnotateAttr>()) {
316 fTitle =
A->getAnnotation().str();
321 else if (!
GetDecl()->isFromASTFile()) {
void Error(const char *location, const char *msgfmt,...)
const clang::Decl * fDecl
virtual bool IsValid() const
virtual const clang::Decl * GetDecl() const
const char * Name() override
Get the name of the current typedef.
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)
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)
void GetNormalizedName(std::string &norm_name, std::string_view name)
Return the normalized name.
static constexpr double L