Skip to content

Commit 545b44e

Browse files
committed
[cxx-interop] Look through template decl to find constructor when importing the function name.
Sometimes, on windows, we get a function template wrapping the constructor decl. In this case, look through the function template to find the constructor decl.
1 parent d9acaf3 commit 545b44e

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lib/ClangImporter/ImportName.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1608,14 +1608,18 @@ ImportedName NameImporter::importNameImpl(const clang::NamedDecl *D,
16081608
SmallString<16> selectorSplitScratch;
16091609
ArrayRef<const clang::ParmVarDecl *> params;
16101610
switch (D->getDeclName().getNameKind()) {
1611-
case clang::DeclarationName::CXXConstructorName:
1611+
case clang::DeclarationName::CXXConstructorName: {
16121612
isInitializer = true;
16131613
isFunction = true;
16141614
result.info.initKind = CtorInitializerKind::Designated;
16151615
baseName = "init";
1616-
addEmptyArgNamesForClangFunction(cast<clang::CXXConstructorDecl>(D),
1617-
argumentNames);
1616+
auto ctor = dyn_cast<clang::CXXConstructorDecl>(D);
1617+
if (auto templateCtor = dyn_cast<clang::FunctionTemplateDecl>(D))
1618+
ctor = cast<clang::CXXConstructorDecl>(templateCtor->getAsFunction());
1619+
assert(ctor && "Unkown decl with CXXConstructorName.");
1620+
addEmptyArgNamesForClangFunction(ctor, argumentNames);
16181621
break;
1622+
}
16191623

16201624
case clang::DeclarationName::CXXConversionFunctionName:
16211625
case clang::DeclarationName::CXXDestructorName:

0 commit comments

Comments
 (0)