Skip to content

Commit 8c19103

Browse files
fix look up of shadow constructor
shadow constructor need to be reconstructed for the base classes
1 parent 515c1c8 commit 8c19103

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

lib/CppInterOp/CppInterOp.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -855,8 +855,21 @@ static void GetClassDecls(TCppScope_t klass,
855855
if (auto* MD = dyn_cast<DeclType>(DI))
856856
methods.push_back(MD);
857857
else if (auto* USD = dyn_cast<UsingShadowDecl>(DI))
858-
if (auto* MD = dyn_cast<DeclType>(USD->getTargetDecl()))
859-
methods.push_back(MD);
858+
if (auto* MD = dyn_cast<DeclType>(USD->getTargetDecl())) {
859+
if (auto* CUSD = dyn_cast<ConstructorUsingShadowDecl>(DI)) {
860+
if (auto* CXXCD =
861+
dyn_cast_or_null<CXXConstructorDecl>(CUSD->getTargetDecl())) {
862+
CXXConstructorDecl* Result = getSema().findInheritingConstructor(
863+
SourceLocation(), CXXCD, CUSD);
864+
// Result is appended to the decls, i.e. CXXRD, iterator
865+
// non-shadowed decl will be push_back later
866+
// methods.push_back(Result);
867+
(void)Result;
868+
} else
869+
methods.push_back(MD);
870+
} else
871+
methods.push_back(MD);
872+
}
860873
}
861874
}
862875

unittests/CppInterOp/FunctionReflectionTest.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,14 @@ TEST(FunctionReflectionTest, GetClassMethods) {
9595
Cpp::GetClassMethods(Decls[4], methods3);
9696

9797
EXPECT_EQ(methods3.size(), 9);
98-
EXPECT_EQ(get_method_name(methods3[0]), "B::B(int n)");
99-
EXPECT_EQ(get_method_name(methods3[1]), "inline constexpr B::B(const B &)");
100-
EXPECT_EQ(get_method_name(methods3[3]), "inline C::C()");
101-
EXPECT_EQ(get_method_name(methods3[4]), "inline constexpr C::C(const C &)");
102-
EXPECT_EQ(get_method_name(methods3[5]), "inline constexpr C::C(C &&)");
103-
EXPECT_EQ(get_method_name(methods3[6]), "inline C &C::operator=(const C &)");
104-
EXPECT_EQ(get_method_name(methods3[7]), "inline C &C::operator=(C &&)");
105-
EXPECT_EQ(get_method_name(methods3[8]), "inline C::~C()");
98+
EXPECT_EQ(get_method_name(methods3[0]), "inline C::C()");
99+
EXPECT_EQ(get_method_name(methods3[1]), "inline constexpr C::C(const C &)");
100+
EXPECT_EQ(get_method_name(methods3[2]), "inline constexpr C::C(C &&)");
101+
EXPECT_EQ(get_method_name(methods3[3]), "inline C &C::operator=(const C &)");
102+
EXPECT_EQ(get_method_name(methods3[4]), "inline C &C::operator=(C &&)");
103+
EXPECT_EQ(get_method_name(methods3[5]), "inline C::~C()");
104+
EXPECT_EQ(get_method_name(methods3[6]), "inline C::B(int)");
105+
EXPECT_EQ(get_method_name(methods3[7]), "inline constexpr C::B(const B &)");
106106

107107
// Should not crash.
108108
std::vector<Cpp::TCppFunction_t> methods4;

0 commit comments

Comments
 (0)