diff --git a/core/clingutils/src/TClingUtils.cxx b/core/clingutils/src/TClingUtils.cxx index 047f86fa7605f..b87198313a028 100644 --- a/core/clingutils/src/TClingUtils.cxx +++ b/core/clingutils/src/TClingUtils.cxx @@ -49,6 +49,7 @@ #include "clang/Sema/Lookup.h" #include "clang/Sema/Sema.h" #include "clang/Sema/SemaDiagnostic.h" +#include "clang/AST/QualTypeNames.h" #include "cling/Interpreter/LookupHelper.h" #include "cling/Interpreter/Transaction.h" @@ -3605,7 +3606,10 @@ void ROOT::TMetaUtils::GetFullyQualifiedTypeName(std::string &typenamestr, const clang::QualType &qtype, const clang::ASTContext &astContext) { - std::string fqname = cling::utils::TypeName::GetFullyQualifiedName(qtype, astContext); + clang::PrintingPolicy Policy(astContext.getPrintingPolicy()); + Policy.SuppressScope = false; + Policy.AnonymousTagLocations = true; + std::string fqname = clang::TypeName::getFullyQualifiedName(qtype, astContext, Policy, /*WithGlobalNsPrefix=*/false); 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); diff --git a/interpreter/cling/include/cling/Utils/AST.h b/interpreter/cling/include/cling/Utils/AST.h index c287626299b4c..6ceee68c0ef8c 100644 --- a/interpreter/cling/include/cling/Utils/AST.h +++ b/interpreter/cling/include/cling/Utils/AST.h @@ -303,15 +303,6 @@ namespace utils { clang::QualType GetFullyQualifiedType(clang::QualType QT, const clang::ASTContext& Ctx); - ///\brief Get the fully qualified name for a type. This includes full - /// qualification of all template parameters etc. - /// - ///\param[in] QT - the type for which the fully qualified name will be - /// returned. - ///\param[in] Ctx - the ASTContext to be used. - std::string GetFullyQualifiedName(clang::QualType QT, - const clang::ASTContext &Ctx); - ///\brief Create a NestedNameSpecifier for Namesp and its enclosing /// scopes. /// diff --git a/interpreter/cling/lib/Interpreter/Interpreter.cpp b/interpreter/cling/lib/Interpreter/Interpreter.cpp index ddf1332a56150..ca97606c2bffb 100644 --- a/interpreter/cling/lib/Interpreter/Interpreter.cpp +++ b/interpreter/cling/lib/Interpreter/Interpreter.cpp @@ -43,6 +43,7 @@ #include "clang/AST/ASTContext.h" #include "clang/AST/GlobalDecl.h" +#include "clang/AST/QualTypeNames.h" #include "clang/Basic/SourceManager.h" #include "clang/Basic/TargetInfo.h" #include "clang/CodeGen/ModuleBuilder.h" @@ -1349,9 +1350,13 @@ namespace cling { funcname << "__cling_Destruct_" << RD; largestream code; + const clang::ASTContext &Context = RD->getASTContext(); + clang::PrintingPolicy Policy(Context.getPrintingPolicy()); + Policy.SuppressScope = false; + Policy.AnonymousTagLocations = true; code << "extern \"C\" void " << funcname.str() << "(void* obj){((" - << utils::TypeName::GetFullyQualifiedName( - clang::QualType(RD->getTypeForDecl(), 0), RD->getASTContext()) + << clang::TypeName::getFullyQualifiedName( + clang::QualType(RD->getTypeForDecl(), 0), Context, Policy, /*WithGlobalNsPrefix=*/false) << "*)obj)->~" << RD->getNameAsString() << "();}"; // ifUniq = false: we know it's unique, no need to check. diff --git a/interpreter/cling/lib/Interpreter/ValueExtractionSynthesizer.cpp b/interpreter/cling/lib/Interpreter/ValueExtractionSynthesizer.cpp index 41095fc3a9829..e3e6497e979c7 100644 --- a/interpreter/cling/lib/Interpreter/ValueExtractionSynthesizer.cpp +++ b/interpreter/cling/lib/Interpreter/ValueExtractionSynthesizer.cpp @@ -21,6 +21,7 @@ #include "clang/Sema/Lookup.h" #include "clang/Sema/Sema.h" #include "clang/Sema/SemaDiagnostic.h" +#include "clang/AST/QualTypeNames.h" using namespace clang; @@ -394,8 +395,11 @@ namespace { locStart, CallArgs, locEnd); } else { + clang::PrintingPolicy Policy(m_Context->getPrintingPolicy()); + Policy.SuppressScope = false; + Policy.AnonymousTagLocations = true; m_Sema->Diag(locStart, diag::err_unsupported_unknown_any_decl) << - utils::TypeName::GetFullyQualifiedName(desugaredTy, *m_Context) << + clang::TypeName::getFullyQualifiedName(desugaredTy, *m_Context, Policy, /*WithGlobalNsPrefix=*/false) << SourceRange(locStart, locEnd); } } diff --git a/interpreter/cling/lib/Interpreter/ValuePrinter.cpp b/interpreter/cling/lib/Interpreter/ValuePrinter.cpp index 07cbf8cc1ceaa..eb1423dfaab1f 100644 --- a/interpreter/cling/lib/Interpreter/ValuePrinter.cpp +++ b/interpreter/cling/lib/Interpreter/ValuePrinter.cpp @@ -36,6 +36,7 @@ #include "clang/Parse/Parser.h" #include "clang/Sema/Lookup.h" #include "clang/Sema/Sema.h" +#include "clang/AST/QualTypeNames.h" #include "llvm/ADT/StringExtras.h" #include "llvm/Support/ConvertUTF.h" @@ -97,7 +98,10 @@ static std::string enclose(std::string Mid, const char* Begin, static std::string enclose(const clang::QualType& Ty, clang::ASTContext& C, const char* Begin = "(", const char* End = "*)", size_t Hint = 3) { - return enclose(cling::utils::TypeName::GetFullyQualifiedName(Ty, C), + clang::PrintingPolicy Policy(C.getPrintingPolicy()); + Policy.SuppressScope = false; + Policy.AnonymousTagLocations = true; + return enclose(clang::TypeName::getFullyQualifiedName(Ty, C, Policy, /*WithGlobalNsPrefix=*/false), Begin, End, Hint); } @@ -148,16 +152,24 @@ static std::string printQualType(clang::ASTContext& Ctx, clang::QualType QT) { // std::vector::iterator is a TemplateSpecializationType // std::vector::value_type is a SubstTemplateTypeParmType // + clang::PrintingPolicy Policy(Ctx.getPrintingPolicy()); + Policy.SuppressScope = false; + Policy.AnonymousTagLocations = true; + QualType SSDesugar = TDTy->getLocallyUnqualifiedSingleStepDesugaredType(); if (dyn_cast(SSDesugar)) - ValueTyStr += utils::TypeName::GetFullyQualifiedName(QTCanon, Ctx); + ValueTyStr += clang::TypeName::getFullyQualifiedName(QTCanon, Ctx, Policy, /*WithGlobalNsPrefix=*/false); else if (dyn_cast(SSDesugar)) - ValueTyStr += utils::TypeName::GetFullyQualifiedName(QTNonRef, Ctx); + ValueTyStr += clang::TypeName::getFullyQualifiedName(QTNonRef, Ctx, Policy, /*WithGlobalNsPrefix=*/false); else ValueTyStr += printDeclType(QTNonRef, TDTy->getDecl()); } - else - ValueTyStr += utils::TypeName::GetFullyQualifiedName(QTNonRef, Ctx); + else { + clang::PrintingPolicy Policy(Ctx.getPrintingPolicy()); + Policy.SuppressScope = false; + Policy.AnonymousTagLocations = true; + ValueTyStr += clang::TypeName::getFullyQualifiedName(QTNonRef, Ctx, Policy, /*WithGlobalNsPrefix=*/false); + } } if (QT->isReferenceType()) diff --git a/interpreter/cling/lib/Utils/AST.cpp b/interpreter/cling/lib/Utils/AST.cpp index 3fd1e600b1061..c60cd8c8a8be8 100644 --- a/interpreter/cling/lib/Utils/AST.cpp +++ b/interpreter/cling/lib/Utils/AST.cpp @@ -1754,14 +1754,5 @@ namespace utils { return QT; } - std::string TypeName::GetFullyQualifiedName(QualType QT, - const ASTContext &Ctx) { - QualType FQQT = GetFullyQualifiedType(QT, Ctx); - PrintingPolicy Policy(Ctx.getPrintingPolicy()); - Policy.SuppressScope = false; - Policy.AnonymousTagLocations = false; - return FQQT.getAsString(Policy); - } - } // end namespace utils } // end namespace cling