Why use xtensa-clang for clang-tidy in IDF Clang Tidy?

andyn_ff
Posts: 18
Joined: Mon Jun 10, 2019 4:34 pm

Why use xtensa-clang for clang-tidy in IDF Clang Tidy?

Postby andyn_ff » Wed Jul 05, 2023 9:29 am

Hi,

I am starting to use static analysis in my codebase for ESP32 project, and I read the guide in the IDF docs for using `idf.py clang-check`. This depends on installing the xtensa-clang binaries, but I wonder why it is recommended to use xtensa-clang instead of the native clang-tidy? I could install clang-tidy for my environment with `apt install clang-tidy`.

Because clang-tidy is analysing C code and not compiling it, can anyone explain why the clang-tidy from xtensa-clang is a better choice than the native clang-tidy?

Thank you

ESP_igrr
Posts: 2072
Joined: Tue Dec 01, 2015 8:37 am

Re: Why use xtensa-clang for clang-tidy in IDF Clang Tidy?

Postby ESP_igrr » Wed Jul 05, 2023 11:00 pm

This is necessary in order for clang-tidy to be able to resolve the system header files (i.e. newlib C library) , preprocessor macros, sizes of built-in types, etc. correctly.

Probably it won't be necessary any longer if https://github.com/llvm/llvm-project/issues/53468 gets implemented — that feature would allow clang-tidy to call GCC to resolve the headers; I don't know if the sizes of the built-in types will be determined correctly with that approach, though.

Who is online

Users browsing this forum: Baidu [Spider] and 411 guests