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 | a798a9d | 2014-03-02 09:32:10 +0000 | [diff] [blame] | 125 | void DeclarationMarkedUsed(const Decl *D) override; |
Alexey Bataev | 9772000 | 2014-11-11 04:05:39 +0000 | [diff] [blame] | 126 | void DeclarationMarkedOpenMPThreadPrivate(const Decl *D) override; |
Richard Smith | 4caa449 | 2015-05-15 02:34:32 +0000 | [diff] [blame] | 127 | void RedefinedHiddenDefinition(const NamedDecl *D, Module *M) override; |
Alex Denisov | fde6495 | 2015-06-26 05:28:36 +0000 | [diff] [blame] | 128 | void AddedAttributeToRecord(const Attr *Attr, |
| 129 | const RecordDecl *Record) override; |
Eli Friedman | 276dd18 | 2013-09-05 00:02:25 +0000 | [diff] [blame] | 130 | |
Nico Weber | 2992efa | 2011-01-25 20:34:14 +0000 | [diff] [blame] | 131 | private: |
| 132 | std::vector<ASTMutationListener*> Listeners; |
| 133 | }; |
| 134 | |
| 135 | MultiplexASTMutationListener::MultiplexASTMutationListener( |
Argyrios Kyrtzidis | 9e0cd46 | 2012-02-10 20:10:38 +0000 | [diff] [blame] | 136 | ArrayRef<ASTMutationListener*> L) |
| 137 | : Listeners(L.begin(), L.end()) { |
Nico Weber | 2992efa | 2011-01-25 20:34:14 +0000 | [diff] [blame] | 138 | } |
| 139 | |
| 140 | void MultiplexASTMutationListener::CompletedTagDefinition(const TagDecl *D) { |
| 141 | for (size_t i = 0, e = Listeners.size(); i != e; ++i) |
| 142 | Listeners[i]->CompletedTagDefinition(D); |
| 143 | } |
| 144 | |
| 145 | void MultiplexASTMutationListener::AddedVisibleDecl( |
| 146 | const DeclContext *DC, const Decl *D) { |
| 147 | for (size_t i = 0, e = Listeners.size(); i != e; ++i) |
| 148 | Listeners[i]->AddedVisibleDecl(DC, D); |
| 149 | } |
| 150 | |
| 151 | void MultiplexASTMutationListener::AddedCXXImplicitMember( |
| 152 | const CXXRecordDecl *RD, const Decl *D) { |
| 153 | for (size_t i = 0, e = Listeners.size(); i != e; ++i) |
| 154 | Listeners[i]->AddedCXXImplicitMember(RD, D); |
| 155 | } |
| 156 | void MultiplexASTMutationListener::AddedCXXTemplateSpecialization( |
| 157 | const ClassTemplateDecl *TD, const ClassTemplateSpecializationDecl *D) { |
| 158 | for (size_t i = 0, e = Listeners.size(); i != e; ++i) |
| 159 | Listeners[i]->AddedCXXTemplateSpecialization(TD, D); |
| 160 | } |
Sebastian Redl | 9ab988f | 2011-04-14 14:07:59 +0000 | [diff] [blame] | 161 | void MultiplexASTMutationListener::AddedCXXTemplateSpecialization( |
Larisse Voufo | 39a1e50 | 2013-08-06 01:03:05 +0000 | [diff] [blame] | 162 | const VarTemplateDecl *TD, const VarTemplateSpecializationDecl *D) { |
| 163 | for (size_t i = 0, e = Listeners.size(); i != e; ++i) |
| 164 | Listeners[i]->AddedCXXTemplateSpecialization(TD, D); |
| 165 | } |
| 166 | void MultiplexASTMutationListener::AddedCXXTemplateSpecialization( |
Sebastian Redl | 9ab988f | 2011-04-14 14:07:59 +0000 | [diff] [blame] | 167 | const FunctionTemplateDecl *TD, const FunctionDecl *D) { |
| 168 | for (size_t i = 0, e = Listeners.size(); i != e; ++i) |
| 169 | Listeners[i]->AddedCXXTemplateSpecialization(TD, D); |
| 170 | } |
Adrian Prantl | 5578e44 | 2015-06-18 16:41:53 +0000 | [diff] [blame] | 171 | void MultiplexASTMutationListener::ResolvedExceptionSpec( |
| 172 | const FunctionDecl *FD) { |
| 173 | for (auto &Listener : Listeners) |
| 174 | Listener->ResolvedExceptionSpec(FD); |
| 175 | } |
Richard Smith | 1fa5d64 | 2013-05-11 05:45:24 +0000 | [diff] [blame] | 176 | void MultiplexASTMutationListener::DeducedReturnType(const FunctionDecl *FD, |
| 177 | QualType ReturnType) { |
| 178 | for (size_t i = 0, e = Listeners.size(); i != e; ++i) |
| 179 | Listeners[i]->DeducedReturnType(FD, ReturnType); |
| 180 | } |
Richard Smith | f813400 | 2015-03-10 01:41:22 +0000 | [diff] [blame] | 181 | void MultiplexASTMutationListener::ResolvedOperatorDelete( |
| 182 | const CXXDestructorDecl *DD, const FunctionDecl *Delete) { |
| 183 | for (auto *L : Listeners) |
| 184 | L->ResolvedOperatorDelete(DD, Delete); |
| 185 | } |
Sebastian Redl | ab238a7 | 2011-04-24 16:28:06 +0000 | [diff] [blame] | 186 | void MultiplexASTMutationListener::CompletedImplicitDefinition( |
| 187 | const FunctionDecl *D) { |
| 188 | for (size_t i = 0, e = Listeners.size(); i != e; ++i) |
| 189 | Listeners[i]->CompletedImplicitDefinition(D); |
| 190 | } |
Sebastian Redl | 2ac2c72 | 2011-04-29 08:19:30 +0000 | [diff] [blame] | 191 | void MultiplexASTMutationListener::StaticDataMemberInstantiated( |
| 192 | const VarDecl *D) { |
| 193 | for (size_t i = 0, e = Listeners.size(); i != e; ++i) |
| 194 | Listeners[i]->StaticDataMemberInstantiated(D); |
| 195 | } |
Argyrios Kyrtzidis | 9262278 | 2012-02-10 20:10:36 +0000 | [diff] [blame] | 196 | void MultiplexASTMutationListener::AddedObjCCategoryToInterface( |
| 197 | const ObjCCategoryDecl *CatD, |
| 198 | const ObjCInterfaceDecl *IFD) { |
| 199 | for (size_t i = 0, e = Listeners.size(); i != e; ++i) |
| 200 | Listeners[i]->AddedObjCCategoryToInterface(CatD, IFD); |
| 201 | } |
Adrian Prantl | 5578e44 | 2015-06-18 16:41:53 +0000 | [diff] [blame] | 202 | void MultiplexASTMutationListener::FunctionDefinitionInstantiated( |
| 203 | const FunctionDecl *D) { |
| 204 | for (auto &Listener : Listeners) |
| 205 | Listener->FunctionDefinitionInstantiated(D); |
| 206 | } |
Eli Friedman | 276dd18 | 2013-09-05 00:02:25 +0000 | [diff] [blame] | 207 | void MultiplexASTMutationListener::DeclarationMarkedUsed(const Decl *D) { |
| 208 | for (size_t i = 0, e = Listeners.size(); i != e; ++i) |
| 209 | Listeners[i]->DeclarationMarkedUsed(D); |
| 210 | } |
Alexey Bataev | 9772000 | 2014-11-11 04:05:39 +0000 | [diff] [blame] | 211 | void MultiplexASTMutationListener::DeclarationMarkedOpenMPThreadPrivate( |
| 212 | const Decl *D) { |
| 213 | for (size_t i = 0, e = Listeners.size(); i != e; ++i) |
| 214 | Listeners[i]->DeclarationMarkedOpenMPThreadPrivate(D); |
| 215 | } |
Richard Smith | 4caa449 | 2015-05-15 02:34:32 +0000 | [diff] [blame] | 216 | void MultiplexASTMutationListener::RedefinedHiddenDefinition(const NamedDecl *D, |
| 217 | Module *M) { |
Richard Smith | 65ebb4a | 2015-03-26 04:09:53 +0000 | [diff] [blame] | 218 | for (auto *L : Listeners) |
Richard Smith | 4caa449 | 2015-05-15 02:34:32 +0000 | [diff] [blame] | 219 | L->RedefinedHiddenDefinition(D, M); |
Richard Smith | 65ebb4a | 2015-03-26 04:09:53 +0000 | [diff] [blame] | 220 | } |
Alex Denisov | fde6495 | 2015-06-26 05:28:36 +0000 | [diff] [blame] | 221 | |
| 222 | void MultiplexASTMutationListener::AddedAttributeToRecord( |
| 223 | const Attr *Attr, |
| 224 | const RecordDecl *Record) { |
| 225 | for (auto *L : Listeners) |
| 226 | L->AddedAttributeToRecord(Attr, Record); |
| 227 | } |
Nico Weber | 2992efa | 2011-01-25 20:34:14 +0000 | [diff] [blame] | 228 | |
| 229 | } // end namespace clang |
| 230 | |
David Blaikie | 6beb6aa | 2014-08-10 19:56:51 +0000 | [diff] [blame] | 231 | MultiplexConsumer::MultiplexConsumer( |
| 232 | std::vector<std::unique_ptr<ASTConsumer>> C) |
| 233 | : Consumers(std::move(C)), MutationListener(), DeserializationListener() { |
Nico Weber | 2992efa | 2011-01-25 20:34:14 +0000 | [diff] [blame] | 234 | // Collect the mutation listeners and deserialization listeners of all |
| 235 | // children, and create a multiplex listener each if so. |
| 236 | std::vector<ASTMutationListener*> mutationListeners; |
| 237 | std::vector<ASTDeserializationListener*> serializationListeners; |
David Blaikie | 6beb6aa | 2014-08-10 19:56:51 +0000 | [diff] [blame] | 238 | for (auto &Consumer : Consumers) { |
| 239 | if (auto *mutationListener = Consumer->GetASTMutationListener()) |
Nico Weber | 2992efa | 2011-01-25 20:34:14 +0000 | [diff] [blame] | 240 | mutationListeners.push_back(mutationListener); |
David Blaikie | 6beb6aa | 2014-08-10 19:56:51 +0000 | [diff] [blame] | 241 | if (auto *serializationListener = Consumer->GetASTDeserializationListener()) |
Nico Weber | 2992efa | 2011-01-25 20:34:14 +0000 | [diff] [blame] | 242 | serializationListeners.push_back(serializationListener); |
| 243 | } |
David Blaikie | 6beb6aa | 2014-08-10 19:56:51 +0000 | [diff] [blame] | 244 | if (!mutationListeners.empty()) { |
| 245 | MutationListener = |
| 246 | llvm::make_unique<MultiplexASTMutationListener>(mutationListeners); |
Nico Weber | 2992efa | 2011-01-25 20:34:14 +0000 | [diff] [blame] | 247 | } |
David Blaikie | 6beb6aa | 2014-08-10 19:56:51 +0000 | [diff] [blame] | 248 | if (!serializationListeners.empty()) { |
| 249 | DeserializationListener = |
| 250 | llvm::make_unique<MultiplexASTDeserializationListener>( |
| 251 | serializationListeners); |
Nico Weber | 2992efa | 2011-01-25 20:34:14 +0000 | [diff] [blame] | 252 | } |
| 253 | } |
| 254 | |
Angel Garcia Gomez | 637d1e6 | 2015-10-20 13:23:58 +0000 | [diff] [blame] | 255 | MultiplexConsumer::~MultiplexConsumer() {} |
Nico Weber | 2992efa | 2011-01-25 20:34:14 +0000 | [diff] [blame] | 256 | |
| 257 | void MultiplexConsumer::Initialize(ASTContext &Context) { |
David Blaikie | 6beb6aa | 2014-08-10 19:56:51 +0000 | [diff] [blame] | 258 | for (auto &Consumer : Consumers) |
| 259 | Consumer->Initialize(Context); |
Nico Weber | 2992efa | 2011-01-25 20:34:14 +0000 | [diff] [blame] | 260 | } |
| 261 | |
Argyrios Kyrtzidis | 841dd88 | 2011-11-18 00:26:59 +0000 | [diff] [blame] | 262 | bool MultiplexConsumer::HandleTopLevelDecl(DeclGroupRef D) { |
Argyrios Kyrtzidis | b11f5a4 | 2011-11-28 04:56:00 +0000 | [diff] [blame] | 263 | bool Continue = true; |
David Blaikie | 6beb6aa | 2014-08-10 19:56:51 +0000 | [diff] [blame] | 264 | for (auto &Consumer : Consumers) |
| 265 | Continue = Continue && Consumer->HandleTopLevelDecl(D); |
Argyrios Kyrtzidis | b11f5a4 | 2011-11-28 04:56:00 +0000 | [diff] [blame] | 266 | return Continue; |
Nico Weber | 2992efa | 2011-01-25 20:34:14 +0000 | [diff] [blame] | 267 | } |
| 268 | |
Hans Wennborg | a926d84 | 2014-05-23 20:37:38 +0000 | [diff] [blame] | 269 | void MultiplexConsumer::HandleInlineMethodDefinition(CXXMethodDecl *D) { |
David Blaikie | 6beb6aa | 2014-08-10 19:56:51 +0000 | [diff] [blame] | 270 | for (auto &Consumer : Consumers) |
| 271 | Consumer->HandleInlineMethodDefinition(D); |
Hans Wennborg | a926d84 | 2014-05-23 20:37:38 +0000 | [diff] [blame] | 272 | } |
| 273 | |
David Blaikie | 6beb6aa | 2014-08-10 19:56:51 +0000 | [diff] [blame] | 274 | void MultiplexConsumer::HandleCXXStaticMemberVarInstantiation(VarDecl *VD) { |
| 275 | for (auto &Consumer : Consumers) |
| 276 | Consumer->HandleCXXStaticMemberVarInstantiation(VD); |
Rafael Espindola | 189fa74 | 2012-03-05 10:54:55 +0000 | [diff] [blame] | 277 | } |
| 278 | |
Nico Weber | 2992efa | 2011-01-25 20:34:14 +0000 | [diff] [blame] | 279 | void MultiplexConsumer::HandleInterestingDecl(DeclGroupRef D) { |
David Blaikie | 6beb6aa | 2014-08-10 19:56:51 +0000 | [diff] [blame] | 280 | for (auto &Consumer : Consumers) |
| 281 | Consumer->HandleInterestingDecl(D); |
Nico Weber | 2992efa | 2011-01-25 20:34:14 +0000 | [diff] [blame] | 282 | } |
| 283 | |
| 284 | void MultiplexConsumer::HandleTranslationUnit(ASTContext &Ctx) { |
David Blaikie | 6beb6aa | 2014-08-10 19:56:51 +0000 | [diff] [blame] | 285 | for (auto &Consumer : Consumers) |
| 286 | Consumer->HandleTranslationUnit(Ctx); |
Nico Weber | 2992efa | 2011-01-25 20:34:14 +0000 | [diff] [blame] | 287 | } |
| 288 | |
| 289 | void MultiplexConsumer::HandleTagDeclDefinition(TagDecl *D) { |
David Blaikie | 6beb6aa | 2014-08-10 19:56:51 +0000 | [diff] [blame] | 290 | for (auto &Consumer : Consumers) |
| 291 | Consumer->HandleTagDeclDefinition(D); |
Nico Weber | 2992efa | 2011-01-25 20:34:14 +0000 | [diff] [blame] | 292 | } |
| 293 | |
David Blaikie | 1326975 | 2014-07-16 23:52:46 +0000 | [diff] [blame] | 294 | void MultiplexConsumer::HandleTagDeclRequiredDefinition(const TagDecl *D) { |
David Blaikie | 6beb6aa | 2014-08-10 19:56:51 +0000 | [diff] [blame] | 295 | for (auto &Consumer : Consumers) |
| 296 | Consumer->HandleTagDeclRequiredDefinition(D); |
David Blaikie | 1326975 | 2014-07-16 23:52:46 +0000 | [diff] [blame] | 297 | } |
| 298 | |
Argyrios Kyrtzidis | e5dc5b3 | 2012-02-10 20:10:44 +0000 | [diff] [blame] | 299 | void MultiplexConsumer::HandleCXXImplicitFunctionInstantiation(FunctionDecl *D){ |
David Blaikie | 6beb6aa | 2014-08-10 19:56:51 +0000 | [diff] [blame] | 300 | for (auto &Consumer : Consumers) |
| 301 | Consumer->HandleCXXImplicitFunctionInstantiation(D); |
Argyrios Kyrtzidis | e5dc5b3 | 2012-02-10 20:10:44 +0000 | [diff] [blame] | 302 | } |
| 303 | |
Argyrios Kyrtzidis | b11f5a4 | 2011-11-28 04:56:00 +0000 | [diff] [blame] | 304 | void MultiplexConsumer::HandleTopLevelDeclInObjCContainer(DeclGroupRef D) { |
David Blaikie | 6beb6aa | 2014-08-10 19:56:51 +0000 | [diff] [blame] | 305 | for (auto &Consumer : Consumers) |
| 306 | Consumer->HandleTopLevelDeclInObjCContainer(D); |
Argyrios Kyrtzidis | b11f5a4 | 2011-11-28 04:56:00 +0000 | [diff] [blame] | 307 | } |
| 308 | |
David Blaikie | 1326975 | 2014-07-16 23:52:46 +0000 | [diff] [blame] | 309 | void MultiplexConsumer::HandleImplicitImportDecl(ImportDecl *D) { |
David Blaikie | 6beb6aa | 2014-08-10 19:56:51 +0000 | [diff] [blame] | 310 | for (auto &Consumer : Consumers) |
| 311 | Consumer->HandleImplicitImportDecl(D); |
David Blaikie | 1326975 | 2014-07-16 23:52:46 +0000 | [diff] [blame] | 312 | } |
| 313 | |
| 314 | void MultiplexConsumer::HandleLinkerOptionPragma(llvm::StringRef Opts) { |
David Blaikie | 6beb6aa | 2014-08-10 19:56:51 +0000 | [diff] [blame] | 315 | for (auto &Consumer : Consumers) |
| 316 | Consumer->HandleLinkerOptionPragma(Opts); |
David Blaikie | 1326975 | 2014-07-16 23:52:46 +0000 | [diff] [blame] | 317 | } |
| 318 | |
| 319 | void MultiplexConsumer::HandleDetectMismatch(llvm::StringRef Name, llvm::StringRef Value) { |
David Blaikie | 6beb6aa | 2014-08-10 19:56:51 +0000 | [diff] [blame] | 320 | for (auto &Consumer : Consumers) |
| 321 | Consumer->HandleDetectMismatch(Name, Value); |
David Blaikie | 1326975 | 2014-07-16 23:52:46 +0000 | [diff] [blame] | 322 | } |
| 323 | |
| 324 | void MultiplexConsumer::HandleDependentLibrary(llvm::StringRef Lib) { |
David Blaikie | 6beb6aa | 2014-08-10 19:56:51 +0000 | [diff] [blame] | 325 | for (auto &Consumer : Consumers) |
| 326 | Consumer->HandleDependentLibrary(Lib); |
David Blaikie | 1326975 | 2014-07-16 23:52:46 +0000 | [diff] [blame] | 327 | } |
| 328 | |
Nico Weber | 2992efa | 2011-01-25 20:34:14 +0000 | [diff] [blame] | 329 | void MultiplexConsumer::CompleteTentativeDefinition(VarDecl *D) { |
David Blaikie | 6beb6aa | 2014-08-10 19:56:51 +0000 | [diff] [blame] | 330 | for (auto &Consumer : Consumers) |
| 331 | Consumer->CompleteTentativeDefinition(D); |
Nico Weber | 2992efa | 2011-01-25 20:34:14 +0000 | [diff] [blame] | 332 | } |
| 333 | |
Nico Weber | b6a5d05 | 2015-01-15 04:07:35 +0000 | [diff] [blame] | 334 | void MultiplexConsumer::HandleVTable(CXXRecordDecl *RD) { |
David Blaikie | 6beb6aa | 2014-08-10 19:56:51 +0000 | [diff] [blame] | 335 | for (auto &Consumer : Consumers) |
Nico Weber | b6a5d05 | 2015-01-15 04:07:35 +0000 | [diff] [blame] | 336 | Consumer->HandleVTable(RD); |
Nico Weber | 2992efa | 2011-01-25 20:34:14 +0000 | [diff] [blame] | 337 | } |
| 338 | |
| 339 | ASTMutationListener *MultiplexConsumer::GetASTMutationListener() { |
| 340 | return MutationListener.get(); |
| 341 | } |
| 342 | |
| 343 | ASTDeserializationListener *MultiplexConsumer::GetASTDeserializationListener() { |
| 344 | return DeserializationListener.get(); |
| 345 | } |
| 346 | |
| 347 | void MultiplexConsumer::PrintStats() { |
David Blaikie | 6beb6aa | 2014-08-10 19:56:51 +0000 | [diff] [blame] | 348 | for (auto &Consumer : Consumers) |
| 349 | Consumer->PrintStats(); |
Nico Weber | 2992efa | 2011-01-25 20:34:14 +0000 | [diff] [blame] | 350 | } |
| 351 | |
| 352 | void MultiplexConsumer::InitializeSema(Sema &S) { |
David Blaikie | 6beb6aa | 2014-08-10 19:56:51 +0000 | [diff] [blame] | 353 | for (auto &Consumer : Consumers) |
| 354 | if (SemaConsumer *SC = dyn_cast<SemaConsumer>(Consumer.get())) |
Nico Weber | 2992efa | 2011-01-25 20:34:14 +0000 | [diff] [blame] | 355 | SC->InitializeSema(S); |
| 356 | } |
| 357 | |
| 358 | void MultiplexConsumer::ForgetSema() { |
David Blaikie | 6beb6aa | 2014-08-10 19:56:51 +0000 | [diff] [blame] | 359 | for (auto &Consumer : Consumers) |
| 360 | if (SemaConsumer *SC = dyn_cast<SemaConsumer>(Consumer.get())) |
Nico Weber | 2992efa | 2011-01-25 20:34:14 +0000 | [diff] [blame] | 361 | SC->ForgetSema(); |
| 362 | } |