Search code examples
carmclangstatic-analysisclang-static-analyzer

clang-check using arm as a target


I've been trying to use clang-check for static code analysis. My makefile generates a compile_commands.json and so far clang-check works well for x86 platforms, however I'd like to use it for arm platforms too. One of the entries looks like this:

{
     "directory": "/path/to/myproject/src",
     "command": "arm-none-eabi-gcc -DBOARD_VERSION=3 -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -std=gnu11 -Wall -Werror -Os -DVERSION_MAJOR=2 -DVERSION_MINOR=4 -DVERSION_PATCH=2 -I/path/to/myproject/src -I/usr/arm-none-eabi/include -MMD -MP -MF/path/to/myproject/.build/debug/src/main.d -MT//path/to/myproject/.build/debug/src/main.o -c -o /path/to/myproject/.build/debug/src/main.o /path/to/myproject/src/main.c",
     "file": "/path/to/myproject/src/main.c"
},

For arm while it gives me some generic errors, it also gives me errors relative to x86 (like interruption syntax):

error: x86-64 'interrupt' attribute only applies to functions that have only a pointer parameter optionally followed by an integer parameter

The clang-check binary I use is part of fedora distribution, but I'm wondering if there is a way to get it working (well) for arm too ?

Maybe some options (I couldn't find any), or maybe I need to compile a specific clang-check or maybe it just cannot work for arm in that case there may be alternatives.


Solution

  • Nevermind I found that using:

    scan-build --use-cc=$(CC) --analyzer-target=arm -o .build make clean all
    

    was good alternative using clang analyzer too