diff options
author | Chris Bieneman <chris.bieneman@me.com> | 2022-09-01 16:31:23 -0500 |
---|---|---|
committer | Chris Bieneman <chris.bieneman@me.com> | 2022-09-02 13:57:39 -0500 |
commit | 5b5329bd41ba977459fcd7abb7cf438fd98c98e0 (patch) | |
tree | 5bf4a8bc736e4856001d32a74339e2ee96fd8a5b /clang/lib/Frontend/ChainedIncludesSource.cpp | |
parent | 1491282165bfb87b15bd806ab53b3e9910ee7b29 (diff) | |
download | llvm-5b5329bd41ba977459fcd7abb7cf438fd98c98e0.zip llvm-5b5329bd41ba977459fcd7abb7cf438fd98c98e0.tar.gz llvm-5b5329bd41ba977459fcd7abb7cf438fd98c98e0.tar.bz2 |
[NFC] Make MultiplexExternalSemaSource own sources
This change refactors the MuiltiplexExternalSemaSource to take ownership
of the underlying sources. As a result it makes a larger cleanup of
external source ownership in Sema and the ChainedIncludesSource.
Reviewed By: aaron.ballman, aprantl
Differential Revision: https://reviews.llvm.org/D133158
Diffstat (limited to 'clang/lib/Frontend/ChainedIncludesSource.cpp')
-rw-r--r-- | clang/lib/Frontend/ChainedIncludesSource.cpp | 39 |
1 files changed, 9 insertions, 30 deletions
diff --git a/clang/lib/Frontend/ChainedIncludesSource.cpp b/clang/lib/Frontend/ChainedIncludesSource.cpp index 380eba4..c1a9f25 100644 --- a/clang/lib/Frontend/ChainedIncludesSource.cpp +++ b/clang/lib/Frontend/ChainedIncludesSource.cpp @@ -27,15 +27,15 @@ using namespace clang; namespace { -class ChainedIncludesSourceImpl : public ExternalSemaSource { +class ChainedIncludesSource : public ExternalSemaSource { public: - ChainedIncludesSourceImpl(std::vector<std::unique_ptr<CompilerInstance>> CIs) + ChainedIncludesSource(std::vector<std::unique_ptr<CompilerInstance>> CIs) : CIs(std::move(CIs)) {} protected: - //===----------------------------------------------------------------------===// + //===--------------------------------------------------------------------===// // ExternalASTSource interface. - //===----------------------------------------------------------------------===// + //===--------------------------------------------------------------------===// /// Return the amount of memory used by memory buffers, breaking down /// by heap-backed versus mmap'ed memory. @@ -51,30 +51,7 @@ protected: private: std::vector<std::unique_ptr<CompilerInstance>> CIs; }; - -/// Members of ChainedIncludesSource, factored out so we can initialize -/// them before we initialize the ExternalSemaSource base class. -struct ChainedIncludesSourceMembers { - ChainedIncludesSourceMembers( - std::vector<std::unique_ptr<CompilerInstance>> CIs, - IntrusiveRefCntPtr<ExternalSemaSource> FinalReader) - : Impl(std::move(CIs)), FinalReader(std::move(FinalReader)) {} - ChainedIncludesSourceImpl Impl; - IntrusiveRefCntPtr<ExternalSemaSource> FinalReader; -}; - -/// Use MultiplexExternalSemaSource to dispatch all ExternalSemaSource -/// calls to the final reader. -class ChainedIncludesSource - : private ChainedIncludesSourceMembers, - public MultiplexExternalSemaSource { -public: - ChainedIncludesSource(std::vector<std::unique_ptr<CompilerInstance>> CIs, - IntrusiveRefCntPtr<ExternalSemaSource> FinalReader) - : ChainedIncludesSourceMembers(std::move(CIs), std::move(FinalReader)), - MultiplexExternalSemaSource(Impl, *this->FinalReader) {} -}; -} +} // end anonymous namespace static ASTReader * createASTReader(CompilerInstance &CI, StringRef pchFile, @@ -214,6 +191,8 @@ IntrusiveRefCntPtr<ExternalSemaSource> clang::createChainedIncludesSource( if (!Reader) return nullptr; - return IntrusiveRefCntPtr<ChainedIncludesSource>( - new ChainedIncludesSource(std::move(CIs), Reader)); + auto ChainedSrc = + llvm::makeIntrusiveRefCnt<ChainedIncludesSource>(std::move(CIs)); + return llvm::makeIntrusiveRefCnt<MultiplexExternalSemaSource>( + ChainedSrc.get(), Reader.get()); } |