yes it is possible by cfg file updates.
I am curious, why do you encounter builtin_memset? I assume you include system headers and your code is corrupted by macros?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
We have an embedded STM32 project (AC6 toolchain). We are fixed on the compiler version and the optimisation lvl. Using gcc builtins gives us a performance boost because the compiler replaces (if possible) the function call with just some ASM instructions. We use the whole bandwith of builtin functions, including stuff like __builtin_ tolower, strlen, memcmp, memcpy etc.
Last edit: Johann Peter 2018-10-29
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
does cppcheck support builtin functions?
Under gcc I tried:
The builtin memset does not show as an error.
If this is not a bug but a feature, can I implement the same checks for builtin functions via library .cfg files?
Best regards,
Johann
Last edit: Johann Peter 2018-10-26
Are you referring to GNU builtin functions?
If yes, we could extend our gnu.cfg file about these definitions. The corresponding file is available here: https://github.com/danmar/cppcheck/blob/master/cfg/gnu.cfg
Experimental support for
__builtin_memset
has been added with https://github.com/danmar/cppcheck/commit/b998dcb5aaf76b0eba74fa2ae3c4fa081c75ca68Scanning following example
gives now
(error) Buffer is accessed out of bounds: buf
yes it is possible by cfg file updates.
I am curious, why do you encounter builtin_memset? I assume you include system headers and your code is corrupted by macros?
We have an embedded STM32 project (AC6 toolchain). We are fixed on the compiler version and the optimisation lvl. Using gcc builtins gives us a performance boost because the compiler replaces (if possible) the function call with just some ASM instructions. We use the whole bandwith of builtin functions, including stuff like __builtin_ tolower, strlen, memcmp, memcpy etc.
Last edit: Johann Peter 2018-10-29
Are you intetested providing a Pull Request to support these builtin functions?