2021-02-05 18:44:26 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
|
|
|
|
*
|
2021-04-22 08:24:48 +00:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2021-02-05 18:44:26 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AK/Types.h>
|
|
|
|
|
2021-05-24 01:33:40 +00:00
|
|
|
namespace AK::UBSanitizer {
|
2021-02-05 18:44:26 +00:00
|
|
|
|
2021-03-04 21:07:23 +00:00
|
|
|
extern bool g_ubsan_is_deadly;
|
|
|
|
|
2021-02-11 19:58:01 +00:00
|
|
|
typedef void* ValueHandle;
|
|
|
|
|
2021-02-05 18:44:26 +00:00
|
|
|
class SourceLocation {
|
|
|
|
public:
|
|
|
|
const char* filename() const { return m_filename; }
|
|
|
|
u32 line() const { return m_line; }
|
|
|
|
u32 column() const { return m_column; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
const char* m_filename;
|
|
|
|
u32 m_line;
|
|
|
|
u32 m_column;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum TypeKind : u16 {
|
|
|
|
Integer = 0,
|
|
|
|
Float = 1,
|
|
|
|
Unknown = 0xffff,
|
|
|
|
};
|
|
|
|
|
|
|
|
class TypeDescriptor {
|
|
|
|
public:
|
|
|
|
const char* name() const { return m_name; }
|
|
|
|
TypeKind kind() const { return (TypeKind)m_kind; }
|
|
|
|
bool is_integer() const { return kind() == TypeKind::Integer; }
|
|
|
|
bool is_signed() const { return m_info & 1; }
|
|
|
|
bool is_unsigned() const { return !is_signed(); }
|
|
|
|
size_t bit_width() const { return 1 << (m_info >> 1); }
|
|
|
|
|
|
|
|
private:
|
|
|
|
u16 m_kind;
|
|
|
|
u16 m_info;
|
|
|
|
char m_name[1];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct InvalidValueData {
|
|
|
|
SourceLocation location;
|
|
|
|
const TypeDescriptor& type;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct NonnullArgData {
|
|
|
|
SourceLocation location;
|
|
|
|
SourceLocation attribute_location;
|
|
|
|
int argument_index;
|
|
|
|
};
|
|
|
|
|
2021-02-07 07:24:49 +00:00
|
|
|
struct NonnullReturnData {
|
|
|
|
SourceLocation attribute_location;
|
|
|
|
};
|
|
|
|
|
2021-02-05 19:03:07 +00:00
|
|
|
struct OverflowData {
|
|
|
|
SourceLocation location;
|
|
|
|
const TypeDescriptor& type;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct VLABoundData {
|
|
|
|
SourceLocation location;
|
|
|
|
const TypeDescriptor& type;
|
|
|
|
};
|
|
|
|
|
2021-02-06 15:08:30 +00:00
|
|
|
struct ShiftOutOfBoundsData {
|
|
|
|
SourceLocation location;
|
|
|
|
const TypeDescriptor& lhs_type;
|
|
|
|
const TypeDescriptor& rhs_type;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct OutOfBoundsData {
|
|
|
|
SourceLocation location;
|
|
|
|
const TypeDescriptor& array_type;
|
|
|
|
const TypeDescriptor& index_type;
|
|
|
|
};
|
|
|
|
|
2021-02-06 16:34:44 +00:00
|
|
|
struct TypeMismatchData {
|
|
|
|
SourceLocation location;
|
|
|
|
const TypeDescriptor& type;
|
|
|
|
u8 log_alignment;
|
|
|
|
u8 type_check_kind;
|
|
|
|
};
|
|
|
|
|
2021-02-11 19:58:01 +00:00
|
|
|
struct AlignmentAssumptionData {
|
|
|
|
SourceLocation location;
|
|
|
|
SourceLocation assumption_location;
|
|
|
|
const TypeDescriptor& type;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct UnreachableData {
|
|
|
|
SourceLocation location;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ImplicitConversionData {
|
|
|
|
SourceLocation location;
|
|
|
|
const TypeDescriptor& from_type;
|
|
|
|
const TypeDescriptor& to_type;
|
|
|
|
/* ImplicitConversionCheckKind */ unsigned char kind;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct InvalidBuiltinData {
|
|
|
|
SourceLocation location;
|
|
|
|
unsigned char kind;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct PointerOverflowData {
|
|
|
|
SourceLocation location;
|
|
|
|
};
|
|
|
|
|
2021-02-05 18:44:26 +00:00
|
|
|
}
|