30 #include "cling/Interpreter/LookupHelper.h" 31 #include "cling/Utils/AST.h" 32 #include "clang/AST/Attr.h" 34 using namespace clang;
42 : fInterp(interp), fFirstTime(true), fDescend(false), fDecl(0), fTitle(
"")
48 const clang::TypedefNameDecl *TdefD)
74 fIter = clang::DeclContext::decl_iterator();
78 if (!name || !*name)
return;
79 const char lastChar = name[strlen(name) - 1];
80 if (lastChar ==
'*' || lastChar ==
'&' || !strncmp(name,
"const ", 6))
84 const cling::LookupHelper& lh =
fInterp->getLookupHelper();
85 clang::QualType QT = lh.findType(name,
86 gDebug > 5 ? cling::LookupHelper::WithDiagnostics
87 : cling::LookupHelper::NoDiagnostics);
92 gDebug > 5 ? cling::LookupHelper::WithDiagnostics
93 : cling::LookupHelper::NoDiagnostics);
99 const clang::TypedefType *td = QT->getAs<clang::TypedefType>();
105 fDecl = td->getDecl();
125 clang::PrintingPolicy Policy(
fDecl->getASTContext().getPrintingPolicy());
126 llvm::raw_string_ostream stream(buf);
127 llvm::dyn_cast<clang::NamedDecl>(
fDecl)
128 ->getNameForDiagnostic(stream, Policy,
false);
130 Error(
"TClingTypedefInfo::InternalNext",
"Next called but iteration not prepared for %s!",buf.c_str());
135 cling::Interpreter::PushTransactionRAII pushedT(
fInterp);
155 clang::DeclContext *dc = llvm::cast<clang::DeclContext>(*fIter);
156 fIter = dc->decls_begin();
172 if (llvm::isa<clang::TypedefNameDecl>(*
fIter)) {
177 clang::Decl::Kind dk =
fIter->getKind();
178 if ((dk == clang::Decl::Namespace) || (dk == clang::Decl::CXXRecord) ||
179 (dk == clang::Decl::ClassTemplateSpecialization)) {
203 const clang::TypedefNameDecl *td = llvm::dyn_cast<clang::TypedefNameDecl>(
fDecl);
204 clang::QualType qt = td->getUnderlyingType().getCanonicalType();
205 if (qt.isConstQualified()) {
209 if (qt->isArrayType()) {
210 qt = llvm::cast<clang::ArrayType>(qt)->getElementType();
213 else if (qt->isReferenceType()) {
215 qt = llvm::cast<clang::ReferenceType>(qt)->getPointeeType();
218 else if (qt->isPointerType()) {
220 if (qt.isConstQualified()) {
223 qt = llvm::cast<clang::PointerType>(qt)->getPointeeType();
226 else if (qt->isMemberPointerType()) {
227 qt = llvm::cast<clang::MemberPointerType>(qt)->getPointeeType();
232 if (qt->isBuiltinType()) {
235 if (qt.isConstQualified()) {
249 clang::ASTContext &context =
fDecl->getASTContext();
250 const clang::TypedefNameDecl *td = llvm::dyn_cast<clang::TypedefNameDecl>(
fDecl);
251 clang::QualType qt = td->getUnderlyingType();
252 if (qt->isDependentType()) {
257 if (
const clang::RecordType *rt = qt->getAs<clang::RecordType>()) {
258 if (!rt->getDecl()->getDefinition()) {
265 cling::Interpreter::PushTransactionRAII pushedT(
fInterp);
268 clang::CharUnits::QuantityType quantity =
269 context.getTypeSizeInChars(qt).getQuantity();
271 return static_cast<int>(quantity);
283 TTHREAD_TLS_DECL( std::string, truename);
285 const clang::TypedefNameDecl *td = llvm::dyn_cast<clang::TypedefNameDecl>(
fDecl);
286 clang::QualType underlyingType = td->getUnderlyingType();
287 if (underlyingType->isBooleanType()) {
290 const clang::ASTContext &ctxt =
fInterp->getCI()->getASTContext();
293 return truename.c_str();
305 TTHREAD_TLS_DECL( std::string, fullname);
307 const clang::TypedefNameDecl *td = llvm::dyn_cast<clang::TypedefNameDecl>(
fDecl);
308 const clang::ASTContext &ctxt =
fDecl->getASTContext();
310 return fullname.c_str();
328 if (
const TypedefNameDecl *TND = llvm::dyn_cast<TypedefNameDecl>(
GetDecl())) {
330 if (AnnotateAttr *
A = TND->getAttr<AnnotateAttr>()) {
331 fTitle =
A->getAnnotation().str();
336 else if (!
GetDecl()->isFromASTFile()) {
int InternalNext()
Increment the iterator, return true if new position is valid.
int Size() const
Return the size in bytes of the underlying type of the current typedef.
RooArgList L(const RooAbsArg &v1)
void Init(const char *name)
Lookup named typedef and reset the iterator to point to it.
const clang::Decl * fDecl
const char * Name() const
Get the name of the current typedef.
std::vector< clang::DeclContext::decl_iterator > fIterStack
clang::DeclContext::decl_iterator fIter
std::string InsertStd(const char *tname)
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.
int Next()
Increment the iterator.
TClingTypedefInfo(cling::Interpreter *interp)
void Error(const char *location, const char *msgfmt,...)
bool IsValid() const
Return true if the current iterator position is valid.
cling::Interpreter * fInterp
const clang::Decl * GetDecl() const
Get the current typedef declaration.