HomePhabricator

[clang-tidy] Refactor IncludeInserter

Authored by njames93 on Mon, Jul 27, 4:48 AM.

Description

[clang-tidy] Refactor IncludeInserter

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:

Inserter.registerPreprocessor(PP);

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

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D83680

Details

Committed
njames93Mon, Jul 27, 4:48 AM
Reviewer
aaron.ballman
Differential Revision
D83680: [clang-tidy] Refactor IncludeInserter
Parents
rG47a0254229ca: Speculative build fix for clangd/Features.inc.in
Branches
Unknown
Tags
Unknown