Merge pull request #2820 from kumpera/license-change-rebased
[mono.git] / mono / metadata / verify.c
index a1e674cfaabaaa11686c8277f1edbfc283e34430..1d291ddb459d2d26df9f940b10ba05548fd50630 100644 (file)
@@ -7,6 +7,7 @@
  * Copyright 2001-2003 Ximian, Inc (http://www.ximian.com)
  * Copyright 2004-2009 Novell, Inc (http://www.novell.com)
  * Copyright 2011 Rodrigo Kumpera
+ * Licensed under the MIT license. See LICENSE file in the project root for full license information.
  */
 #include <config.h>
 
@@ -466,7 +467,7 @@ mono_class_has_default_constructor (MonoClass *klass)
        int i;
 
        mono_class_setup_methods (klass);
-       if (klass->exception_type)
+       if (mono_class_has_failure (klass))
                return FALSE;
 
        for (i = 0; i < klass->method.count; ++i) {
@@ -884,7 +885,7 @@ mono_type_is_valid_in_context (VerifyContext *ctx, MonoType *type)
 
        klass = mono_class_from_mono_type (type);
        mono_class_init (klass);
-       if (mono_loader_get_last_error () || klass->exception_type != MONO_EXCEPTION_NONE) {
+       if (mono_loader_get_last_error () || mono_class_has_failure (klass)) {
                if (klass->generic_class && !mono_class_is_valid_generic_instantiation (NULL, klass))
                        ADD_VERIFY_ERROR2 (ctx, g_strdup_printf ("Invalid generic instantiation of type %s.%s at 0x%04x", klass->name_space, klass->name, ctx->ip_offset), MONO_EXCEPTION_TYPE_LOAD);
                else
@@ -893,7 +894,7 @@ mono_type_is_valid_in_context (VerifyContext *ctx, MonoType *type)
                return FALSE;
        }
 
-       if (klass->generic_class && klass->generic_class->container_class->exception_type != MONO_EXCEPTION_NONE) {
+       if (klass->generic_class && mono_class_has_failure (klass->generic_class->container_class)) {
                ADD_VERIFY_ERROR2 (ctx, g_strdup_printf ("Could not load type %s.%s at 0x%04x", klass->name_space, klass->name, ctx->ip_offset), MONO_EXCEPTION_TYPE_LOAD);
                return FALSE;
        }
@@ -4854,9 +4855,10 @@ mono_method_verify (MonoMethod *method, int level)
                return ctx.list;
        }
 
-       ctx.header = mono_method_get_header (method);
+       ctx.header = mono_method_get_header_checked (method, &error);
        if (!ctx.header) {
-               ADD_VERIFY_ERROR (&ctx, g_strdup_printf ("Could not decode method header"));
+               ADD_VERIFY_ERROR (&ctx, g_strdup_printf ("Could not decode method header due to %s", mono_error_get_message (&error)));
+               mono_error_cleanup (&error);
                finish_collect_stats ();
                return ctx.list;
        }
@@ -5015,7 +5017,7 @@ mono_method_verify (MonoMethod *method, int level)
        if (!ctx.valid)
                goto cleanup;
 
-       original_bb = bb = mono_basic_block_split (method, &error);
+       original_bb = bb = mono_basic_block_split (method, &error, ctx.header);
        if (!mono_error_ok (&error)) {
                ADD_VERIFY_ERROR (&ctx, g_strdup_printf ("Invalid branch target: %s", mono_error_get_message (&error)));
                mono_error_cleanup (&error);
@@ -5959,7 +5961,7 @@ mono_method_verify (MonoMethod *method, int level)
        if (mono_method_is_constructor (ctx.method) && !ctx.super_ctor_called && !ctx.method->klass->valuetype && ctx.method->klass != mono_defaults.object_class) {
                char *method_name = mono_method_full_name (ctx.method, TRUE);
                char *type = mono_type_get_full_name (ctx.method->klass);
-               if (ctx.method->klass->parent && ctx.method->klass->parent->exception_type != MONO_EXCEPTION_NONE)
+               if (ctx.method->klass->parent && mono_class_has_failure (ctx.method->klass->parent))
                        CODE_NOT_VERIFIABLE (&ctx, g_strdup_printf ("Constructor %s for type %s not calling base type ctor due to a TypeLoadException on base type.", method_name, type));
                else
                        CODE_NOT_VERIFIABLE (&ctx, g_strdup_printf ("Constructor %s for type %s not calling base type ctor.", method_name, type));