Page MenuHomePhabricator

[clang-tidy] IncludeInserter: allow <> in header name
ClosedPublic

Authored by alexfh on Aug 10 2020, 10:23 AM.

Details

Summary

This adds a pair of overloads for create(MainFile)?IncludeInsertion methods that
use the presence of the <> in the file name to control whether the #include
directive will use angle brackets or quotes. Motivating examples:
https://reviews.llvm.org/D82089#inline-789412 and
https://github.com/llvm/llvm-project/blob/master/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp#L433

The overloads with the IsAngled parameter can be removed after the users are
updated.

Update usages of createIncludeInsertion.

Update (almost all) usages of createMainFileIncludeInsertion.

Diff Detail

Event Timeline

alexfh created this revision.Aug 10 2020, 10:23 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 10 2020, 10:23 AM
alexfh requested review of this revision.Aug 10 2020, 10:23 AM
hokein accepted this revision.Aug 11 2020, 12:04 AM
hokein added inline comments.
clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
31

this looks like a bug fix, I think the check lit test didn't cover it before, maybe add a header verification in test/clang-tidy/checkers/cppcoreguidelines-init-variables.cpp.

clang-tools-extra/clang-tidy/utils/IncludeInserter.h
71–73

Add a FIXME saying this would be removed eventually.

87–89

The same here.

This revision is now accepted and ready to land.Aug 11 2020, 12:04 AM

Should a line be added to the release notes to explain this behaviour:
'Checks that specify files to include now support wrapping the include in angle brackets to create a system include'?

njames93 added inline comments.Aug 11 2020, 8:40 AM
clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp
98–103

To save duplication could this not just dispatch to createIncludeInsertion(FileID, StringRef)

alexfh updated this revision to Diff 294666.Mon, Sep 28, 5:18 AM
alexfh marked 4 inline comments as done.
  • clang-format
  • addressed review comments
clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
31

I've already added this ;)

clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp
98–103

Good point! Thanks!

alexfh updated this revision to Diff 294678.Mon, Sep 28, 5:59 AM
  • Updated release notes and default option values in docs
This revision was automatically updated to reflect the committed changes.