1f4a2713aSLionel Sambuc //===- MultiplexConsumer.cpp - AST Consumer for PCH Generation --*- C++ -*-===//
2f4a2713aSLionel Sambuc //
3f4a2713aSLionel Sambuc // The LLVM Compiler Infrastructure
4f4a2713aSLionel Sambuc //
5f4a2713aSLionel Sambuc // This file is distributed under the University of Illinois Open Source
6f4a2713aSLionel Sambuc // License. See LICENSE.TXT for details.
7f4a2713aSLionel Sambuc //
8f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===//
9f4a2713aSLionel Sambuc //
10f4a2713aSLionel Sambuc // This file defines the MultiplexConsumer class. It also declares and defines
11f4a2713aSLionel Sambuc // MultiplexASTDeserializationListener and MultiplexASTMutationListener, which
12f4a2713aSLionel Sambuc // are implementation details of MultiplexConsumer.
13f4a2713aSLionel Sambuc //
14f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===//
15f4a2713aSLionel Sambuc
16f4a2713aSLionel Sambuc #include "clang/Frontend/MultiplexConsumer.h"
17f4a2713aSLionel Sambuc #include "clang/AST/ASTMutationListener.h"
18f4a2713aSLionel Sambuc #include "clang/AST/DeclGroup.h"
19f4a2713aSLionel Sambuc #include "clang/Serialization/ASTDeserializationListener.h"
20f4a2713aSLionel Sambuc
21f4a2713aSLionel Sambuc using namespace clang;
22f4a2713aSLionel Sambuc
23f4a2713aSLionel Sambuc namespace clang {
24f4a2713aSLionel Sambuc
25f4a2713aSLionel Sambuc // This ASTDeserializationListener forwards its notifications to a set of
26f4a2713aSLionel Sambuc // child listeners.
27f4a2713aSLionel Sambuc class MultiplexASTDeserializationListener
28f4a2713aSLionel Sambuc : public ASTDeserializationListener {
29f4a2713aSLionel Sambuc public:
30f4a2713aSLionel Sambuc // Does NOT take ownership of the elements in L.
31f4a2713aSLionel Sambuc MultiplexASTDeserializationListener(
32f4a2713aSLionel Sambuc const std::vector<ASTDeserializationListener*>& L);
33*0a6a1f1dSLionel Sambuc void ReaderInitialized(ASTReader *Reader) override;
34*0a6a1f1dSLionel Sambuc void IdentifierRead(serialization::IdentID ID,
35*0a6a1f1dSLionel Sambuc IdentifierInfo *II) override;
36*0a6a1f1dSLionel Sambuc void TypeRead(serialization::TypeIdx Idx, QualType T) override;
37*0a6a1f1dSLionel Sambuc void DeclRead(serialization::DeclID ID, const Decl *D) override;
38*0a6a1f1dSLionel Sambuc void SelectorRead(serialization::SelectorID iD, Selector Sel) override;
39*0a6a1f1dSLionel Sambuc void MacroDefinitionRead(serialization::PreprocessedEntityID,
40*0a6a1f1dSLionel Sambuc MacroDefinition *MD) override;
41f4a2713aSLionel Sambuc private:
42f4a2713aSLionel Sambuc std::vector<ASTDeserializationListener*> Listeners;
43f4a2713aSLionel Sambuc };
44f4a2713aSLionel Sambuc
MultiplexASTDeserializationListener(const std::vector<ASTDeserializationListener * > & L)45f4a2713aSLionel Sambuc MultiplexASTDeserializationListener::MultiplexASTDeserializationListener(
46f4a2713aSLionel Sambuc const std::vector<ASTDeserializationListener*>& L)
47f4a2713aSLionel Sambuc : Listeners(L) {
48f4a2713aSLionel Sambuc }
49f4a2713aSLionel Sambuc
ReaderInitialized(ASTReader * Reader)50f4a2713aSLionel Sambuc void MultiplexASTDeserializationListener::ReaderInitialized(
51f4a2713aSLionel Sambuc ASTReader *Reader) {
52f4a2713aSLionel Sambuc for (size_t i = 0, e = Listeners.size(); i != e; ++i)
53f4a2713aSLionel Sambuc Listeners[i]->ReaderInitialized(Reader);
54f4a2713aSLionel Sambuc }
55f4a2713aSLionel Sambuc
IdentifierRead(serialization::IdentID ID,IdentifierInfo * II)56f4a2713aSLionel Sambuc void MultiplexASTDeserializationListener::IdentifierRead(
57f4a2713aSLionel Sambuc serialization::IdentID ID, IdentifierInfo *II) {
58f4a2713aSLionel Sambuc for (size_t i = 0, e = Listeners.size(); i != e; ++i)
59f4a2713aSLionel Sambuc Listeners[i]->IdentifierRead(ID, II);
60f4a2713aSLionel Sambuc }
61f4a2713aSLionel Sambuc
TypeRead(serialization::TypeIdx Idx,QualType T)62f4a2713aSLionel Sambuc void MultiplexASTDeserializationListener::TypeRead(
63f4a2713aSLionel Sambuc serialization::TypeIdx Idx, QualType T) {
64f4a2713aSLionel Sambuc for (size_t i = 0, e = Listeners.size(); i != e; ++i)
65f4a2713aSLionel Sambuc Listeners[i]->TypeRead(Idx, T);
66f4a2713aSLionel Sambuc }
67f4a2713aSLionel Sambuc
DeclRead(serialization::DeclID ID,const Decl * D)68f4a2713aSLionel Sambuc void MultiplexASTDeserializationListener::DeclRead(
69f4a2713aSLionel Sambuc serialization::DeclID ID, const Decl *D) {
70f4a2713aSLionel Sambuc for (size_t i = 0, e = Listeners.size(); i != e; ++i)
71f4a2713aSLionel Sambuc Listeners[i]->DeclRead(ID, D);
72f4a2713aSLionel Sambuc }
73f4a2713aSLionel Sambuc
SelectorRead(serialization::SelectorID ID,Selector Sel)74f4a2713aSLionel Sambuc void MultiplexASTDeserializationListener::SelectorRead(
75f4a2713aSLionel Sambuc serialization::SelectorID ID, Selector Sel) {
76f4a2713aSLionel Sambuc for (size_t i = 0, e = Listeners.size(); i != e; ++i)
77f4a2713aSLionel Sambuc Listeners[i]->SelectorRead(ID, Sel);
78f4a2713aSLionel Sambuc }
79f4a2713aSLionel Sambuc
MacroDefinitionRead(serialization::PreprocessedEntityID ID,MacroDefinition * MD)80f4a2713aSLionel Sambuc void MultiplexASTDeserializationListener::MacroDefinitionRead(
81f4a2713aSLionel Sambuc serialization::PreprocessedEntityID ID, MacroDefinition *MD) {
82f4a2713aSLionel Sambuc for (size_t i = 0, e = Listeners.size(); i != e; ++i)
83f4a2713aSLionel Sambuc Listeners[i]->MacroDefinitionRead(ID, MD);
84f4a2713aSLionel Sambuc }
85f4a2713aSLionel Sambuc
86f4a2713aSLionel Sambuc // This ASTMutationListener forwards its notifications to a set of
87f4a2713aSLionel Sambuc // child listeners.
88f4a2713aSLionel Sambuc class MultiplexASTMutationListener : public ASTMutationListener {
89f4a2713aSLionel Sambuc public:
90f4a2713aSLionel Sambuc // Does NOT take ownership of the elements in L.
91f4a2713aSLionel Sambuc MultiplexASTMutationListener(ArrayRef<ASTMutationListener*> L);
92*0a6a1f1dSLionel Sambuc void CompletedTagDefinition(const TagDecl *D) override;
93*0a6a1f1dSLionel Sambuc void AddedVisibleDecl(const DeclContext *DC, const Decl *D) override;
94*0a6a1f1dSLionel Sambuc void AddedCXXImplicitMember(const CXXRecordDecl *RD, const Decl *D) override;
95*0a6a1f1dSLionel Sambuc void AddedCXXTemplateSpecialization(const ClassTemplateDecl *TD,
96*0a6a1f1dSLionel Sambuc const ClassTemplateSpecializationDecl *D) override;
97*0a6a1f1dSLionel Sambuc void AddedCXXTemplateSpecialization(const VarTemplateDecl *TD,
98*0a6a1f1dSLionel Sambuc const VarTemplateSpecializationDecl *D) override;
99*0a6a1f1dSLionel Sambuc void AddedCXXTemplateSpecialization(const FunctionTemplateDecl *TD,
100*0a6a1f1dSLionel Sambuc const FunctionDecl *D) override;
101*0a6a1f1dSLionel Sambuc void DeducedReturnType(const FunctionDecl *FD, QualType ReturnType) override;
102*0a6a1f1dSLionel Sambuc void CompletedImplicitDefinition(const FunctionDecl *D) override;
103*0a6a1f1dSLionel Sambuc void StaticDataMemberInstantiated(const VarDecl *D) override;
104*0a6a1f1dSLionel Sambuc void AddedObjCCategoryToInterface(const ObjCCategoryDecl *CatD,
105*0a6a1f1dSLionel Sambuc const ObjCInterfaceDecl *IFD) override;
106*0a6a1f1dSLionel Sambuc void AddedObjCPropertyInClassExtension(const ObjCPropertyDecl *Prop,
107f4a2713aSLionel Sambuc const ObjCPropertyDecl *OrigProp,
108*0a6a1f1dSLionel Sambuc const ObjCCategoryDecl *ClassExt) override;
109*0a6a1f1dSLionel Sambuc void DeclarationMarkedUsed(const Decl *D) override;
110*0a6a1f1dSLionel Sambuc void DeclarationMarkedOpenMPThreadPrivate(const Decl *D) override;
111f4a2713aSLionel Sambuc
112f4a2713aSLionel Sambuc private:
113f4a2713aSLionel Sambuc std::vector<ASTMutationListener*> Listeners;
114f4a2713aSLionel Sambuc };
115f4a2713aSLionel Sambuc
MultiplexASTMutationListener(ArrayRef<ASTMutationListener * > L)116f4a2713aSLionel Sambuc MultiplexASTMutationListener::MultiplexASTMutationListener(
117f4a2713aSLionel Sambuc ArrayRef<ASTMutationListener*> L)
118f4a2713aSLionel Sambuc : Listeners(L.begin(), L.end()) {
119f4a2713aSLionel Sambuc }
120f4a2713aSLionel Sambuc
CompletedTagDefinition(const TagDecl * D)121f4a2713aSLionel Sambuc void MultiplexASTMutationListener::CompletedTagDefinition(const TagDecl *D) {
122f4a2713aSLionel Sambuc for (size_t i = 0, e = Listeners.size(); i != e; ++i)
123f4a2713aSLionel Sambuc Listeners[i]->CompletedTagDefinition(D);
124f4a2713aSLionel Sambuc }
125f4a2713aSLionel Sambuc
AddedVisibleDecl(const DeclContext * DC,const Decl * D)126f4a2713aSLionel Sambuc void MultiplexASTMutationListener::AddedVisibleDecl(
127f4a2713aSLionel Sambuc const DeclContext *DC, const Decl *D) {
128f4a2713aSLionel Sambuc for (size_t i = 0, e = Listeners.size(); i != e; ++i)
129f4a2713aSLionel Sambuc Listeners[i]->AddedVisibleDecl(DC, D);
130f4a2713aSLionel Sambuc }
131f4a2713aSLionel Sambuc
AddedCXXImplicitMember(const CXXRecordDecl * RD,const Decl * D)132f4a2713aSLionel Sambuc void MultiplexASTMutationListener::AddedCXXImplicitMember(
133f4a2713aSLionel Sambuc const CXXRecordDecl *RD, const Decl *D) {
134f4a2713aSLionel Sambuc for (size_t i = 0, e = Listeners.size(); i != e; ++i)
135f4a2713aSLionel Sambuc Listeners[i]->AddedCXXImplicitMember(RD, D);
136f4a2713aSLionel Sambuc }
AddedCXXTemplateSpecialization(const ClassTemplateDecl * TD,const ClassTemplateSpecializationDecl * D)137f4a2713aSLionel Sambuc void MultiplexASTMutationListener::AddedCXXTemplateSpecialization(
138f4a2713aSLionel Sambuc const ClassTemplateDecl *TD, const ClassTemplateSpecializationDecl *D) {
139f4a2713aSLionel Sambuc for (size_t i = 0, e = Listeners.size(); i != e; ++i)
140f4a2713aSLionel Sambuc Listeners[i]->AddedCXXTemplateSpecialization(TD, D);
141f4a2713aSLionel Sambuc }
AddedCXXTemplateSpecialization(const VarTemplateDecl * TD,const VarTemplateSpecializationDecl * D)142f4a2713aSLionel Sambuc void MultiplexASTMutationListener::AddedCXXTemplateSpecialization(
143f4a2713aSLionel Sambuc const VarTemplateDecl *TD, const VarTemplateSpecializationDecl *D) {
144f4a2713aSLionel Sambuc for (size_t i = 0, e = Listeners.size(); i != e; ++i)
145f4a2713aSLionel Sambuc Listeners[i]->AddedCXXTemplateSpecialization(TD, D);
146f4a2713aSLionel Sambuc }
AddedCXXTemplateSpecialization(const FunctionTemplateDecl * TD,const FunctionDecl * D)147f4a2713aSLionel Sambuc void MultiplexASTMutationListener::AddedCXXTemplateSpecialization(
148f4a2713aSLionel Sambuc const FunctionTemplateDecl *TD, const FunctionDecl *D) {
149f4a2713aSLionel Sambuc for (size_t i = 0, e = Listeners.size(); i != e; ++i)
150f4a2713aSLionel Sambuc Listeners[i]->AddedCXXTemplateSpecialization(TD, D);
151f4a2713aSLionel Sambuc }
DeducedReturnType(const FunctionDecl * FD,QualType ReturnType)152f4a2713aSLionel Sambuc void MultiplexASTMutationListener::DeducedReturnType(const FunctionDecl *FD,
153f4a2713aSLionel Sambuc QualType ReturnType) {
154f4a2713aSLionel Sambuc for (size_t i = 0, e = Listeners.size(); i != e; ++i)
155f4a2713aSLionel Sambuc Listeners[i]->DeducedReturnType(FD, ReturnType);
156f4a2713aSLionel Sambuc }
CompletedImplicitDefinition(const FunctionDecl * D)157f4a2713aSLionel Sambuc void MultiplexASTMutationListener::CompletedImplicitDefinition(
158f4a2713aSLionel Sambuc const FunctionDecl *D) {
159f4a2713aSLionel Sambuc for (size_t i = 0, e = Listeners.size(); i != e; ++i)
160f4a2713aSLionel Sambuc Listeners[i]->CompletedImplicitDefinition(D);
161f4a2713aSLionel Sambuc }
StaticDataMemberInstantiated(const VarDecl * D)162f4a2713aSLionel Sambuc void MultiplexASTMutationListener::StaticDataMemberInstantiated(
163f4a2713aSLionel Sambuc const VarDecl *D) {
164f4a2713aSLionel Sambuc for (size_t i = 0, e = Listeners.size(); i != e; ++i)
165f4a2713aSLionel Sambuc Listeners[i]->StaticDataMemberInstantiated(D);
166f4a2713aSLionel Sambuc }
AddedObjCCategoryToInterface(const ObjCCategoryDecl * CatD,const ObjCInterfaceDecl * IFD)167f4a2713aSLionel Sambuc void MultiplexASTMutationListener::AddedObjCCategoryToInterface(
168f4a2713aSLionel Sambuc const ObjCCategoryDecl *CatD,
169f4a2713aSLionel Sambuc const ObjCInterfaceDecl *IFD) {
170f4a2713aSLionel Sambuc for (size_t i = 0, e = Listeners.size(); i != e; ++i)
171f4a2713aSLionel Sambuc Listeners[i]->AddedObjCCategoryToInterface(CatD, IFD);
172f4a2713aSLionel Sambuc }
AddedObjCPropertyInClassExtension(const ObjCPropertyDecl * Prop,const ObjCPropertyDecl * OrigProp,const ObjCCategoryDecl * ClassExt)173f4a2713aSLionel Sambuc void MultiplexASTMutationListener::AddedObjCPropertyInClassExtension(
174f4a2713aSLionel Sambuc const ObjCPropertyDecl *Prop,
175f4a2713aSLionel Sambuc const ObjCPropertyDecl *OrigProp,
176f4a2713aSLionel Sambuc const ObjCCategoryDecl *ClassExt) {
177f4a2713aSLionel Sambuc for (size_t i = 0, e = Listeners.size(); i != e; ++i)
178f4a2713aSLionel Sambuc Listeners[i]->AddedObjCPropertyInClassExtension(Prop, OrigProp, ClassExt);
179f4a2713aSLionel Sambuc }
DeclarationMarkedUsed(const Decl * D)180f4a2713aSLionel Sambuc void MultiplexASTMutationListener::DeclarationMarkedUsed(const Decl *D) {
181f4a2713aSLionel Sambuc for (size_t i = 0, e = Listeners.size(); i != e; ++i)
182f4a2713aSLionel Sambuc Listeners[i]->DeclarationMarkedUsed(D);
183f4a2713aSLionel Sambuc }
DeclarationMarkedOpenMPThreadPrivate(const Decl * D)184*0a6a1f1dSLionel Sambuc void MultiplexASTMutationListener::DeclarationMarkedOpenMPThreadPrivate(
185*0a6a1f1dSLionel Sambuc const Decl *D) {
186*0a6a1f1dSLionel Sambuc for (size_t i = 0, e = Listeners.size(); i != e; ++i)
187*0a6a1f1dSLionel Sambuc Listeners[i]->DeclarationMarkedOpenMPThreadPrivate(D);
188*0a6a1f1dSLionel Sambuc }
189f4a2713aSLionel Sambuc
190f4a2713aSLionel Sambuc } // end namespace clang
191f4a2713aSLionel Sambuc
MultiplexConsumer(std::vector<std::unique_ptr<ASTConsumer>> C)192*0a6a1f1dSLionel Sambuc MultiplexConsumer::MultiplexConsumer(
193*0a6a1f1dSLionel Sambuc std::vector<std::unique_ptr<ASTConsumer>> C)
194*0a6a1f1dSLionel Sambuc : Consumers(std::move(C)), MutationListener(), DeserializationListener() {
195f4a2713aSLionel Sambuc // Collect the mutation listeners and deserialization listeners of all
196f4a2713aSLionel Sambuc // children, and create a multiplex listener each if so.
197f4a2713aSLionel Sambuc std::vector<ASTMutationListener*> mutationListeners;
198f4a2713aSLionel Sambuc std::vector<ASTDeserializationListener*> serializationListeners;
199*0a6a1f1dSLionel Sambuc for (auto &Consumer : Consumers) {
200*0a6a1f1dSLionel Sambuc if (auto *mutationListener = Consumer->GetASTMutationListener())
201f4a2713aSLionel Sambuc mutationListeners.push_back(mutationListener);
202*0a6a1f1dSLionel Sambuc if (auto *serializationListener = Consumer->GetASTDeserializationListener())
203f4a2713aSLionel Sambuc serializationListeners.push_back(serializationListener);
204f4a2713aSLionel Sambuc }
205*0a6a1f1dSLionel Sambuc if (!mutationListeners.empty()) {
206*0a6a1f1dSLionel Sambuc MutationListener =
207*0a6a1f1dSLionel Sambuc llvm::make_unique<MultiplexASTMutationListener>(mutationListeners);
208f4a2713aSLionel Sambuc }
209*0a6a1f1dSLionel Sambuc if (!serializationListeners.empty()) {
210*0a6a1f1dSLionel Sambuc DeserializationListener =
211*0a6a1f1dSLionel Sambuc llvm::make_unique<MultiplexASTDeserializationListener>(
212*0a6a1f1dSLionel Sambuc serializationListeners);
213f4a2713aSLionel Sambuc }
214f4a2713aSLionel Sambuc }
215f4a2713aSLionel Sambuc
~MultiplexConsumer()216*0a6a1f1dSLionel Sambuc MultiplexConsumer::~MultiplexConsumer() {}
217f4a2713aSLionel Sambuc
Initialize(ASTContext & Context)218f4a2713aSLionel Sambuc void MultiplexConsumer::Initialize(ASTContext &Context) {
219*0a6a1f1dSLionel Sambuc for (auto &Consumer : Consumers)
220*0a6a1f1dSLionel Sambuc Consumer->Initialize(Context);
221f4a2713aSLionel Sambuc }
222f4a2713aSLionel Sambuc
HandleTopLevelDecl(DeclGroupRef D)223f4a2713aSLionel Sambuc bool MultiplexConsumer::HandleTopLevelDecl(DeclGroupRef D) {
224f4a2713aSLionel Sambuc bool Continue = true;
225*0a6a1f1dSLionel Sambuc for (auto &Consumer : Consumers)
226*0a6a1f1dSLionel Sambuc Continue = Continue && Consumer->HandleTopLevelDecl(D);
227f4a2713aSLionel Sambuc return Continue;
228f4a2713aSLionel Sambuc }
229f4a2713aSLionel Sambuc
HandleInlineMethodDefinition(CXXMethodDecl * D)230*0a6a1f1dSLionel Sambuc void MultiplexConsumer::HandleInlineMethodDefinition(CXXMethodDecl *D) {
231*0a6a1f1dSLionel Sambuc for (auto &Consumer : Consumers)
232*0a6a1f1dSLionel Sambuc Consumer->HandleInlineMethodDefinition(D);
233*0a6a1f1dSLionel Sambuc }
234*0a6a1f1dSLionel Sambuc
HandleCXXStaticMemberVarInstantiation(VarDecl * VD)235f4a2713aSLionel Sambuc void MultiplexConsumer::HandleCXXStaticMemberVarInstantiation(VarDecl *VD) {
236*0a6a1f1dSLionel Sambuc for (auto &Consumer : Consumers)
237*0a6a1f1dSLionel Sambuc Consumer->HandleCXXStaticMemberVarInstantiation(VD);
238f4a2713aSLionel Sambuc }
239f4a2713aSLionel Sambuc
HandleInterestingDecl(DeclGroupRef D)240f4a2713aSLionel Sambuc void MultiplexConsumer::HandleInterestingDecl(DeclGroupRef D) {
241*0a6a1f1dSLionel Sambuc for (auto &Consumer : Consumers)
242*0a6a1f1dSLionel Sambuc Consumer->HandleInterestingDecl(D);
243f4a2713aSLionel Sambuc }
244f4a2713aSLionel Sambuc
HandleTranslationUnit(ASTContext & Ctx)245f4a2713aSLionel Sambuc void MultiplexConsumer::HandleTranslationUnit(ASTContext &Ctx) {
246*0a6a1f1dSLionel Sambuc for (auto &Consumer : Consumers)
247*0a6a1f1dSLionel Sambuc Consumer->HandleTranslationUnit(Ctx);
248f4a2713aSLionel Sambuc }
249f4a2713aSLionel Sambuc
HandleTagDeclDefinition(TagDecl * D)250f4a2713aSLionel Sambuc void MultiplexConsumer::HandleTagDeclDefinition(TagDecl *D) {
251*0a6a1f1dSLionel Sambuc for (auto &Consumer : Consumers)
252*0a6a1f1dSLionel Sambuc Consumer->HandleTagDeclDefinition(D);
253*0a6a1f1dSLionel Sambuc }
254*0a6a1f1dSLionel Sambuc
HandleTagDeclRequiredDefinition(const TagDecl * D)255*0a6a1f1dSLionel Sambuc void MultiplexConsumer::HandleTagDeclRequiredDefinition(const TagDecl *D) {
256*0a6a1f1dSLionel Sambuc for (auto &Consumer : Consumers)
257*0a6a1f1dSLionel Sambuc Consumer->HandleTagDeclRequiredDefinition(D);
258f4a2713aSLionel Sambuc }
259f4a2713aSLionel Sambuc
HandleCXXImplicitFunctionInstantiation(FunctionDecl * D)260f4a2713aSLionel Sambuc void MultiplexConsumer::HandleCXXImplicitFunctionInstantiation(FunctionDecl *D){
261*0a6a1f1dSLionel Sambuc for (auto &Consumer : Consumers)
262*0a6a1f1dSLionel Sambuc Consumer->HandleCXXImplicitFunctionInstantiation(D);
263f4a2713aSLionel Sambuc }
264f4a2713aSLionel Sambuc
HandleTopLevelDeclInObjCContainer(DeclGroupRef D)265f4a2713aSLionel Sambuc void MultiplexConsumer::HandleTopLevelDeclInObjCContainer(DeclGroupRef D) {
266*0a6a1f1dSLionel Sambuc for (auto &Consumer : Consumers)
267*0a6a1f1dSLionel Sambuc Consumer->HandleTopLevelDeclInObjCContainer(D);
268*0a6a1f1dSLionel Sambuc }
269*0a6a1f1dSLionel Sambuc
HandleImplicitImportDecl(ImportDecl * D)270*0a6a1f1dSLionel Sambuc void MultiplexConsumer::HandleImplicitImportDecl(ImportDecl *D) {
271*0a6a1f1dSLionel Sambuc for (auto &Consumer : Consumers)
272*0a6a1f1dSLionel Sambuc Consumer->HandleImplicitImportDecl(D);
273*0a6a1f1dSLionel Sambuc }
274*0a6a1f1dSLionel Sambuc
HandleLinkerOptionPragma(llvm::StringRef Opts)275*0a6a1f1dSLionel Sambuc void MultiplexConsumer::HandleLinkerOptionPragma(llvm::StringRef Opts) {
276*0a6a1f1dSLionel Sambuc for (auto &Consumer : Consumers)
277*0a6a1f1dSLionel Sambuc Consumer->HandleLinkerOptionPragma(Opts);
278*0a6a1f1dSLionel Sambuc }
279*0a6a1f1dSLionel Sambuc
HandleDetectMismatch(llvm::StringRef Name,llvm::StringRef Value)280*0a6a1f1dSLionel Sambuc void MultiplexConsumer::HandleDetectMismatch(llvm::StringRef Name, llvm::StringRef Value) {
281*0a6a1f1dSLionel Sambuc for (auto &Consumer : Consumers)
282*0a6a1f1dSLionel Sambuc Consumer->HandleDetectMismatch(Name, Value);
283*0a6a1f1dSLionel Sambuc }
284*0a6a1f1dSLionel Sambuc
HandleDependentLibrary(llvm::StringRef Lib)285*0a6a1f1dSLionel Sambuc void MultiplexConsumer::HandleDependentLibrary(llvm::StringRef Lib) {
286*0a6a1f1dSLionel Sambuc for (auto &Consumer : Consumers)
287*0a6a1f1dSLionel Sambuc Consumer->HandleDependentLibrary(Lib);
288f4a2713aSLionel Sambuc }
289f4a2713aSLionel Sambuc
CompleteTentativeDefinition(VarDecl * D)290f4a2713aSLionel Sambuc void MultiplexConsumer::CompleteTentativeDefinition(VarDecl *D) {
291*0a6a1f1dSLionel Sambuc for (auto &Consumer : Consumers)
292*0a6a1f1dSLionel Sambuc Consumer->CompleteTentativeDefinition(D);
293f4a2713aSLionel Sambuc }
294f4a2713aSLionel Sambuc
HandleVTable(CXXRecordDecl * RD,bool DefinitionRequired)295f4a2713aSLionel Sambuc void MultiplexConsumer::HandleVTable(
296f4a2713aSLionel Sambuc CXXRecordDecl *RD, bool DefinitionRequired) {
297*0a6a1f1dSLionel Sambuc for (auto &Consumer : Consumers)
298*0a6a1f1dSLionel Sambuc Consumer->HandleVTable(RD, DefinitionRequired);
299f4a2713aSLionel Sambuc }
300f4a2713aSLionel Sambuc
GetASTMutationListener()301f4a2713aSLionel Sambuc ASTMutationListener *MultiplexConsumer::GetASTMutationListener() {
302f4a2713aSLionel Sambuc return MutationListener.get();
303f4a2713aSLionel Sambuc }
304f4a2713aSLionel Sambuc
GetASTDeserializationListener()305f4a2713aSLionel Sambuc ASTDeserializationListener *MultiplexConsumer::GetASTDeserializationListener() {
306f4a2713aSLionel Sambuc return DeserializationListener.get();
307f4a2713aSLionel Sambuc }
308f4a2713aSLionel Sambuc
PrintStats()309f4a2713aSLionel Sambuc void MultiplexConsumer::PrintStats() {
310*0a6a1f1dSLionel Sambuc for (auto &Consumer : Consumers)
311*0a6a1f1dSLionel Sambuc Consumer->PrintStats();
312f4a2713aSLionel Sambuc }
313f4a2713aSLionel Sambuc
InitializeSema(Sema & S)314f4a2713aSLionel Sambuc void MultiplexConsumer::InitializeSema(Sema &S) {
315*0a6a1f1dSLionel Sambuc for (auto &Consumer : Consumers)
316*0a6a1f1dSLionel Sambuc if (SemaConsumer *SC = dyn_cast<SemaConsumer>(Consumer.get()))
317f4a2713aSLionel Sambuc SC->InitializeSema(S);
318f4a2713aSLionel Sambuc }
319f4a2713aSLionel Sambuc
ForgetSema()320f4a2713aSLionel Sambuc void MultiplexConsumer::ForgetSema() {
321*0a6a1f1dSLionel Sambuc for (auto &Consumer : Consumers)
322*0a6a1f1dSLionel Sambuc if (SemaConsumer *SC = dyn_cast<SemaConsumer>(Consumer.get()))
323f4a2713aSLionel Sambuc SC->ForgetSema();
324f4a2713aSLionel Sambuc }
325