[all-commits] [llvm/llvm-project] 13c9bb: [clang-tidy] Refactor IncludeInserter

Nathan James via All-commits all-commits at lists.llvm.org
Mon Jul 27 04:49:17 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 13c9bbc28ef9cf9976a0962e6c930a7dfc52c877
      https://github.com/llvm/llvm-project/commit/13c9bbc28ef9cf9976a0962e6c930a7dfc52c877
  Author: Nathan James <n.james93 at hotmail.co.uk>
  Date:   2020-07-27 (Mon, 27 Jul 2020)

  Changed paths:
    M clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp
    M clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.h
    M clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
    M clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.h
    M clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
    M clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.h
    M clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
    M clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.h
    M clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp
    M clang-tools-extra/clang-tidy/modernize/PassByValueCheck.h
    M clang-tools-extra/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp
    M clang-tools-extra/clang-tidy/modernize/ReplaceAutoPtrCheck.h
    M clang-tools-extra/clang-tidy/modernize/ReplaceRandomShuffleCheck.cpp
    M clang-tools-extra/clang-tidy/modernize/ReplaceRandomShuffleCheck.h
    M clang-tools-extra/clang-tidy/performance/MoveConstructorInitCheck.cpp
    M clang-tools-extra/clang-tidy/performance/MoveConstructorInitCheck.h
    M clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.cpp
    M clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.h
    M clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
    M clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.h
    M clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp
    M clang-tools-extra/clang-tidy/utils/IncludeInserter.h
    M clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
    M clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.h
    M clang-tools-extra/unittests/clang-tidy/IncludeInserterTest.cpp

  Log Message:
  -----------
  [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




More information about the All-commits mailing list