我正在尝试从 visual studio 或命令行对文件应用 clang 现代化,利用我的 visual studio 2015 C++ 项目中的包含路径和设置。
我创建了一个 clang-tidy 设置文件,如下所示:
clang-tidy -dump-config=.clang-tidy
-checks="modernize-loop-convert,modernize-deprecated-headers"
并从 (cygwin) 命令行验证它适用于单个文件:clang-tidy.exe -explain-config
列出(除其他外)
'modernize-deprecated-headers' is enabled in the C:\abc\.clang-tidy.
我可以通过手动设置包含在单个文件上运行它:
clang-tidy.exe someFile.cpp -- -Ic:/abc -I。 -IIncludes
我安装了 visual studio clang-format VS plugin ,并创建了一个示例 .clang-format 文件,{ BasedOnStyle: "LLVM", IndentWidth: 20 }
, 由 VS 插件获取。然后我天真地尝试使用 clang-tidy 配置提供 clang-format,但不出所料,这根本不起作用。
总结一下:如何在文件和 Visual Studio 项目上运行 clang-tidy?
也许解决方法是从 visual studio 中转储每个文件的包含?任何前进的方向都可以。
供引用:
How can I enable clang-tidy's "modernize" checks?
How to feed Visual Studio Clang-Format plugin with clang-format file?
最佳答案
我是 Cppcheck 开发人员。
您可以在 Cppcheck GUI 中对 visual studio 解决方案运行 clang-tidy。
它是一个免费的开源 (GPL) 工具。您可以在这里下载:http://cppcheck.sf.net
部分截图: http://cppcheck.sourceforge.net/clangtidy/index.html
它目前没有集成其他 clang 工具(例如 clang-format),但可以提取 Cppcheck GUI 使用的 clang-tidy 命令。也许您可以编辑它们。
关于c++ - 如何使用 clang-tidy 通过 visual studio 实现现代化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41441188/