-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add test to check if typedefs are being unnecessarily resolved #124
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -849,6 +849,39 @@ TEST(FunctionReflectionTest, JitCallAdvanced) { | |||||
EXPECT_TRUE(object) << "Failed to call the ctor."; | ||||||
// Building a wrapper with a typedef decl must be possible. | ||||||
Cpp::Destruct(object, Decls[1]); | ||||||
|
||||||
// Test to check if typedefs are unnecessarily resolved during the creation | ||||||
// of the wrapper | ||||||
Interp->process(R"( | ||||||
class TDT { | ||||||
private: | ||||||
class PC { | ||||||
public: | ||||||
PC(int i) : m_val(i) {} | ||||||
int m_val; | ||||||
}; | ||||||
|
||||||
public: | ||||||
typedef PC PP; | ||||||
PP f() { return PC(42); } | ||||||
}; | ||||||
)"); | ||||||
|
||||||
clang::NamedDecl *ClassTDT = (clang::NamedDecl*) Cpp::GetNamed("TDT"); | ||||||
auto *CtorTDT = | ||||||
(clang::CXXConstructorDecl*) Cpp::GetDefaultConstructor(ClassTDT); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: do not use C-style cast to convert between unrelated types [cppcoreguidelines-pro-type-cstyle-cast] (clang::CXXConstructorDecl*) Cpp::GetDefaultConstructor(ClassTDT);
^ |
||||||
auto FCI_CtorTDT = Cpp::MakeFunctionCallable(CtorTDT); | ||||||
void* objectTDT = nullptr; | ||||||
FCI_CtorTDT.Invoke((void*)&objectTDT); | ||||||
EXPECT_TRUE(objectTDT != nullptr); | ||||||
clang::NamedDecl *TDT_f = (clang::NamedDecl*) Cpp::GetNamed("f", ClassTDT); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: use auto when initializing with a cast to avoid duplicating the type name [modernize-use-auto]
Suggested change
|
||||||
auto FCI_TDT_f = Cpp::MakeFunctionCallable(TDT_f); | ||||||
void* objectTDT_PP = nullptr; | ||||||
FCI_TDT_f.Invoke((void*) &objectTDT_PP, {}, objectTDT); | ||||||
EXPECT_TRUE(objectTDT_PP != nullptr); | ||||||
std::stringstream ss_mval; | ||||||
ss_mval << "(" << objectTDT_PP << ")->mval"; | ||||||
EXPECT_EQ(Cpp::Evaluate(ss_mval.str().c_str()), 42); | ||||||
} | ||||||
|
||||||
|
||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: use auto when initializing with a cast to avoid duplicating the type name [modernize-use-auto]