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