Repository: godotengine/godot
File: core/typedefs.h (C/C++)

Code before:
#endif

#if __has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
#define ASAN_ENABLED
#include <sanitizer/asan_interface.h>
#endif

#if __has_feature(thread_sanitizer) || defined(__SANITIZE_THREAD__)
#define TSAN_ENABLED
#include <sanitizer/tsan_interface.h>
#endif

#if __has_feature(memory_sanitizer) || defined(__SANITIZE_MEMORY__)
#define MSAN_ENABLED
#include <sanitizer/msan_interface.h>
#endif

#if __has_feature(leak_sanitizer) || defined(__SANITIZE_LEAKS__)
#define LSAN_ENABLED
#include <sanitizer/lsan_interface.h>
#endif

#if __has_feature(undefined_behavior_sanitizer)
#define UBSAN_ENABLED
#include <sanitizer/ubsan_interface.h>
#endif

#if defined(ASAN_ENABLED) || defined(TSAN_ENABLED) || defined(MSAN_ENABLED) || defined(LSAN_ENABLED) || defined(UBSAN_ENABLED)
#define SANITIZERS_ENABLED
#endif

// IWYU pragma: end_exports

// Turn argument to string constant:
// https://gcc.gnu.org/onlinedocs/cpp/Stringizing.html#Stringizing
#ifndef _STR
#define _STR(m_x) #m_x
#define _MKSTR(m_x) _STR(m_x)
#endif

// Should always inline no matter what.
#ifndef _ALWAYS_INLINE_
#if defined(__GNUC__)
#define _ALWAYS_INLINE_ __attribute__((always_inline)) inline
#elif defined(_MSC_VER)
#define _ALWAYS_INLINE_ __forceinline
#else
#define _ALWAYS_INLINE_ inline
#endif
#endif


Review comment (security):
It's not too big a deal as it only impacts sanitizers-enabled builds, but isn't this going contrary to the aim to reduce transitive includes in the codebase?

This will force include these interfaces in pretty much every single Godot file, while it seems before that it was only needed in `rid_owner.h` and a couple of tests.

Code after:

#if defined(__has_feature)
#define GD_HAS_FEATURE(m_feature) __has_feature(m_feature)
#else
#define GD_HAS_FEATURE(m_feature) 0
#endif

#if (GD_HAS_FEATURE(address_sanitizer) || defined(__SANITIZE_ADDRESS__)) && !defined(ASAN_ENABLED)
#error Address sanitizer was enabled without defining `ASAN_ENABLED`
#endif

#if (GD_HAS_FEATURE(leak_sanitizer) || defined(__SANITIZE_LEAKS__)) && !defined(LSAN_ENABLED)
#error Leak sanitizer was enabled without defining `LSAN_ENABLED`
#endif

#if (GD_HAS_FEATURE(memory_sanitizer) || defined(__SANITIZE_MEMORY__)) && !defined(MSAN_ENABLED)
#error Memory sanitizer was enabled without defining `MSAN_ENABLED`
#endif

#if (GD_HAS_FEATURE(thread_sanitizer) || defined(__SANITIZE_THREAD__)) && !defined(TSAN_ENABLED)
#error Thread sanitizer was enabled without defining `TSAN_ENABLED`
#endif

#if (GD_HAS_FEATURE(undefined_behavior_sanitizer) || defined(__UNDEFINED_SANITIZER__)) && !defined(UBSAN_ENABLED)
#error Undefined behavior sanitizer was enabled without defining `UBSAN_ENABLED`
#endif

// Turn argument to string constant:
// https://gcc.gnu.org/onlinedocs/cpp/Stringizing.html#Stringizing
#ifndef _STR
#define _STR(m_x) #m_x
#define _MKSTR(m_x) _STR(m_x)
#endif

// Should always inline no matter what.
#ifndef _ALWAYS_INLINE_
#if defined(__GNUC__)
#define _ALWAYS_INLINE_ __attribute__((always_inline)) inline
#elif defined(_MSC_VER)
#define _ALWAYS_INLINE_ __forceinline
#else
#define _ALWAYS_INLINE_ inline
#endif
#endif

// Should always inline, except in dev builds because it makes debugging harder,
// or `size_enabled` builds where inlining is actively avoided.
#ifndef _FORCE_INLINE_
#if defined(DEV_ENABLED) || defined(SIZE_EXTRA)
#define _FORCE_INLINE_ inline
#else