This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Make clang-format and include-order-check coherent
ClosedPublic

Authored by kadircet on Nov 17 2020, 1:31 AM.

Details

Summary

LLVM style puts both gtest and gmock to the end of the include list.
But llvm-include-order-check was only moving gtest headers to the end, resulting
in a false tidy-warning.

Diff Detail

Event Timeline

kadircet created this revision.Nov 17 2020, 1:31 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 17 2020, 1:31 AM
kadircet requested review of this revision.Nov 17 2020, 1:31 AM
hokein accepted this revision.Nov 17 2020, 1:56 AM
This revision is now accepted and ready to land.Nov 17 2020, 1:56 AM
kadircet updated this revision to Diff 305707.Nov 17 2020, 2:11 AM
  • Add gmock header

Thanks for fixing this, been bugging me for a while.

clang-tools-extra/test/clang-tidy/checkers/llvm-include-order.cpp
1

Would it be wise to specify a format style here to ensure they align. Better yet 2 run lines, one that runs clang-tidy with no format, the other specifies a format.

kadircet added inline comments.Nov 17 2020, 6:21 AM
clang-tools-extra/test/clang-tidy/checkers/llvm-include-order.cpp
1

ah sorry, i missed this comment :/ i am not sure how the formatting vs. generated edits interact. is it enough to have --format-style=LLVM and ensure the run lines produce the same ordering?

njames93 added inline comments.Nov 17 2020, 10:07 AM
clang-tools-extra/test/clang-tidy/checkers/llvm-include-order.cpp
1

Just noticed they still don't seem to sync up, but thats because llvm-include-order doesn't move the first include in a file. Could argue that's a bug and instead should use a heuristic based on the translation unit name and header name.