<p dir="ltr">Sigh. Fixed in r275730.</p>
<div class="gmail_extra"><br><div class="gmail_quote">On 17 Jul 2016 10:54 a.m., "Reid Kleckner via cfe-commits" <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Breaks the VS 2013 build, even though we tried to check ahead of time:<div><a href="https://llvm.org/bugs/show_bug.cgi?id=28589" target="_blank">https://llvm.org/bugs/show_bug.cgi?id=28589</a><br></div><div><a href="http://lab.llvm.org:8011/builders/clang-x86-win2008-selfhost/builds/9110" target="_blank">http://lab.llvm.org:8011/builders/clang-x86-win2008-selfhost/builds/9110</a></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jul 15, 2016 at 5:35 PM, Richard Smith via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: rsmith<br>
Date: Fri Jul 15 19:35:14 2016<br>
New Revision: 275653<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=275653&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=275653&view=rev</a><br>
Log:<br>
Reimplement ExternalSemaSource delegation in terms of<br>
MultiplexExternalSemaSource to remove one of the places that needs updating<br>
every time the ExternalSemaSource interface changes.<br>
<br>
Modified:<br>
cfe/trunk/lib/Frontend/ChainedIncludesSource.cpp<br>
<br>
Modified: cfe/trunk/lib/Frontend/ChainedIncludesSource.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ChainedIncludesSource.cpp?rev=275653&r1=275652&r2=275653&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ChainedIncludesSource.cpp?rev=275653&r1=275652&r2=275653&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Frontend/ChainedIncludesSource.cpp (original)<br>
+++ cfe/trunk/lib/Frontend/ChainedIncludesSource.cpp Fri Jul 15 19:35:14 2016<br>
@@ -18,6 +18,7 @@<br>
#include "clang/Frontend/TextDiagnosticPrinter.h"<br>
#include "clang/Lex/Preprocessor.h"<br>
#include "clang/Parse/ParseAST.h"<br>
+#include "clang/Sema/MultiplexExternalSemaSource.h"<br>
#include "clang/Serialization/ASTReader.h"<br>
#include "clang/Serialization/ASTWriter.h"<br>
#include "llvm/Support/MemoryBuffer.h"<br>
@@ -25,51 +26,48 @@<br>
using namespace clang;<br>
<br>
namespace {<br>
-class ChainedIncludesSource : public ExternalSemaSource {<br>
+class ChainedIncludesSourceImpl : public ExternalSemaSource {<br>
public:<br>
- ~ChainedIncludesSource() override;<br>
-<br>
- ExternalSemaSource &getFinalReader() const { return *FinalReader; }<br>
-<br>
- std::vector<CompilerInstance *> CIs;<br>
- IntrusiveRefCntPtr<ExternalSemaSource> FinalReader;<br>
+ ChainedIncludesSourceImpl(std::vector<std::unique_ptr<CompilerInstance>> CIs)<br>
+ : CIs(std::move(CIs)) {}<br>
<br>
protected:<br>
//===----------------------------------------------------------------------===//<br>
// ExternalASTSource interface.<br>
//===----------------------------------------------------------------------===//<br>
<br>
- Decl *GetExternalDecl(uint32_t ID) override;<br>
- Selector GetExternalSelector(uint32_t ID) override;<br>
- uint32_t GetNumExternalSelectors() override;<br>
- Stmt *GetExternalDeclStmt(uint64_t Offset) override;<br>
- CXXCtorInitializer **GetExternalCXXCtorInitializers(uint64_t Offset) override;<br>
- CXXBaseSpecifier *GetExternalCXXBaseSpecifiers(uint64_t Offset) override;<br>
- bool FindExternalVisibleDeclsByName(const DeclContext *DC,<br>
- DeclarationName Name) override;<br>
- void<br>
- FindExternalLexicalDecls(const DeclContext *DC,<br>
- llvm::function_ref<bool(Decl::Kind)> IsKindWeWant,<br>
- SmallVectorImpl<Decl *> &Result) override;<br>
- void CompleteType(TagDecl *Tag) override;<br>
- void CompleteType(ObjCInterfaceDecl *Class) override;<br>
- void StartedDeserializing() override;<br>
- void FinishedDeserializing() override;<br>
- void StartTranslationUnit(ASTConsumer *Consumer) override;<br>
- void PrintStats() override;<br>
-<br>
/// Return the amount of memory used by memory buffers, breaking down<br>
/// by heap-backed versus mmap'ed memory.<br>
- void getMemoryBufferSizes(MemoryBufferSizes &sizes) const override;<br>
+ void getMemoryBufferSizes(MemoryBufferSizes &sizes) const override {<br>
+ for (unsigned i = 0, e = CIs.size(); i != e; ++i) {<br>
+ if (const ExternalASTSource *eSrc =<br>
+ CIs[i]->getASTContext().getExternalSource()) {<br>
+ eSrc->getMemoryBufferSizes(sizes);<br>
+ }<br>
+ }<br>
+ }<br>
<br>
- //===----------------------------------------------------------------------===//<br>
- // ExternalSemaSource interface.<br>
- //===----------------------------------------------------------------------===//<br>
+private:<br>
+ std::vector<std::unique_ptr<CompilerInstance>> CIs;<br>
+};<br>
<br>
- void InitializeSema(Sema &S) override;<br>
- void ForgetSema() override;<br>
- void ReadMethodPool(Selector Sel) override;<br>
- bool LookupUnqualified(LookupResult &R, Scope *S) override;<br>
+/// Members of ChainedIncludesSource, factored out so we can initialize<br>
+/// them before we initialize the ExternalSemaSource base class.<br>
+struct ChainedIncludesSourceMembers {<br>
+ ChainedIncludesSourceImpl Impl;<br>
+ IntrusiveRefCntPtr<ExternalSemaSource> FinalReader;<br>
+};<br>
+<br>
+/// Use MultiplexExternalSemaSource to dispatch all ExternalSemaSource<br>
+/// calls to the final reader.<br>
+class ChainedIncludesSource<br>
+ : private ChainedIncludesSourceMembers,<br>
+ public MultiplexExternalSemaSource {<br>
+public:<br>
+ ChainedIncludesSource(std::vector<std::unique_ptr<CompilerInstance>> CIs,<br>
+ IntrusiveRefCntPtr<ExternalSemaSource> FinalReader)<br>
+ : ChainedIncludesSourceMembers{{std::move(CIs)}, std::move(FinalReader)},<br>
+ MultiplexExternalSemaSource(Impl, *this->FinalReader) {}<br>
};<br>
}<br>
<br>
@@ -107,18 +105,13 @@ createASTReader(CompilerInstance &CI, St<br>
return nullptr;<br>
}<br>
<br>
-ChainedIncludesSource::~ChainedIncludesSource() {<br>
- for (unsigned i = 0, e = CIs.size(); i != e; ++i)<br>
- delete CIs[i];<br>
-}<br>
-<br>
IntrusiveRefCntPtr<ExternalSemaSource> clang::createChainedIncludesSource(<br>
CompilerInstance &CI, IntrusiveRefCntPtr<ExternalSemaSource> &Reader) {<br>
<br>
std::vector<std::string> &includes = CI.getPreprocessorOpts().ChainedIncludes;<br>
assert(!includes.empty() && "No '-chain-include' in options!");<br>
<br>
- IntrusiveRefCntPtr<ChainedIncludesSource> source(new ChainedIncludesSource());<br>
+ std::vector<std::unique_ptr<CompilerInstance>> CIs;<br>
InputKind IK = CI.getFrontendOpts().Inputs[0].getKind();<br>
<br>
SmallVector<std::unique_ptr<llvm::MemoryBuffer>, 4> SerialBufs;<br>
@@ -206,7 +199,7 @@ IntrusiveRefCntPtr<ExternalSemaSource> c<br>
SerialBufs.push_back(llvm::MemoryBuffer::getMemBufferCopy(<br>
StringRef(serialAST.data(), serialAST.size())));<br>
serialAST.clear();<br>
- source->CIs.push_back(Clang.release());<br>
+ CIs.push_back(std::move(Clang));<br>
}<br>
<br>
assert(!SerialBufs.empty());<br>
@@ -216,83 +209,6 @@ IntrusiveRefCntPtr<ExternalSemaSource> c<br>
if (!Reader)<br>
return nullptr;<br>
<br>
- source->FinalReader = Reader;<br>
- return source;<br>
-}<br>
-<br>
-//===----------------------------------------------------------------------===//<br>
-// ExternalASTSource interface.<br>
-//===----------------------------------------------------------------------===//<br>
-<br>
-Decl *ChainedIncludesSource::GetExternalDecl(uint32_t ID) {<br>
- return getFinalReader().GetExternalDecl(ID);<br>
-}<br>
-Selector ChainedIncludesSource::GetExternalSelector(uint32_t ID) {<br>
- return getFinalReader().GetExternalSelector(ID);<br>
-}<br>
-uint32_t ChainedIncludesSource::GetNumExternalSelectors() {<br>
- return getFinalReader().GetNumExternalSelectors();<br>
-}<br>
-Stmt *ChainedIncludesSource::GetExternalDeclStmt(uint64_t Offset) {<br>
- return getFinalReader().GetExternalDeclStmt(Offset);<br>
+ return IntrusiveRefCntPtr<ChainedIncludesSource>(<br>
+ new ChainedIncludesSource(std::move(CIs), Reader));<br>
}<br>
-CXXBaseSpecifier *<br>
-ChainedIncludesSource::GetExternalCXXBaseSpecifiers(uint64_t Offset) {<br>
- return getFinalReader().GetExternalCXXBaseSpecifiers(Offset);<br>
-}<br>
-CXXCtorInitializer **<br>
-ChainedIncludesSource::GetExternalCXXCtorInitializers(uint64_t Offset) {<br>
- return getFinalReader().GetExternalCXXCtorInitializers(Offset);<br>
-}<br>
-bool<br>
-ChainedIncludesSource::FindExternalVisibleDeclsByName(const DeclContext *DC,<br>
- DeclarationName Name) {<br>
- return getFinalReader().FindExternalVisibleDeclsByName(DC, Name);<br>
-}<br>
-void ChainedIncludesSource::FindExternalLexicalDecls(<br>
- const DeclContext *DC, llvm::function_ref<bool(Decl::Kind)> IsKindWeWant,<br>
- SmallVectorImpl<Decl *> &Result) {<br>
- return getFinalReader().FindExternalLexicalDecls(DC, IsKindWeWant, Result);<br>
-}<br>
-void ChainedIncludesSource::CompleteType(TagDecl *Tag) {<br>
- return getFinalReader().CompleteType(Tag);<br>
-}<br>
-void ChainedIncludesSource::CompleteType(ObjCInterfaceDecl *Class) {<br>
- return getFinalReader().CompleteType(Class);<br>
-}<br>
-void ChainedIncludesSource::StartedDeserializing() {<br>
- return getFinalReader().StartedDeserializing();<br>
-}<br>
-void ChainedIncludesSource::FinishedDeserializing() {<br>
- return getFinalReader().FinishedDeserializing();<br>
-}<br>
-void ChainedIncludesSource::StartTranslationUnit(ASTConsumer *Consumer) {<br>
- return getFinalReader().StartTranslationUnit(Consumer);<br>
-}<br>
-void ChainedIncludesSource::PrintStats() {<br>
- return getFinalReader().PrintStats();<br>
-}<br>
-void ChainedIncludesSource::getMemoryBufferSizes(MemoryBufferSizes &sizes)const{<br>
- for (unsigned i = 0, e = CIs.size(); i != e; ++i) {<br>
- if (const ExternalASTSource *eSrc =<br>
- CIs[i]->getASTContext().getExternalSource()) {<br>
- eSrc->getMemoryBufferSizes(sizes);<br>
- }<br>
- }<br>
-<br>
- getFinalReader().getMemoryBufferSizes(sizes);<br>
-}<br>
-<br>
-void ChainedIncludesSource::InitializeSema(Sema &S) {<br>
- return getFinalReader().InitializeSema(S);<br>
-}<br>
-void ChainedIncludesSource::ForgetSema() {<br>
- return getFinalReader().ForgetSema();<br>
-}<br>
-void ChainedIncludesSource::ReadMethodPool(Selector Sel) {<br>
- getFinalReader().ReadMethodPool(Sel);<br>
-}<br>
-bool ChainedIncludesSource::LookupUnqualified(LookupResult &R, Scope *S) {<br>
- return getFinalReader().LookupUnqualified(R, S);<br>
-}<br>
-<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>
<br>_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
<br></blockquote></div></div>