mirror of
https://github.com/esphome/esphome.git
synced 2026-09-16 09:38:42 +00:00
Fix clang-tidy and test for optimize(O2) attribute
This commit is contained in:
+478
-1022
File diff suppressed because it is too large
Load Diff
@@ -65,7 +65,8 @@ static StaticTask_t loop_task_tcb; // NOLINT(cppcoreguidelines-avoid-non-
|
||||
static StackType_t
|
||||
loop_task_stack[ESPHOME_LOOP_TASK_STACK_SIZE]; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
|
||||
void __attribute__((optimize("O2"))) loop_task(void *pv_params) {
|
||||
void __attribute__((optimize("O2"))) // NOLINT(clang-diagnostic-unknown-attributes)
|
||||
loop_task(void *pv_params) {
|
||||
setup();
|
||||
while (true) {
|
||||
App.loop();
|
||||
|
||||
@@ -77,7 +77,8 @@ uint32_t arch_get_cpu_freq_hz() { return 1000000000U; }
|
||||
|
||||
void setup();
|
||||
void loop();
|
||||
int __attribute__((optimize("O2"))) main() {
|
||||
int __attribute__((optimize("O2"))) // NOLINT(clang-diagnostic-unknown-attributes)
|
||||
main() {
|
||||
// Install signal handlers for graceful shutdown (flushes preferences to disk)
|
||||
std::signal(SIGINT, signal_handler);
|
||||
std::signal(SIGTERM, signal_handler);
|
||||
|
||||
@@ -95,7 +95,8 @@ void get_mac_address_raw(uint8_t *mac) { // NOLINT(readability-non-const-parame
|
||||
void setup();
|
||||
void loop();
|
||||
|
||||
int __attribute__((optimize("O2"))) main() {
|
||||
int __attribute__((optimize("O2"))) // NOLINT(clang-diagnostic-unknown-attributes)
|
||||
main() {
|
||||
setup();
|
||||
while (true) {
|
||||
loop();
|
||||
|
||||
@@ -837,6 +837,7 @@ inline void ESPHOME_ALWAYS_INLINE Application::before_loop_tasks_(uint32_t loop_
|
||||
this->in_loop_ = true;
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(clang-diagnostic-unknown-attributes)
|
||||
inline void ESPHOME_ALWAYS_INLINE __attribute__((optimize("O2"))) Application::loop() {
|
||||
uint8_t new_app_state = 0;
|
||||
|
||||
|
||||
@@ -2683,7 +2683,7 @@ def build_message_type(
|
||||
# When set, __attribute__((optimize("O2"))) is added to the definitions
|
||||
# so GCC inlines the small ProtoEncode helpers even under -Os.
|
||||
is_speed_optimized = get_opt(desc, pb.speed_optimized, False)
|
||||
speed_attr = '__attribute__((optimize("O2"))) ' if is_speed_optimized else ""
|
||||
speed_attr = '__attribute__((optimize("O2"))) // NOLINT(clang-diagnostic-unknown-attributes)\n' if is_speed_optimized else ""
|
||||
|
||||
# Only generate encode method if this message needs encoding and has fields
|
||||
if needs_encode and encode and not is_inline_only:
|
||||
|
||||
@@ -782,7 +782,8 @@ def test_write_cpp_creates_new_file(
|
||||
assert CPP_AUTO_GENERATE_END in written_content
|
||||
assert test_code in written_content
|
||||
assert "void setup()" in written_content
|
||||
assert "void loop()" in written_content
|
||||
assert 'optimize("O2")' in written_content
|
||||
assert "loop()" in written_content
|
||||
assert "App.setup();" in written_content
|
||||
assert "App.loop();" in written_content
|
||||
|
||||
|
||||
Reference in New Issue
Block a user