ch_bot
(Andreas Frei)
January 12, 2022, 3:36pm
1
I don’t know how to activate clang tidy.
I followed the Code linting Documentation and created the .clang-tidy file.
In my code I have a null pointer.
char *a = NULL;
This should be converted to nullptr.
Unfortunately, after compiling, there is no warning or error telling me this.
This is my .clang-tidy file
Checks: '*'
CheckOptions:
- key: modernize-use-nullptr.NullMacros
value: NULL,CUSTOM_NULL
I really don’t know how to activate clang-tidy.
As I understand it, I need to check the Clang Tidy box in the settings, create a clang-tidy file in the root of the current project and compile it.
What am I missing?
ladislas
(Ladislas de Toldi)
January 12, 2022, 10:02pm
2
Are you using visual studio code?
If so, you can use the vscode-clangd extension:
We have it working perfectly with the following options:
"clangd.checkUpdates": true,
"clangd.arguments": [
"--query-driver=/usr/local/bin/arm-none-eabi*",
"--log=verbose",
"--completion-style=detailed",
"--clang-tidy",
"--header-insertion=never",
"--suggest-missing-includes"
]
The --query-driver
part was what was missing for cross compilation. Change the path accordingly.
And the .clang-tidy file:
# vim: set filetype=yaml:
---
HeaderFilterRegex: ""
UseColor: true
FormatStyle: file
Checks: " \
-* \
, bugprone-assert-side-effect \
, bugprone-bool-pointer-implicit-conversion \
, bugprone-branch-clone \
, bugprone-copy-constructor-init \
, bugprone-dangling-handle \
, bugprone-dynamic-static-initializers \
, bugprone-exception-escape \
, bugprone-forward-declaration-namespace \
, bugprone-implicit-widening-of-multiplication-result \
, bugprone-incorrect-roundings \
, bugprone-infinite-loop \
, bugprone-integer-division \
This file has been truncated. show original