Skip to content
Merged
1 change: 1 addition & 0 deletions mk/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ CFLAGS=\
-Wcast-function-type-mismatch \
-Wsemicolon-before-method-body \
-Wsign-compare \
-Wshadow \
-g \
-I.
SWIFTFLAGS=-g -emit-library
Expand Down
1 change: 0 additions & 1 deletion runtime/monovm-bridge.m
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,6 @@
bool
xamarin_is_class_nsstring (MonoClass *cls)
{
MonoClass *nsstring_class = xamarin_get_nsstring_class ();
if (nsstring_class == NULL)
return false;

Expand Down
20 changes: 12 additions & 8 deletions runtime/runtime.m
Original file line number Diff line number Diff line change
Expand Up @@ -2176,9 +2176,11 @@ -(struct NSObjectData*) xamarinGetNSObjectData;
MarshalManagedExceptionMode mode;
GCHandle exception_gchandle = INVALID_GCHANDLE;

GCHandle handle = xamarin_gchandle_new (exception, false);
mode = xamarin_on_marshal_managed_exception (handle, &exception_gchandle);
xamarin_gchandle_free (handle);
{
GCHandle handle = xamarin_gchandle_new (exception, false);
mode = xamarin_on_marshal_managed_exception (handle, &exception_gchandle);
xamarin_gchandle_free (handle);
}
Comment on lines -2179 to +2183
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this inside its own block?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It defines a local variable named "handle", and there are other locations further down in this method that do the same thing. Putting it inside its own block makes this definition separate from those definitions (which is exactly what the new warning detects).


if (exception_gchandle != INVALID_GCHANDLE) {
PRINT (PRODUCT ": Got an exception while executing the MarshalManagedException event (this exception will be ignored):");
Expand All @@ -2197,7 +2199,7 @@ -(struct NSObjectData*) xamarinGetNSObjectData;
switch (mode) {
#if !defined (CORECLR_RUNTIME) // CoreCLR won't unwind through native frames, so we'll have to abort (in the default case statement)
case MarshalManagedExceptionModeDisable:
case MarshalManagedExceptionModeUnwindNativeCode:
case MarshalManagedExceptionModeUnwindNativeCode: {
//
// We want to maintain the original stack trace of the exception, but unfortunately
// calling mono_raise_exception directly with the original exception will overwrite
Expand All @@ -2210,7 +2212,7 @@ -(struct NSObjectData*) xamarinGetNSObjectData;
// to throw an exception that contains the original stack trace.
//

handle = xamarin_gchandle_new (exception, false);
GCHandle handle = xamarin_gchandle_new (exception, false);
xamarin_rethrow_managed_exception (handle, &exception_gchandle);
xamarin_gchandle_free (handle);

Expand All @@ -2231,8 +2233,9 @@ -(struct NSObjectData*) xamarinGetNSObjectData;
xamarin_handling_unhandled_exceptions = 0;

mono_raise_exception ((MonoException *) exception);
#endif
break;
}
#endif
case MarshalManagedExceptionModeThrowObjectiveCException: {
GCHandle handle = xamarin_gchandle_new (exception, false);
NSException *ns_exc = xamarin_unwrap_ns_exception (handle, &exception_gchandle);
Expand Down Expand Up @@ -2295,13 +2298,14 @@ -(struct NSObjectData*) xamarinGetNSObjectData;
case MarshalManagedExceptionModeUnwindNativeCode:
#endif
case MarshalManagedExceptionModeAbort:
default:
handle = xamarin_gchandle_new (exception, false);
default: {
GCHandle handle = xamarin_gchandle_new (exception, false);
const char *msg = [xamarin_print_all_exceptions (handle) UTF8String];
xamarin_gchandle_free (handle);
xamarin_assertion_message ("Aborting due to trying to marshal managed exception:\n%s\n", msg);
break;
}
}
}

void
Expand Down
14 changes: 6 additions & 8 deletions runtime/trampolines-invoke.m
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@
}

void
xamarin_invoke_trampoline (enum TrampolineType type, id self, SEL sel, iterator_func iterator, marshal_return_value_func marshal_return_value, void *context)
xamarin_invoke_trampoline (enum TrampolineType trampoline_type, id self, SEL sel, iterator_func iterator, marshal_return_value_func marshal_return_value, void *context)
{
MonoObject *exception = NULL;
MonoObject **exception_ptr = xamarin_is_managed_exception_marshaling_disabled () ? NULL : &exception;
GCHandle exception_gchandle = INVALID_GCHANDLE;
bool is_static = (type & Tramp_Static) == Tramp_Static;
bool is_ctor = type == Tramp_Ctor;
bool is_static = (trampoline_type & Tramp_Static) == Tramp_Static;
bool is_ctor = trampoline_type == Tramp_Ctor;
const char *ret_type = NULL;
MonoType *sig_ret_type = NULL;

Expand Down Expand Up @@ -148,8 +148,6 @@
void *iter = NULL;
gboolean needs_writeback = FALSE; // determines if there are any ref/out parameters.
MonoType *p;
int ofs;
unsigned long i;
unsigned long mofs = 0;

unsigned long desc_arg_count = num_arg + 2; /* 1 for the return value + 1 if this is a category instance method */
Expand Down Expand Up @@ -207,11 +205,11 @@
if (exception_gchandle != INVALID_GCHANDLE)
goto exception_handling;

for (i = 0, ofs = 0; i < num_arg; i++) {
for (unsigned long i = 0, ofs = 0; i < num_arg; i++) {
const char *argType = [sig getArgumentTypeAtIndex: (i+2)];
const char *type = xamarin_skip_encoding_flags (argType);
unsigned long size = xamarin_objc_type_size (type);
int frameofs = ofs;
unsigned long frameofs = ofs;
p = mono_signature_get_params (msig, &iter);
ADD_TO_MONOOBJECT_RELEASE_LIST (p);
LOGZ (" argument %i's type: %s (argType: %s)\n", (int) i + 1, type, argType);
Expand Down Expand Up @@ -633,7 +631,7 @@
iterator (IteratorStart, context, NULL, 0, NULL, &exception_gchandle); // start
if (exception_gchandle != INVALID_GCHANDLE)
goto exception_handling;
for (i = 0; i < num_arg; i++) {
for (unsigned long i = 0; i < num_arg; i++) {
const char *type = [sig getArgumentTypeAtIndex: (i+2)];

type = xamarin_skip_encoding_flags (type);
Expand Down