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)
49 : fInterp(interp), fFirstTime(true), fDescend(
false), fDecl(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();
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()) {
264 clang::CharUnits::QuantityType quantity =
265 context.getTypeSizeInChars(qt).getQuantity();
267 return static_cast<int>(quantity);
279 TTHREAD_TLS_DECL( std::string, truename);
281 const clang::TypedefNameDecl *td = llvm::dyn_cast<clang::TypedefNameDecl>(
fDecl);
282 clang::QualType underlyingType = td->getUnderlyingType();
283 if (underlyingType->isBooleanType()) {
286 const clang::ASTContext &ctxt =
fInterp->getCI()->getASTContext();
289 return truename.c_str();
301 TTHREAD_TLS_DECL( std::string, fullname);
303 const clang::TypedefNameDecl *td = llvm::dyn_cast<clang::TypedefNameDecl>(
fDecl);
304 const clang::ASTContext &ctxt =
fDecl->getASTContext();
306 return fullname.c_str();
324 if (
const TypedefNameDecl *TND = llvm::dyn_cast<TypedefNameDecl>(
GetDecl())) {
326 if (AnnotateAttr *
A = TND->getAttr<AnnotateAttr>()) {
327 fTitle =
A->getAnnotation().str();
332 else if (!
GetDecl()->isFromASTFile()) {
int InternalNext()
Increment the iterator, return true if new position is valid.
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
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.
ClassImp(TIterator) Bool_t TIterator return false
Compare two iterator objects.
int Next()
Increment the iterator.
long Property() const
Return a bit mask of metadata about the current typedef.
TClingTypedefInfo(cling::Interpreter *interp)
void Error(const char *location, const char *msgfmt,...)
const clang::Decl * GetDecl() const
Get the current typedef declaration.
const char * Name() const
Get the name of the current typedef.
int Size() const
Return the size in bytes of the underlying type of the current typedef.
bool IsValid() const
Return true if the current iterator position is valid.
cling::Interpreter * fInterp