#pragma once
#include <luna/Types.h>

namespace UBSAN
{
    struct SourceLocation
    {
        const char* file;
        u32 line;
        u32 column;
    };

    struct TypeDescriptor
    {
        u16 kind;
        u16 info;
        char name[];
    };

    namespace UBInfo
    {
        struct TypeMismatchInfo
        {
            SourceLocation location;
            TypeDescriptor* type;
            usize alignment;
            u8 type_check_kind;
        };

        struct TypeMismatchInfo_v1
        {
            SourceLocation location;
            TypeDescriptor* type;
            u8 log_alignment;
            u8 type_check_kind;
        };

        struct OverflowInfo
        {
            SourceLocation location;
            TypeDescriptor* type;
        };

        struct UnreachableInfo
        {
            SourceLocation location;
        };

        struct OutOfBoundsInfo
        {
            SourceLocation location;
            TypeDescriptor* array_type;
            TypeDescriptor* index_type;
        };

        struct InvalidValueInfo
        {
            SourceLocation location;
            TypeDescriptor* type;
        };

        struct ShiftOutOfBoundsInfo
        {
            SourceLocation location;
            TypeDescriptor* lhs_type;
            TypeDescriptor* rhs_type;
        };

        struct PointerOverflowInfo
        {
            SourceLocation location;
        };

        struct NonnullArgInfo
        {
            SourceLocation location;
            SourceLocation attr_location;
        };
    }
}