Better Firmware with LLVM/Clang | Interrupt

Great article! The majority of my company’s firmware (with the exception of PIC-based systems) is developed & shipped with clang; when we switched 5-6 years ago the primary motivation was the superior quality of its diagnostic messages compared to GCC. I understand GCC’s output has improved drastically since then, but we haven’t had any practical reasons to reconsider that decision. We’re currently building with c++17 and I’m hoping to get clang 10 up and running soon so we can take advantage of some c++20 features.

I think clang-tidy also belongs in this conversation: it includes the static analyzer checks performed by scan-build, and additionally can perform a whole raft of checks against various coding & style guidelines including the C++ core guidelines. Running it is a little bit more involved than scan-build as it works best with a compile_commands database and introducing it to an existing codebase can be a big task, but it’s got some great checks: https://releases.llvm.org/10.0.0/tools/clang/tools/extra/docs/clang-tidy/checks/list.html

3 Likes