Skip to content
Closed
6 changes: 4 additions & 2 deletions core/clingutils/res/TClingUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -576,12 +576,14 @@ void GetCppName(std::string &output, const char *input);
//______________________________________________________________________________
// Return the type with all parts fully qualified (most typedefs),
// including template arguments, appended to name.
void GetFullyQualifiedTypeName(std::string &name, const clang::QualType &type, const cling::Interpreter &interpreter);
void GetFullyQualifiedTypeName(std::string &name, const clang::QualType &type, const cling::Interpreter &interpreter,
const clang::ClassTemplateSpecializationDecl *Spec = nullptr);

//______________________________________________________________________________
// Return the type with all parts fully qualified (most typedefs),
// including template arguments, appended to name, without using the interpreter
void GetFullyQualifiedTypeName(std::string &name, const clang::QualType &type, const clang::ASTContext &);
void GetFullyQualifiedTypeName(std::string &name, const clang::QualType &type, const clang::ASTContext &,
const clang::ClassTemplateSpecializationDecl *Spec = nullptr);

//______________________________________________________________________________
// Return the type normalized for ROOT,
Expand Down
17 changes: 11 additions & 6 deletions core/clingutils/src/TClingUtils.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1368,7 +1368,8 @@ bool ROOT::TMetaUtils::HasCustomConvStreamerMemberFunction(const AnnotatedRecord

void ROOT::TMetaUtils::GetQualifiedName(std::string &qual_name, const clang::QualType &type, const clang::NamedDecl &forcontext)
{
ROOT::TMetaUtils::GetFullyQualifiedTypeName(qual_name, type, forcontext.getASTContext());
ROOT::TMetaUtils::GetFullyQualifiedTypeName(qual_name, type, forcontext.getASTContext(),
llvm::dyn_cast_or_null<clang::ClassTemplateSpecializationDecl>(&forcontext));
}

//----
Expand Down Expand Up @@ -1483,6 +1484,7 @@ void ROOT::TMetaUtils::CreateNameTypeMap(const clang::CXXRecordDecl &cl, ROOT::M
std::string typenameStr;

const clang::ASTContext& astContext = cl.getASTContext();
auto CTSD = llvm::dyn_cast<clang::ClassTemplateSpecializationDecl>(&cl);

// Loop over the non static data member.
for(clang::RecordDecl::field_iterator field_iter = cl.field_begin(), end = cl.field_end();
Expand All @@ -1507,7 +1509,7 @@ void ROOT::TMetaUtils::CreateNameTypeMap(const clang::CXXRecordDecl &cl, ROOT::M
}
}

GetFullyQualifiedTypeName(typenameStr, fieldType, astContext);
GetFullyQualifiedTypeName(typenameStr, fieldType, astContext, CTSD);
nameType[field_iter->getName().str()] = ROOT::Internal::TSchemaType(typenameStr.c_str(),dims.str().c_str());
}

Expand Down Expand Up @@ -3491,9 +3493,10 @@ llvm::StringRef ROOT::TMetaUtils::GetFileName(const clang::Decl& decl,

void ROOT::TMetaUtils::GetFullyQualifiedTypeName(std::string &typenamestr,
const clang::QualType &qtype,
const clang::ASTContext &astContext)
const clang::ASTContext &astContext,
const clang::ClassTemplateSpecializationDecl *Spec /*= nullptr*/)
{
std::string fqname = cling::utils::TypeName::GetFullyQualifiedName(qtype, astContext);
std::string fqname = cling::utils::TypeName::GetFullyQualifiedName(qtype, astContext, Spec);
TClassEdit::TSplitType splitname(fqname.c_str(),
(TClassEdit::EModType)(TClassEdit::kLong64 | TClassEdit::kDropStd | TClassEdit::kDropStlDefault | TClassEdit::kKeepOuterConst));
splitname.ShortType(typenamestr,TClassEdit::kDropStd | TClassEdit::kDropStlDefault | TClassEdit::kKeepOuterConst);
Expand All @@ -3503,7 +3506,8 @@ void ROOT::TMetaUtils::GetFullyQualifiedTypeName(std::string &typenamestr,

void ROOT::TMetaUtils::GetFullyQualifiedTypeName(std::string &typenamestr,
const clang::QualType &qtype,
const cling::Interpreter &interpreter)
const cling::Interpreter &interpreter,
const clang::ClassTemplateSpecializationDecl *Spec /*= nullptr*/)
{
// We need this because GetFullyQualifiedTypeName is triggering deserialization
// This calling the same name function GetFullyQualifiedTypeName, but this should stay here because
Expand All @@ -3512,7 +3516,8 @@ void ROOT::TMetaUtils::GetFullyQualifiedTypeName(std::string &typenamestr,

GetFullyQualifiedTypeName(typenamestr,
qtype,
interpreter.getCI()->getASTContext());
interpreter.getCI()->getASTContext(),
Spec);
}

////////////////////////////////////////////////////////////////////////////////
Expand Down
27 changes: 9 additions & 18 deletions core/dictgen/res/DictSelectionReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,25 +260,16 @@ class DictSelectionReader : public clang::RecursiveASTVisitor<DictSelectionReade
std::unordered_set<std::string> fUnsplittableMembers {};
};

inline bool
InSelectionNamespace(const clang::RecordDecl &,
const std::string &str =
""); ///< Check if in the ROOT::Meta::Selection namespace
inline bool FirstPass(const clang::RecordDecl &); ///< First pass on the AST
inline bool SecondPass(const clang::RecordDecl &); ///< Second pass on the AST, using the information of the first one
inline void
ManageFields(const clang::RecordDecl &,
const std::string &,
ClassSelectionRule &,
bool); ///< Take care of the class fields
inline void
ManageBaseClasses(const clang::CXXRecordDecl &, const std::string &, bool &); ///< Take care of the class bases
bool InSelectionNamespace(const clang::RecordDecl &,
const std::string &str = ""); ///< Check if in the ROOT::Meta::Selection namespace
bool FirstPass(const clang::RecordDecl &); ///< First pass on the AST
bool SecondPass(const clang::RecordDecl &); ///< Second pass on the AST, using the information of the first one
void ManageFields(const clang::RecordDecl &, const std::string &,
ClassSelectionRule &, bool); ///< Take care of the class fields
void ManageBaseClasses(const clang::CXXRecordDecl &, const std::string &, bool &); ///< Take care of the class bases
template <class T>
inline unsigned int ExtractTemplateArgValue(
const T &,
const std::string &); ///< Extract the value of the template parameter
inline const clang::TemplateArgumentList *GetTmplArgList(
const clang::CXXRecordDecl &); ///< Get the template arguments list if any
unsigned int ExtractTemplateArgValue(const T &, const std::string &); ///< Extract the value of the template parameter
const clang::TemplateArgumentList *GetTmplArgList(const clang::CXXRecordDecl &); ///< Get the template arguments list if any

std::string PatternifyName(const std::string &className); ///< Transform instance name in pattern for selection
void GetPointeeType(std::string &typeName); ///< Get name of the pointee type
Expand Down
15 changes: 15 additions & 0 deletions core/dictgen/src/DictSelectionReader.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -384,12 +384,27 @@ bool DictSelectionReader::SecondPass(const clang::RecordDecl &recordDecl)

bool DictSelectionReader::VisitRecordDecl(clang::RecordDecl *recordDecl)
{
if (auto CXXRD = llvm::dyn_cast<clang::CXXRecordDecl>(recordDecl)) {
if (CXXRD->getDescribedClassTemplate()) {
// this is a member of a template; ignore: dictionaries can only
// select instances / specializations.
return true;
}
}
if (auto CXXRD = llvm::dyn_cast<clang::CXXRecordDecl>(recordDecl->getDeclContext())) {
if (CXXRD->getDescribedClassTemplate()) {
// this is a member of a template; ignore: dictionaries can only
// select instances / specializations.
return true;
}
}
if (fIsFirstPass)
return FirstPass(*recordDecl);
else
return SecondPass(*recordDecl);
}


////////////////////////////////////////////////////////////////////////////////

/**
Expand Down
5 changes: 1 addition & 4 deletions core/metacling/src/TCling.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -9125,10 +9125,7 @@ const char* TCling::MethodInfo_TypeName(MethodInfo_t* minfo) const
std::string TCling::MethodInfo_TypeNormalizedName(MethodInfo_t* minfo) const
{
TClingMethodInfo* info = (TClingMethodInfo*) minfo;
if (info && info->IsValid())
return info->Type()->NormalizedName(*fNormalizedCtxt);
else
return "";
return info->NormalizedName(*fNormalizedCtxt);
}

////////////////////////////////////////////////////////////////////////////////
Expand Down
4 changes: 3 additions & 1 deletion core/metacling/src/TClingDataMemberInfo.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ from the Clang C++ compiler, not CINT.
#include "clang/AST/Attr.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Decl.h"
#include "clang/AST/DeclTemplate.h"
#include "clang/AST/GlobalDecl.h"
#include "clang/AST/Expr.h"
#include "clang/AST/ExprCXX.h"
Expand Down Expand Up @@ -580,7 +581,8 @@ const char *TClingDataMemberInfo::TypeName() const
// if (we_need_to_do_the_subst_because_the_class_is_a_template_instance_of_double32_t)
vdType = ROOT::TMetaUtils::ReSubstTemplateArg(vdType, GetClassAsType() );

ROOT::TMetaUtils::GetFullyQualifiedTypeName(buf, vdType, *fInterp);
auto CTSD = llvm::dyn_cast<clang::ClassTemplateSpecializationDecl>(vd->getDeclContext());
ROOT::TMetaUtils::GetFullyQualifiedTypeName(buf, vdType, *fInterp, CTSD);

return buf.c_str();
}
Expand Down
7 changes: 6 additions & 1 deletion core/metacling/src/TClingMethodArgInfo.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ the Clang C++ compiler, not CINT.
#include "cling/Interpreter/Interpreter.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Decl.h"
#include "clang/AST/DeclTemplate.h"
#include "clang/AST/Expr.h"
#include "clang/AST/ExprCXX.h"
#include "clang/AST/PrettyPrinter.h"
Expand Down Expand Up @@ -148,6 +149,10 @@ const char *TClingMethodArgInfo::TypeName() const
if (!IsValid()) {
return 0;
}
return Type()->Name();

const clang::ClassTemplateSpecializationDecl *spec = nullptr;
if (const auto FD = llvm::cast_or_null<clang::FunctionDecl>(TClingDeclInfo::GetDecl()))
spec = llvm::dyn_cast<clang::ClassTemplateSpecializationDecl>(FD->getDeclContext());
return Type()->Name(spec);
}

15 changes: 13 additions & 2 deletions core/metacling/src/TClingMethodInfo.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,9 @@ const char *TClingMethodInfo::GetPrototype()
if (const clang::TypeDecl *td = llvm::dyn_cast<clang::TypeDecl>(GetDecl()->getDeclContext())) {
std::string name;
clang::QualType qualType(td->getTypeForDecl(),0);
ROOT::TMetaUtils::GetFullyQualifiedTypeName(name,qualType,*fInterp);
const clang::ClassTemplateSpecializationDecl *spec
= llvm::dyn_cast<clang::ClassTemplateSpecializationDecl>(td);
ROOT::TMetaUtils::GetFullyQualifiedTypeName(name, qualType, *fInterp, spec);
buf += name;
buf += "::";
} else if (const clang::NamedDecl *nd = llvm::dyn_cast<clang::NamedDecl>(FD->getDeclContext())) {
Expand Down Expand Up @@ -655,9 +657,18 @@ const char *TClingMethodInfo::TypeName() const
// FIXME: Cint does not check!
return 0;
}
return Type()->Name();

const clang::ClassTemplateSpecializationDecl *spec
= llvm::dyn_cast<clang::ClassTemplateSpecializationDecl>(GetDecl()->getDeclContext());
return Type()->Name(spec);
}

std::string TClingMethodInfo::NormalizedName(ROOT::TMetaUtils::TNormalizedCtxt &ctx) const
{
return Type()->NormalizedName(ctx);
}


const char *TClingMethodInfo::Title()
{
if (!IsValid()) {
Expand Down
1 change: 1 addition & 0 deletions core/metacling/src/TClingMethodInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ class TClingMethodInfo final : public TClingDeclInfo {
const char *GetPrototype();
const char *Name() const override;
const char *TypeName() const;
std::string NormalizedName(ROOT::TMetaUtils::TNormalizedCtxt &ctx) const;
const char *Title();
};

Expand Down
5 changes: 3 additions & 2 deletions core/metacling/src/TClingTypeInfo.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ but the type metadata comes from the Clang C++ compiler, not CINT.

#include "clang/AST/ASTContext.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/DeclTemplate.h"
#include "clang/AST/Type.h"
#include "clang/AST/PrettyPrinter.h"
#include "clang/Frontend/CompilerInstance.h"
Expand Down Expand Up @@ -99,7 +100,7 @@ void TClingTypeInfo::Init(const char *name)

////////////////////////////////////////////////////////////////////////////////

const char *TClingTypeInfo::Name() const
const char *TClingTypeInfo::Name(const clang::ClassTemplateSpecializationDecl *spec) const
{
if (!IsValid()) {
return "";
Expand All @@ -109,7 +110,7 @@ const char *TClingTypeInfo::Name() const
buf.clear();

R__LOCKGUARD(gInterpreterMutex);
ROOT::TMetaUtils::GetFullyQualifiedTypeName(buf,fQualType,*fInterp);
ROOT::TMetaUtils::GetFullyQualifiedTypeName(buf,fQualType,*fInterp, spec);
return buf.c_str(); // NOLINT
}

Expand Down
7 changes: 6 additions & 1 deletion core/metacling/src/TClingTypeInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@

#include "clang/AST/Type.h"

namespace clang {
class ClassTemplateSpecializationDecl;
}

namespace cling {
class Interpreter;
}
Expand Down Expand Up @@ -63,7 +67,8 @@ class TClingTypeInfo final : public TClingDeclInfo {
void Init(const char *name); // Set type by name.
void Init(clang::QualType ty) { fQualType = ty; }
bool IsValid() const override { return !fQualType.isNull(); }
const char *Name() const override; // Get name of type.
const char *Name() const override { return Name(nullptr); }
const char *Name(const clang::ClassTemplateSpecializationDecl *spec) const; // Get name of type.
long Property() const; // Get properties of type.
int RefType() const; // Get CINT reftype of type.
int Size() const; // Get size in bytes of type.
Expand Down
Loading