Is it possible for MultiplexExternalSemaSource to own the Sources?

MultiplexExternalSemaSource doesn’t own the Sources.
SmallVector<ExternalSemaSource *, 2> Sources; // doesn't own them.

So when using it, one has to take care of the ownership of the Sources.

One solution I found in clang is in ChainedIncludesSource.
It creates a struct to hold the Sources and inherited the struct.

/// 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) {}
};

Is there another solution to take care of the ownership of Sources?

Is it possible for MultiplexExternalSemaSource to own the Sources?

Thanks
Xiang

Posted a change for review: ⚙ D133158 [NFC] Make MultiplexExternalSemaSource own sources