Page MenuHomePhabricator

[clang-tidy] Refactor IncludeInserter

Authored by njames93 on Mon, Jul 13, 6:27 AM.



Simplified how IncludeInserter is used in Checks by abstracting away the SourceManager and PPCallbacks inside the method registerPreprocessor.
Changed checks that use IncludeInserter to no longer use a std::unique_ptr, instead the IncludeInserter is just a member of the class thats initialized with an IncludeStyle.
Saving an unnecessary allocation.

This results in the removal of the field IncludeSorter::IncludeStyle from the checks, as its wrapped in the IncludeInserter.
No longer need to create an instance of the IncludeInserter in the registerPPCallbacks, now that method only needs to contain:


Also added a helper method to IncludeInserter called createMainFileInclusionInsertion, purely sugar but does better express intentions.

Diff Detail

Event Timeline

njames93 created this revision.Mon, Jul 13, 6:27 AM
Herald added a project: Restricted Project. · View Herald TranscriptMon, Jul 13, 6:27 AM
aaron.ballman added inline comments.Fri, Jul 17, 7:45 AM

I think it might be useful to add something like ; did you remember to call registerPreprocessor()? to the assertion message, as that seems like it would be the most likely issue if SourceMgr was null.


retrived -> retrieved
ClangTidyOptios -> ClangTidyOptions


or if inclusion -> or if the inclusion


or if inclusion -> or if the inclusion


In-class initialize this to nullptr instead of leaving it indeterminate?

njames93 updated this revision to Diff 278807.Fri, Jul 17, 9:33 AM
njames93 marked 5 inline comments as done.

Address reviewer comments

This revision is now accepted and ready to land.Fri, Jul 17, 9:38 AM
This revision was automatically updated to reflect the committed changes.