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