mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-05-13 10:51:35 +00:00
Add DAWN_UNUSED_FUNC to ignore unused functions in generated code
BUG=dawn:13 Change-Id: I7a224503d0a33ef148e63b8327a6a53df1b3868a Reviewed-on: https://dawn-review.googlesource.com/1520 Commit-Queue: Kai Ninomiya <kainino@chromium.org> Reviewed-by: Stephen White <senorblanco@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
parent
a60799f5e1
commit
03e1813fd2
@ -135,6 +135,9 @@
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
// GetExtraRequiredSize isn't used for structures that are value members of other structures
|
||||||
|
// because we assume they cannot contain pointers themselves.
|
||||||
|
DAWN_UNUSED_FUNC({{name}}GetExtraRequiredSize);
|
||||||
|
|
||||||
//* Serializes `record` into `transfer`, using `buffer` to get more space for pointed-to data
|
//* Serializes `record` into `transfer`, using `buffer` to get more space for pointed-to data
|
||||||
//* and `provider` to serialize objects.
|
//* and `provider` to serialize objects.
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
// - DAWN_(UN)?LIKELY(EXPR): Where available, hints the compiler that the expression will be true
|
// - DAWN_(UN)?LIKELY(EXPR): Where available, hints the compiler that the expression will be true
|
||||||
// (resp. false) to help it generate code that leads to better branch prediction.
|
// (resp. false) to help it generate code that leads to better branch prediction.
|
||||||
// - DAWN_UNUSED(EXPR): Prevents unused variable/expression warnings on EXPR.
|
// - DAWN_UNUSED(EXPR): Prevents unused variable/expression warnings on EXPR.
|
||||||
|
// - DAWN_UNUSED_FUNC(FUNC): Prevents unused function warnings on FUNC.
|
||||||
|
|
||||||
// Clang and GCC, check for __clang__ too to catch clang-cl masquarading as MSVC
|
// Clang and GCC, check for __clang__ too to catch clang-cl masquarading as MSVC
|
||||||
#if defined(__GNUC__) || defined(__clang__)
|
#if defined(__GNUC__) || defined(__clang__)
|
||||||
@ -75,6 +76,8 @@ extern void __cdecl __debugbreak(void);
|
|||||||
|
|
||||||
// It seems that (void) EXPR works on all compilers to silence the unused variable warning.
|
// It seems that (void) EXPR works on all compilers to silence the unused variable warning.
|
||||||
#define DAWN_UNUSED(EXPR) (void)EXPR
|
#define DAWN_UNUSED(EXPR) (void)EXPR
|
||||||
|
// Likewise using static asserting on sizeof(&FUNC) seems to make it tagged as used
|
||||||
|
#define DAWN_UNUSED_FUNC(FUNC) static_assert(sizeof(&FUNC) == sizeof(void (*)()), "");
|
||||||
|
|
||||||
// Add noop replacements for macros for features that aren't supported by the compiler.
|
// Add noop replacements for macros for features that aren't supported by the compiler.
|
||||||
#if !defined(DAWN_LIKELY)
|
#if !defined(DAWN_LIKELY)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user