llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Devajith (devajithvs) <details> <summary>Changes</summary> Use the canonical type when generating type strings to ensure sugared (e.g. `AutoType`, `DecltypeType`) are resolved before calling getFullyQualifiedType. This will revert a few commits that were added to fix these assertions. --- Full diff: https://github.com/llvm/llvm-project/pull/190528.diff 3 Files Affected: - (modified) clang/lib/AST/QualTypeNames.cpp (-22) - (modified) clang/lib/Interpreter/InterpreterValuePrinter.cpp (+5-6) - (modified) clang/test/Interpreter/pretty-print.cpp (+4) ``````````diff diff --git a/clang/lib/AST/QualTypeNames.cpp b/clang/lib/AST/QualTypeNames.cpp index 066c5de35bba9..191841649a86f 100644 --- a/clang/lib/AST/QualTypeNames.cpp +++ b/clang/lib/AST/QualTypeNames.cpp @@ -369,17 +369,6 @@ NestedNameSpecifier createNestedNameSpecifier(const ASTContext &Ctx, /// versions of any template parameters. QualType getFullyQualifiedType(QualType QT, const ASTContext &Ctx, bool WithGlobalNsPrefix) { - // Use the underlying deduced type for AutoType - if (const auto *AT = dyn_cast<AutoType>(QT.getTypePtr())) { - if (AT->isDeduced()) { - // Get the qualifiers. - Qualifiers Quals = QT.getQualifiers(); - QT = AT->getDeducedType(); - // Add back the qualifiers. - QT = Ctx.getQualifiedType(QT, Quals); - } - } - // In case of myType* we need to strip the pointer first, fully // qualify and attach the pointer once again. if (isa<PointerType>(QT.getTypePtr())) { @@ -450,17 +439,6 @@ QualType getFullyQualifiedType(QualType QT, const ASTContext &Ctx, QT = Ctx.getQualifiedType(QT, Quals); } - // Try to get to the underlying type for DecltypeType - while (const auto *DT = dyn_cast<DecltypeType>(QT.getTypePtr())) { - // Get the qualifiers. - Qualifiers Quals = QT.getQualifiers(); - QualType Underlying = DT->getUnderlyingType(); - if (Underlying.isNull() || Underlying->isDependentType()) - break; - // Add back the qualifiers. - QT = Ctx.getQualifiedType(Underlying, Quals); - } - if (const auto *TST = dyn_cast<const TemplateSpecializationType>(QT.getTypePtr())) { diff --git a/clang/lib/Interpreter/InterpreterValuePrinter.cpp b/clang/lib/Interpreter/InterpreterValuePrinter.cpp index cfa50ee908bf8..1754e7812469a 100644 --- a/clang/lib/Interpreter/InterpreterValuePrinter.cpp +++ b/clang/lib/Interpreter/InterpreterValuePrinter.cpp @@ -78,7 +78,7 @@ static std::string QualTypeToString(ASTContext &Ctx, QualType QT) { !NonRefTy->isMemberPointerType()) return Canon.getAsString(Ctx.getPrintingPolicy()); - if (const auto *TDTy = dyn_cast<TypedefType>(NonRefTy)) { + if (const auto *TDTy = dyn_cast<TypedefType>(Canon)) { // FIXME: TemplateSpecializationType & SubstTemplateTypeParmType checks // are predominately to get STL containers to print nicer and might be // better handled in GetFullyQualifiedName. @@ -87,13 +87,12 @@ static std::string QualTypeToString(ASTContext &Ctx, QualType QT) { // std::vector<Type>::value_type is a SubstTemplateTypeParmType // QualType SSDesugar = TDTy->getLocallyUnqualifiedSingleStepDesugaredType(); - if (llvm::isa<SubstTemplateTypeParmType>(SSDesugar)) + if (llvm::isa<SubstTemplateTypeParmType>(SSDesugar) || + llvm::isa<TemplateSpecializationType>(SSDesugar)) return GetFullTypeName(Ctx, Canon); - else if (llvm::isa<TemplateSpecializationType>(SSDesugar)) - return GetFullTypeName(Ctx, NonRefTy); - return DeclTypeToString(NonRefTy, TDTy->getDecl()); + return DeclTypeToString(Canon, TDTy->getDecl()); } - return GetFullTypeName(Ctx, NonRefTy); + return GetFullTypeName(Ctx, Canon); } static std::string EnumToString(const Value &V) { diff --git a/clang/test/Interpreter/pretty-print.cpp b/clang/test/Interpreter/pretty-print.cpp index 852c4117197d8..12133ad877ade 100644 --- a/clang/test/Interpreter/pretty-print.cpp +++ b/clang/test/Interpreter/pretty-print.cpp @@ -85,6 +85,10 @@ decltype(decl1) decl2; decl2 const decltype(N::D()) decl3; decl3 // CHECK-NEXT: (const N::D &) @0x{{[0-9a-f]+}} +// Check printing of UnaryTransformType (this used to assert) +__remove_extent(N::D)* decl4; decl4 +// CHECK-NEXT: (N::D *) @0x{{[0-9a-f]+}} + // int i = 12; // int &iref = i; // iref `````````` </details> https://github.com/llvm/llvm-project/pull/190528 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
