c++clang

Apply Clang's fix-it hints automatically from command line


Clang (and GCC) compilation errors can come with suggestions on how to fix them: "Fix-it Hints". Does Clang (or maybe another LLVM tool) have an option which would apply these hints? I don't see one in https://clang.llvm.org/docs/UsersManual.html. Obviously such a program could be written using -fdiagnostics-parseable-fixits; that's not what I am asking about.


Solution

  • Yes.

     -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