This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Add an option to export suggested fixes into a file.
ClosedPublic

Authored by bkramer on Sep 3 2014, 11:44 AM.

Diff Detail

Event Timeline

bkramer updated this revision to Diff 13220.Sep 3 2014, 11:44 AM
bkramer retitled this revision from to [clang-tidy] Add an option to export suggested fixes into a file..
bkramer added a reviewer: alexfh.
bkramer updated this object.
bkramer added a subscriber: Unknown Object (MLST).
alexfh accepted this revision.Sep 4 2014, 2:57 AM
alexfh edited edge metadata.

NIce! But please add error handling for YAML serialization and a bit more description of the new option.

clang-tidy/ClangTidy.cpp
374

"return YAML.error();" seems like a good idea in case the file is not writable or any other error occurs.

clang-tidy/tool/ClangTidyMain.cpp
82

I'd say a few more words about why we need this and how can one use this file.

This revision is now accepted and ready to land.Sep 4 2014, 2:57 AM
bkramer added inline comments.Sep 4 2014, 3:20 AM
clang-tidy/ClangTidy.cpp
374

yaml::Output has no way to retrieve errors :(

Diffusion closed this revision.Sep 4 2014, 3:41 AM
Diffusion updated this revision to Diff 13243.

Closed by commit rL217139 (authored by d0k).

alexfh added inline comments.Sep 4 2014, 4:55 AM
clang-tidy/ClangTidy.cpp
374

Oh, didn't know that. In this case, you could use raw_fd_ostream::has_error() after manually closing it. It doesn't provide much detail about what was wrong, but it's better than nothing. WDYT?

bkramer added inline comments.Sep 4 2014, 5:07 AM
clang-tidy/ClangTidy.cpp
374

raw_ostream will report a fatal error on close anyways when anything went wrong (and we didn't clear the error). The only thing we could do is provide a nicer message, not sure if that's worth the additional code.