-
Notifications
You must be signed in to change notification settings - Fork 31
Add support for array of objects in Construct/Destruct #587
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
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #587 +/- ##
==========================================
+ Coverage 76.36% 76.47% +0.11%
==========================================
Files 9 9
Lines 3655 3673 +18
==========================================
+ Hits 2791 2809 +18
Misses 864 864
🚀 New features to boost your workflow:
|
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.
clang-tidy made some suggestions
There were too many comments to post at once. Showing the first 10 out of 22. Check the log or trigger a new build to see more.
// Forward if we intended to call a dtor with only 1 parameter. | ||
if (m_Kind == kDestructorCall && result && !args.m_Args) | ||
return InvokeDestructor(result, /*nary=*/0UL, /*withFree=*/true); | ||
return InvokeDestructor(result, nary, /*withFree=*/true); |
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: return statement within a void function should not have a specified return value [readability-avoid-return-with-void-value]
return InvokeDestructor(result, nary, /*withFree=*/true); | |
{ InvokeDestructor(result, nary, /*withFree=*/true); return; | |
} |
|
||
#ifndef NDEBUG | ||
assert(AreArgumentsValid(result, args, self) && "Invalid args!"); | ||
ReportInvokeStart(result, args, self); | ||
#endif // NDEBUG | ||
m_GenericCall(self, args.m_ArgSize, args.m_Args, result); | ||
m_GenericCall(self, args.m_ArgSize, args.m_Args, result, nary); |
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: do not access members of unions; use (boost::)variant instead [cppcoreguidelines-pro-type-union-access]
m_GenericCall(self, args.m_ArgSize, args.m_Args, result, nary);
^
|
||
#ifndef NDEBUG | ||
assert(AreArgumentsValid(result, args, self) && "Invalid args!"); | ||
ReportInvokeStart(result, args, self); | ||
#endif // NDEBUG | ||
m_GenericCall(self, args.m_ArgSize, args.m_Args, result); | ||
m_GenericCall(self, args.m_ArgSize, args.m_Args, result, nary); |
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: narrowing conversion from 'size_t' (aka 'unsigned long') to signed type 'int' is implementation-defined [cppcoreguidelines-narrowing-conversions]
m_GenericCall(self, args.m_ArgSize, args.m_Args, result, nary);
^
TCppObject_t Allocate(TCppScope_t scope) { | ||
return (TCppObject_t)::operator new(Cpp::SizeOf(scope)); | ||
TCppObject_t Allocate(TCppScope_t scope, TCppIndex_t count) { | ||
return (TCppObject_t)::operator new(Cpp::SizeOf(scope) * count); |
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: no header providing "operator new" is directly included [misc-include-cleaner]
lib/Interpreter/CppInterOp.cpp:39:
- #if CLANG_VERSION_MAJOR >= 19
+ #include <new>
+ #if CLANG_VERSION_MAJOR >= 19
::operator delete(address); | ||
void Deallocate(TCppScope_t scope, TCppObject_t address, TCppIndex_t count) { | ||
size_t bytes = Cpp::SizeOf(scope) * count; | ||
::operator delete(address, bytes); |
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: no header providing "operator delete" is directly included [misc-include-cleaner]
::operator delete(address, bytes);
^
@@ -3596,7 +3633,8 @@ | |||
auto* const Ctor = GetDefaultConstructor(interp, Class); | |||
if (JitCall JC = MakeFunctionCallable(&interp, Ctor)) { | |||
if (arena) { | |||
JC.Invoke(&arena, {}, (void*)~0); // Tell Invoke to use placement new. | |||
JC.Invoke(&arena, {}, (void*)~0, |
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: do not use C-style cast to convert between unrelated types [cppcoreguidelines-pro-type-cstyle-cast]
JC.Invoke(&arena, {}, (void*)~0,
^
@@ -3596,7 +3633,8 @@ | |||
auto* const Ctor = GetDefaultConstructor(interp, Class); | |||
if (JitCall JC = MakeFunctionCallable(&interp, Ctor)) { | |||
if (arena) { | |||
JC.Invoke(&arena, {}, (void*)~0); // Tell Invoke to use placement new. | |||
JC.Invoke(&arena, {}, (void*)~0, |
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: integer to pointer cast pessimizes optimization opportunities [performance-no-int-to-ptr]
JC.Invoke(&arena, {}, (void*)~0,
^
@@ -3596,7 +3633,8 @@ | |||
auto* const Ctor = GetDefaultConstructor(interp, Class); | |||
if (JitCall JC = MakeFunctionCallable(&interp, Ctor)) { | |||
if (arena) { | |||
JC.Invoke(&arena, {}, (void*)~0); // Tell Invoke to use placement new. | |||
JC.Invoke(&arena, {}, (void*)~0, |
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: multilevel pointer conversion from 'void **' to 'void *', please use explicit cast [bugprone-multi-level-implicit-pointer-conversion]
JC.Invoke(&arena, {}, (void*)~0,
^
@@ -1950,6 +1950,58 @@ TEST(FunctionReflectionTest, ConstructNested) { | |||
output.clear(); | |||
} | |||
|
|||
TEST(FunctionReflectionTest, ConstructArray) { |
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: function 'TEST' can be made static or moved into an anonymous namespace to enforce internal linkage [misc-use-internal-linkage]
TEST(FunctionReflectionTest, ConstructArray) { | |
TESTstatic (FunctionReflectionTest, ConstructArray) { |
testing::internal::CaptureStdout(); | ||
EXPECT_TRUE(where == Cpp::Construct(scope, where, a)); // placement new | ||
// Check for the value of x which should be at the start of the object. | ||
EXPECT_TRUE(*(int*)where == 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: do not use C-style cast to convert between unrelated types [cppcoreguidelines-pro-type-cstyle-cast]
EXPECT_TRUE(*(int*)where == 42);
^
No description provided.