feat(build): add COMPILER_STATIC_ANALYZER option

This commit is contained in:
Alexey Lapshin
2024-06-06 15:23:02 +07:00
committed by BOT
parent e1b9985bd0
commit ed6e497c6f
46 changed files with 265 additions and 41 deletions

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2016-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2016-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -11,7 +11,7 @@
/*
* The likely and unlikely macro pairs:
* These macros are useful to place when application
* knows the majority ocurrence of a decision paths,
* knows the majority occurrence of a decision paths,
* placing one of these macros can hint the compiler
* to reorder instructions producing more optimized
* code.
@@ -52,3 +52,31 @@
#define ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_STR(member, value) .member = value,
#define ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(member)
#endif
#define __COMPILER_PRAGMA__(string) _Pragma(#string)
#define _COMPILER_PRAGMA_(string) __COMPILER_PRAGMA__(string)
#if __clang__
#define ESP_COMPILER_DIAGNOSTIC_PUSH_IGNORE(warning) \
__COMPILER_PRAGMA__(clang diagnostic push) \
__COMPILER_PRAGMA__(clang diagnostic ignored "-Wunknown-warning-option") \
__COMPILER_PRAGMA__(clang diagnostic ignored warning)
#define ESP_COMPILER_DIAGNOSTIC_POP(warning) \
__COMPILER_PRAGMA__(clang diagnostic pop)
#elif __GNUC__
#define ESP_COMPILER_DIAGNOSTIC_PUSH_IGNORE(warning) \
__COMPILER_PRAGMA__(GCC diagnostic push) \
__COMPILER_PRAGMA__(GCC diagnostic ignored "-Wpragmas") \
__COMPILER_PRAGMA__(GCC diagnostic ignored warning)
#define ESP_COMPILER_DIAGNOSTIC_POP(warning) \
__COMPILER_PRAGMA__(GCC diagnostic pop)
#else
#define ESP_COMPILER_DIAGNOSTIC_PUSH_IGNORE(warning)
#define ESP_COMPILER_DIAGNOSTIC_POP(warning)
#endif
#if __clang_analyzer__ || CONFIG_COMPILER_STATIC_ANALYZER
#define ESP_STATIC_ANALYZER_CHECK(_expr_, _ret_) do { if ((_expr_)) { return (_ret_); } } while(0)
#else
#define ESP_STATIC_ANALYZER_CHECK(_expr_, _ret_)
#endif