目前,我正在项目中使用Clang格式实用程序。为了在我的团队中共享它的设置,我将..clang格式的配置文件放在项目文件夹的根目录中,现在IDE在使用项目时自动加载它。同样,我想使用Clang实用程序。但是,与Clang格式不同,我无法找到配置文件格式的描述或创建配置文件格式的实用程序。我还需要IDE自动加载这些设置,并在自动格式化中考虑到这些设置,因此我无法使用一个脚本来运行该实用程序,该脚本将向它传递必要的参数。有什么办法能满足我的需要吗?
发布于 2021-11-24 20:45:12
.clang-tidy
文件格式实际上是在命令行帮助中指定的,请参见文献资料。
--config=<string> -
Specifies a configuration in YAML/JSON format:
-config="{Checks: '*',
CheckOptions: [{key: x,
value: y}]}"
When the value is empty, clang-tidy will
attempt to find a file named .clang-tidy for
each source file in its parent directories.
--config-file=<string> -
Specify the path of .clang-tidy or custom config file:
e.g. --config-file=/some/path/myTidyConfigFile
This option internally works exactly the same way as
--config option after reading specified config file.
Use either --config-file or --config, not both.
您所需要做的就是将配置字符串放入一个文件中,这样就可以了。如果不指定--config-file
选项,它将自动在选中代码所在的目录中搜索.clang-tidy
文件。
一个示例.clang-tidy
文件:
Checks: '-*,bugprone-*'
CheckOptions:
- key: bugprone-argument-comment.StrictMode
value: 1
- key: bugprone-exception-escape.FunctionsThatShouldNotThrow
value: WinMain,SDL_main
FormatStyle: 'file'
这将运行所有容易出错的检查,并为其中两个设置选项。
https://stackoverflow.com/questions/70081393
复制相似问题