================ @@ -1257,28 +1257,42 @@ void StmtPrinter::VisitConstantExpr(ConstantExpr *Node) { } void StmtPrinter::VisitDeclRefExpr(DeclRefExpr *Node) { - if (const auto *OCED = dyn_cast<OMPCapturedExprDecl>(Node->getDecl())) { + ValueDecl *VD = Node->getDecl(); + if (const auto *OCED = dyn_cast<OMPCapturedExprDecl>(VD)) { OCED->getInit()->IgnoreImpCasts()->printPretty(OS, nullptr, Policy); return; } - if (const auto *TPOD = dyn_cast<TemplateParamObjectDecl>(Node->getDecl())) { + if (const auto *TPOD = dyn_cast<TemplateParamObjectDecl>(VD)) { TPOD->printAsExpr(OS, Policy); return; } if (NestedNameSpecifier *Qualifier = Node->getQualifier()) Qualifier->print(OS, Policy); if (Node->hasTemplateKeyword()) OS << "template "; - if (Policy.CleanUglifiedParameters && - isa<ParmVarDecl, NonTypeTemplateParmDecl>(Node->getDecl()) && - Node->getDecl()->getIdentifier()) - OS << Node->getDecl()->getIdentifier()->deuglifiedName(); - else - Node->getNameInfo().printName(OS, Policy); + DeclarationNameInfo NameInfo = Node->getNameInfo(); + if (IdentifierInfo *ID = NameInfo.getName().getAsIdentifierInfo(); + ID || NameInfo.getName().getNameKind() != DeclarationName::Identifier) { + if (Policy.CleanUglifiedParameters && + isa<ParmVarDecl, NonTypeTemplateParmDecl>(VD) && ID) + OS << ID->deuglifiedName(); + else + NameInfo.printName(OS, Policy); + } else { + switch (VD->getKind()) { + case Decl::NonTypeTemplateParm: { + auto *TD = cast<NonTypeTemplateParmDecl>(VD); + OS << "value-parameter-" << TD->getDepth() << '-' << TD->getIndex() << ""; + break; + } + default: ---------------- erichkeane wrote:
The crash observed happens here. `VD->getKind()` is `Decl::ParmVar`. I wonder if this, for defensive purposes, should at least handle all of the kinds in the `TextNodeDumper`. https://github.com/llvm/llvm-project/pull/124605 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits