From 8e782602de7c327663c6f80d208e87b9561823c5 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Tue, 11 Jun 2024 11:29:44 -0400 Subject: [PATCH] wikiheaders: Fixes and cleanups to fix SDL_ReportAssertion's wiki page. --- build-scripts/wikiheaders.pl | 12 +++++++++--- include/SDL3/SDL_assert.h | 12 +----------- include/SDL3/SDL_begin_code.h | 10 ++++++++++ 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/build-scripts/wikiheaders.pl b/build-scripts/wikiheaders.pl index a06c02e167..4291ba1453 100755 --- a/build-scripts/wikiheaders.pl +++ b/build-scripts/wikiheaders.pl @@ -872,7 +872,7 @@ while (my $d = readdir(DH)) { } $decl =~ s/\s*\)\s*(\{.*|)\s*\Z/);/; } else { - if (not $decl =~ /\)\s*;/) { + if (not $decl =~ /;/) { while () { chomp; $lineno++; @@ -880,14 +880,19 @@ while (my $d = readdir(DH)) { s/\A\s+//; s/\s+\Z//; $decl .= " $_"; - last if /\)\s*;/; + last if /;/; } } $decl =~ s/\s+\);\Z/);/; + $decl =~ s/\s+;\Z/;/; } $decl =~ s/\s+\Z//; + $decl =~ s/\s*SDL_W?PRINTF_VARARG_FUNCV?\s*\(\d+\)\s*//; # don't want this metadata as part of the documentation. + $decl =~ s/SDL_PRINTF_FORMAT_STRING\s*//; # don't want this metadata as part of the documentation. + $decl =~ s/\s*SDL_ANALYZER_NORETURN\s*//; # don't want this metadata as part of the documentation. + if (!$is_forced_inline && $decl =~ /\A\s*extern\s+(SDL_DEPRECATED\s+|)(SDLMAIN_|SDL_)DECLSPEC\s+(const\s+|)(unsigned\s+|)(.*?)\s*(\*?)\s*SDLCALL\s+(.*?)\s*\((.*?)\);/) { $sym = $7; } elsif ($is_forced_inline && $decl =~ /\A\s*SDL_FORCE_INLINE\s+(SDL_DEPRECATED\s+|)(const\s+|)(unsigned\s+|)(.*?)([\*\s]+)(.*?)\s*\((.*?)\);/) { @@ -919,8 +924,9 @@ while (my $d = readdir(DH)) { } } - $decl =~ s/\s*SDL_W?PRINTF_VARARG_FUNCV?\s*\(\d+\)\s*;\Z/;/; # don't want this metadata as part of the documentation. + $decl =~ s/\s*SDL_W?PRINTF_VARARG_FUNCV?\s*\(\d+\)\s*//; # don't want this metadata as part of the documentation. $decl =~ s/SDL_PRINTF_FORMAT_STRING\s*//; # don't want this metadata as part of the documentation. + $decl =~ s/\s*SDL_ANALYZER_NORETURN\s*//; # don't want this metadata as part of the documentation. # !!! FIXME: code duplication with typedef processing, below. # We assume any `#define`s directly after the function are related to it: probably bitflags for an integer typedef. diff --git a/include/SDL3/SDL_assert.h b/include/SDL3/SDL_assert.h index e88fd1e858..caf5eac5af 100644 --- a/include/SDL3/SDL_assert.h +++ b/include/SDL3/SDL_assert.h @@ -244,17 +244,7 @@ typedef struct SDL_AssertData */ extern SDL_DECLSPEC SDL_AssertState SDLCALL SDL_ReportAssertion(SDL_AssertData *data, const char *func, - const char *file, int line) -#ifdef __clang__ -#if __has_feature(attribute_analyzer_noreturn) - __attribute__((analyzer_noreturn)) -#endif -#endif -; -/* Previous 'analyzer_noreturn' attribute tells Clang's static analysis that we're a custom assert function, - and that the analyzer should assume the condition was always true past this - SDL_assert test. */ - + const char *file, int line) SDL_ANALYZER_NORETURN; /* Define the trigger breakpoint call used in asserts */ #ifndef SDL_AssertBreakpoint diff --git a/include/SDL3/SDL_begin_code.h b/include/SDL3/SDL_begin_code.h index aea2ef1d47..e577029073 100644 --- a/include/SDL3/SDL_begin_code.h +++ b/include/SDL3/SDL_begin_code.h @@ -139,6 +139,16 @@ #endif #endif /* SDL_NORETURN not defined */ +#ifdef __clang__ +#if __has_feature(attribute_analyzer_noreturn) +#define SDL_ANALYZER_NORETURN __attribute__((analyzer_noreturn)) +#endif +#endif + +#ifndef SDL_ANALYZER_NORETURN +#define SDL_ANALYZER_NORETURN +#endif + /* Apparently this is needed by several Windows compilers */ #ifndef __MACH__ #ifndef NULL