assemblycmakegithub-actionsstm32clang-tidy

Clang-tidy tries to analyze an STM32 assembly file located in compile_commands.json


I have an STM32 project which is compiled using CMake and generates a compile_commands.json STM32CubeMX generates an assembly file (i.e. startup_stm32f103xb.s) and adds it to the compilation database.

Whenever I run use-clang-tidy.py, it attempts to analyse that file and returns an error:

D:\git\leany\Core\startup_stm32f103xb.s:28:3: error: expected identifier or '(' [clang-diagnostic-error]
   28 |   .syntax unified
      |   ^

I'm not surprised by the error as clang tries to compile an ASM file as C, but I'm wondering if it would be possible to just ignore this file or any asm file altogether. Also, I would very much like to keep clang-tidy as a part of my CI/CD procedures, as I want to keep my own code (located in Components/) as clean as possible. Also, I cannot touch the files generated by STM32CubeMX, neither can I touch the CMake files it creates.

Here is the codebase : Github

I've tried to create a .clang-tidy file at the root of the project with the mention 'Checks: "-*"', but it just cancels all checks altogether, including the ones located in Components/

I've also tried adding HeaderFileExtensions and ImplementationFileExtensions sections in it to consider only *.h and *.c files, but this doesn't change anything


Solution

  • I've found the solution on the LLVM forum ! From the help, I did not understand that [files ...] expected a regex. I've just added files ".*(?<!\.s)$" at the end of the command to filter out the assembly file