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/Sema/MultiplexExternalSemaSource.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/Sema/MultiplexExternalSemaSource.cpp')
-rw-r--r-- | clang/lib/Sema/MultiplexExternalSemaSource.cpp | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/clang/lib/Sema/MultiplexExternalSemaSource.cpp b/clang/lib/Sema/MultiplexExternalSemaSource.cpp index 0727756..55e0154 100644 --- a/clang/lib/Sema/MultiplexExternalSemaSource.cpp +++ b/clang/lib/Sema/MultiplexExternalSemaSource.cpp @@ -16,24 +16,30 @@ using namespace clang; char MultiplexExternalSemaSource::ID; -///Constructs a new multiplexing external sema source and appends the +/// Constructs a new multiplexing external sema source and appends the /// given element to it. /// -MultiplexExternalSemaSource::MultiplexExternalSemaSource(ExternalSemaSource &s1, - ExternalSemaSource &s2){ - Sources.push_back(&s1); - Sources.push_back(&s2); +MultiplexExternalSemaSource::MultiplexExternalSemaSource( + ExternalSemaSource *S1, ExternalSemaSource *S2) { + S1->Retain(); + S2->Retain(); + Sources.push_back(S1); + Sources.push_back(S2); } // pin the vtable here. -MultiplexExternalSemaSource::~MultiplexExternalSemaSource() {} +MultiplexExternalSemaSource::~MultiplexExternalSemaSource() { + for (auto *S : Sources) + S->Release(); +} -///Appends new source to the source list. +/// Appends new source to the source list. /// ///\param[in] source - An ExternalSemaSource. /// -void MultiplexExternalSemaSource::addSource(ExternalSemaSource &source) { - Sources.push_back(&source); +void MultiplexExternalSemaSource::AddSource(ExternalSemaSource *Source) { + Source->Retain(); + Sources.push_back(Source); } //===----------------------------------------------------------------------===// |