This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Added -fix-errors option
ClosedPublic

Authored by alexfh on Oct 31 2014, 11:53 AM.

Details

Summary

Added -fix-errors option to allow applying fixes when compiler errors
are present. Without this flag -fix would bail out if there are compiler errors.
This is needed to avoid applying wrong fixes if Clang fails to recover from
compilation errors correctly.

Diff Detail

Event Timeline

alexfh updated this revision to Diff 15636.Oct 31 2014, 11:53 AM
alexfh retitled this revision from to [clang-tidy] Added -fix-errors option.
alexfh updated this object.
alexfh edited the test plan for this revision. (Show Details)
alexfh added a reviewer: klimek.
alexfh added a subscriber: Unknown Object (MLST).
klimek added inline comments.Nov 1 2014, 4:15 AM
clang-tidy/tool/ClangTidyMain.cpp
295–299

It seems strange to first have to compute DisableFixes based on FixErrors, and then use FixErrors again.
If we want FixErrors to imply Fix, why not have the if (FixErrors) Fix = true; before the whole block?

alexfh updated this revision to Diff 15675.Nov 2 2014, 12:26 AM

Make the relation between -fix-errors and -fix more explicit. Slightly changed error messages.

klimek added inline comments.Nov 2 2014, 8:37 PM
clang-tidy/tool/ClangTidyMain.cpp
300–301

Why don't we directly do llvm::errs() ...; here and skip the rest of the function (perhaps apart from the stat printing and profile checking)?

alexfh added inline comments.Nov 2 2014, 8:42 PM
clang-tidy/tool/ClangTidyMain.cpp
300–301

We need to call handleErrors to display the errors in any case. We also need to print the stats and profile data, and only then the message that fixes had not been applied.

klimek accepted this revision.Nov 2 2014, 9:01 PM
klimek edited edge metadata.

lg

clang-tidy/tool/ClangTidyMain.cpp
300–301

Ok, then I'd optionally do Fix && !DisableFixes below instead of using the flag like a global variable...

This revision is now accepted and ready to land.Nov 2 2014, 9:01 PM
alexfh closed this revision.Nov 3 2014, 6:17 AM
alexfh added inline comments.Nov 3 2014, 6:37 AM
clang-tidy/tool/ClangTidyMain.cpp
300–301

Done. Committed.