diff --git a/kythe/cxx/indexer/cxx/decl_printer.cc b/kythe/cxx/indexer/cxx/decl_printer.cc index a2cb48621b..83f742fdae 100644 --- a/kythe/cxx/indexer/cxx/decl_printer.cc +++ b/kythe/cxx/indexer/cxx/decl_printer.cc @@ -192,7 +192,9 @@ bool DeclPrinter::PrintDeclarationName(const clang::DeclarationName& name, [[fallthrough]]; case DeclarationName::CXXConstructorName: if (const auto type = name.getCXXNameType(); !type.isNull()) { - return PrintNamedDecl(*type->getAsCXXRecordDecl(), out); + // UnresolvedUsingValueDecl (and potentially others) result in a + // non-null QualType, but a null CXXRecordDecl. + return PrintName(type->getAsCXXRecordDecl(), out); } break; // These will be given parent-relative identifiers. diff --git a/kythe/cxx/indexer/cxx/decl_printer_test.cc b/kythe/cxx/indexer/cxx/decl_printer_test.cc index 82ac848456..ddf4d88521 100644 --- a/kythe/cxx/indexer/cxx/decl_printer_test.cc +++ b/kythe/cxx/indexer/cxx/decl_printer_test.cc @@ -291,5 +291,25 @@ TEST(DeclPrinterTest, AnonymousNamespace) { EXPECT_THAT(decl, Pointee(HasQualifiedId(printer, "foo:@#anon"))); } +TEST(DeclPrinterTest, UnresolvedUsingValueDecl) { + using ::clang::ast_matchers::unresolvedUsingValueDecl; + constexpr std::string_view code = R"c++( + template + struct Base {}; + template + struct Child : Base { + using Base::Base; + }; + )c++"; + + ParsedUnit unit(buildASTFromCode(code, "input.cc")); + DeclPrinter printer = unit.CreateDeclPrinter(); + const auto* decl = FindSingleDeclOrDie( + unresolvedUsingValueDecl(), unit.ast_context()); + + EXPECT_THAT(decl, + Pointee(HasQualifiedId(printer, MatchesRegex(R"([0-9]:Child)")))); +} + } // namespace } // namespace kythe