From c41440e3fb27f6630063c2b12ea4734a025f9b32 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Fri, 25 Oct 2024 21:02:55 -0600 Subject: [PATCH] Small clangd fixes --- include/__ppc_eabi_linker.h | 94 ++++++++++++++++++++----------------- include/static_assert.hpp | 7 +-- tools/decompctx.py | 2 +- 3 files changed, 55 insertions(+), 48 deletions(-) diff --git a/include/__ppc_eabi_linker.h b/include/__ppc_eabi_linker.h index 98ba18f6..2fddd9c9 100644 --- a/include/__ppc_eabi_linker.h +++ b/include/__ppc_eabi_linker.h @@ -1,17 +1,23 @@ #ifndef __PPC_EABI_LINKER #define __PPC_EABI_LINKER -__declspec(section ".init") extern char _stack_addr[]; -__declspec(section ".init") extern char _stack_end[]; -__declspec(section ".init") extern char _heap_addr[]; -__declspec(section ".init") extern char _heap_end[]; -__declspec(section ".init") extern const char _fextabindex_rom[]; -__declspec(section ".init") extern char _fextabindex[]; -__declspec(section ".init") extern char _eextabindex[]; +#ifdef __MWERKS__ +#define DECL_SECTION(name) __declspec(section name) +#else +#define DECL_SECTION(name) +#endif -__declspec(section ".init") extern char _SDA_BASE_[]; +DECL_SECTION(".init") extern char _stack_addr[]; +DECL_SECTION(".init") extern char _stack_end[]; +DECL_SECTION(".init") extern char _heap_addr[]; +DECL_SECTION(".init") extern char _heap_end[]; +DECL_SECTION(".init") extern const char _fextabindex_rom[]; +DECL_SECTION(".init") extern char _fextabindex[]; +DECL_SECTION(".init") extern char _eextabindex[]; -__declspec(section ".init") extern char _SDA2_BASE_[]; +DECL_SECTION(".init") extern char _SDA_BASE_[]; + +DECL_SECTION(".init") extern char _SDA2_BASE_[]; typedef struct __rom_copy_info { char* rom; @@ -19,14 +25,14 @@ typedef struct __rom_copy_info { unsigned int size; } __rom_copy_info; -__declspec(section ".init") extern __rom_copy_info _rom_copy_info[]; +DECL_SECTION(".init") extern __rom_copy_info _rom_copy_info[]; typedef struct __bss_init_info { char* addr; unsigned int size; } __bss_init_info; -__declspec(section ".init") extern __bss_init_info _bss_init_info[]; +DECL_SECTION(".init") extern __bss_init_info _bss_init_info[]; typedef struct __eti_init_info { void* eti_start; @@ -35,39 +41,39 @@ typedef struct __eti_init_info { unsigned long code_size; } __eti_init_info; -__declspec(section ".init") extern __eti_init_info _eti_init_info[]; -__declspec(section ".init") extern const char _f_init_rom[]; -__declspec(section ".init") extern char _f_init[]; -__declspec(section ".init") extern char _e_init[]; -__declspec(section ".init") extern const char _f_text_rom[]; -__declspec(section ".init") extern char _f_text[]; -__declspec(section ".init") extern char _e_text[]; -__declspec(section ".init") extern const char _f_rodata_rom[]; -__declspec(section ".init") extern char _f_rodata[]; -__declspec(section ".init") extern char _e_rodata[]; -__declspec(section ".init") extern const char _fextab_rom[]; -__declspec(section ".init") extern char _fextab[]; -__declspec(section ".init") extern char _eextab[]; -__declspec(section ".init") extern const char _f_data_rom[]; -__declspec(section ".init") extern char _f_data[]; -__declspec(section ".init") extern char _e_data[]; -__declspec(section ".init") extern char _f_bss[]; -__declspec(section ".init") extern char _e_bss[]; -__declspec(section ".init") extern const char _f_sdata_rom[]; -__declspec(section ".init") extern char _f_sdata[]; -__declspec(section ".init") extern char _e_sdata[]; -__declspec(section ".init") extern char _f_sbss[]; -__declspec(section ".init") extern char _e_sbss[]; -__declspec(section ".init") extern const char _f_sdata2_rom[]; -__declspec(section ".init") extern char _f_sdata2[]; -__declspec(section ".init") extern char _e_sdata2[]; -__declspec(section ".init") extern char _f_sbss2[]; -__declspec(section ".init") extern char _e_sbss2[]; -__declspec(section ".init") extern const char _f_PPC_EMB_sdata0_rom[]; -__declspec(section ".init") extern char _f_PPC_EMB_sdata0[]; -__declspec(section ".init") extern char _e_PPC_EMB_sdata0[]; -__declspec(section ".init") extern char _f_PPC_EMB_sbss0[]; -__declspec(section ".init") extern char _e_PPC_EMB_sbss0[]; +DECL_SECTION(".init") extern __eti_init_info _eti_init_info[]; +DECL_SECTION(".init") extern const char _f_init_rom[]; +DECL_SECTION(".init") extern char _f_init[]; +DECL_SECTION(".init") extern char _e_init[]; +DECL_SECTION(".init") extern const char _f_text_rom[]; +DECL_SECTION(".init") extern char _f_text[]; +DECL_SECTION(".init") extern char _e_text[]; +DECL_SECTION(".init") extern const char _f_rodata_rom[]; +DECL_SECTION(".init") extern char _f_rodata[]; +DECL_SECTION(".init") extern char _e_rodata[]; +DECL_SECTION(".init") extern const char _fextab_rom[]; +DECL_SECTION(".init") extern char _fextab[]; +DECL_SECTION(".init") extern char _eextab[]; +DECL_SECTION(".init") extern const char _f_data_rom[]; +DECL_SECTION(".init") extern char _f_data[]; +DECL_SECTION(".init") extern char _e_data[]; +DECL_SECTION(".init") extern char _f_bss[]; +DECL_SECTION(".init") extern char _e_bss[]; +DECL_SECTION(".init") extern const char _f_sdata_rom[]; +DECL_SECTION(".init") extern char _f_sdata[]; +DECL_SECTION(".init") extern char _e_sdata[]; +DECL_SECTION(".init") extern char _f_sbss[]; +DECL_SECTION(".init") extern char _e_sbss[]; +DECL_SECTION(".init") extern const char _f_sdata2_rom[]; +DECL_SECTION(".init") extern char _f_sdata2[]; +DECL_SECTION(".init") extern char _e_sdata2[]; +DECL_SECTION(".init") extern char _f_sbss2[]; +DECL_SECTION(".init") extern char _e_sbss2[]; +DECL_SECTION(".init") extern const char _f_PPC_EMB_sdata0_rom[]; +DECL_SECTION(".init") extern char _f_PPC_EMB_sdata0[]; +DECL_SECTION(".init") extern char _e_PPC_EMB_sdata0[]; +DECL_SECTION(".init") extern char _f_PPC_EMB_sbss0[]; +DECL_SECTION(".init") extern char _e_PPC_EMB_sbss0[]; #endif // __PPC_EABI_LINKER diff --git a/include/static_assert.hpp b/include/static_assert.hpp index a087130b..4070c6ef 100644 --- a/include/static_assert.hpp +++ b/include/static_assert.hpp @@ -23,11 +23,12 @@ typedef unsigned long size_t; #define offsetof(type, member) ((size_t) & (((type*)0)->member)) #endif #define CHECK_SIZEOF(cls, size) extern int cls##_check[check_sizeof< cls, size >::value]; -#define NESTED_CHECK_SIZEOF(parent, cls, size) extern int cls##_check[check_sizeof< parent::cls, size >::value]; +#define NESTED_CHECK_SIZEOF(parent, cls, size) \ + extern int cls##_check[check_sizeof< parent::cls, size >::value]; #define CHECK_OFFSETOF(cls, member, offset) \ extern int cls##_check_offset##[_n_is_equal< offsetof(cls, member), offset >::value]; -#elif defined(__clang__) && defined(__powerpc__) // Enable for clangd -#pragma clang diagnostic ignored "-Wc11-extensions" // Allow _Static_assert +#elif defined(__clang__) && defined(__powerpc__) // Enable for clangd +#pragma clang diagnostic ignored "-Wc11-extensions" // Allow _Static_assert #pragma clang diagnostic ignored "-Wc++17-extensions" // Allow _Static_assert without message #define CHECK_SIZEOF(cls, size) _Static_assert(sizeof(cls) == size); #define NESTED_CHECK_SIZEOF(parent, cls, size) _Static_assert(sizeof(parent::cls) == size); diff --git a/tools/decompctx.py b/tools/decompctx.py index ad857f63..84780bc5 100755 --- a/tools/decompctx.py +++ b/tools/decompctx.py @@ -24,7 +24,7 @@ include_dirs = [ os.path.join(root_dir, "extern/musyx/include") ] -include_pattern = re.compile(r'^#\s*include\s*[<"](.+?)[>"]$') +include_pattern = re.compile(r'^#\s*include\s*[<"](.+?)[>"]') guard_pattern = re.compile(r"^#\s*ifndef\s+(.*)$") defines = set()