Static Analyzer

[中文]

A static analyzer is a tool that checks source code for errors and vulnerabilities without running it. It helps developers find issues early, improving code quality.

GNU Static Analyzer

The GNU Static Analyzer is distributed with GCC (refer to GCC documentation). It can be enabled with CONFIG_COMPILER_STATIC_ANALYZER to perform code checks during application builds.

Suppressing Warnings

GNU Static Analyzer is still under development and may give some false-positive warnings. Here is an example of how to suppress unwanted warnings using IDF:

#include "esp_compiler.h"
/* .... */
  ESP_COMPILER_DIAGNOSTIC_PUSH_IGNORE("-Wanalyzer-null-dereference")
  *((volatile int *) 0) = 0;
  ESP_COMPILER_DIAGNOSTIC_POP("-Wanalyzer-null-dereference")
/* .... */

Clang Static Analyzer

See IDF Clang-Tidy


此文档对您有帮助吗?