Skip to content

Commit d843279

Browse files
committed
[cxx-interop] Bail instead of crashing If we cannot find a constructor decl in importNameImpl.
It's possible to have a "UnresolvedUsingValueDecl" with a "CXXConstructorName". If that's the case (or if there's any other unkown decl) bail instead of crashing.
1 parent f0f2246 commit d843279

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/ClangImporter/ImportName.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1616,7 +1616,9 @@ ImportedName NameImporter::importNameImpl(const clang::NamedDecl *D,
16161616
auto ctor = dyn_cast<clang::CXXConstructorDecl>(D);
16171617
if (auto templateCtor = dyn_cast<clang::FunctionTemplateDecl>(D))
16181618
ctor = cast<clang::CXXConstructorDecl>(templateCtor->getAsFunction());
1619-
assert(ctor && "Unkown decl with CXXConstructorName.");
1619+
// If we couldn't find a constructor decl, bail.
1620+
if (!ctor)
1621+
return ImportedName();
16201622
addEmptyArgNamesForClangFunction(ctor, argumentNames);
16211623
break;
16221624
}

test/Interop/Cxx/class/Inputs/constructors.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,9 @@ struct EmptyStruct {};
4343
struct IntWrapper {
4444
int x;
4545
};
46+
47+
// TODO: we should be able to import this constructor correctly. Until we can,
48+
// make sure not to crash.
49+
struct UsingBaseConstructor : ConstructorWithParam {
50+
using ConstructorWithParam::ConstructorWithParam;
51+
};

0 commit comments

Comments
 (0)