从命令行自动应用 Clang 的修复提示

Ale*_*nov 3 c++ clang

Clang(和 GCC)编译错误可能伴随着如何修复它们的建议:“Fix-it Hints”。Clang(或者另一个 LLVM 工具)是否有一个选项可以应用这些提示?我在https://clang.llvm.org/docs/UsersManual.html 中没有看到。显然,这样的程序可以使用-fdiagnostics-parseable-fixits; 这不是我要问的。

Yak*_*ont 6

是的。

 -fix-only-warnings      Apply fix-it advice only for warnings, not errors
 -fix-what-you-can       Apply fix-it advice even in the presence of unfixable errors
 -fixit-recompile        Apply fix-it changes and recompile
 -fixit-to-temporary     Apply fix-it changes to temporary files
 -fixit=<value>          Apply fix-it advice creating a file with the given suffix
 -fixit                  Apply fix-it advice to the input source
Run Code Online (Sandbox Code Playgroud)