Skip to content

Commit 0464fd3

Browse files
authored
Merge pull request #60253 from apple/egorzhdan/cxx-declname-crash
[cxx-interop] Do not crash when diagnosing cycles for C++ operators
2 parents 497ae4e + 29b579e commit 0464fd3

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lib/ClangImporter/ImportDecl.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8193,9 +8193,13 @@ ClangImporter::Implementation::importDeclForDeclContext(
81938193
if (!contextDeclsWarnedAbout.insert(contextDecl).second)
81948194
return nullptr;
81958195

8196-
auto getDeclName = [](const clang::Decl *D) -> StringRef {
8197-
if (auto ND = dyn_cast<clang::NamedDecl>(D))
8198-
return ND->getName();
8196+
auto getDeclName = [](const clang::Decl *D) -> std::string {
8197+
if (auto ND = dyn_cast<clang::NamedDecl>(D)) {
8198+
std::string name;
8199+
llvm::raw_string_ostream os(name);
8200+
ND->printName(os);
8201+
return name;
8202+
}
81998203
return "<anonymous>";
82008204
};
82018205

0 commit comments

Comments
 (0)