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; |
John McCall | 32791cc | 2016-01-06 22:34:54 +0000 | [diff] [blame] | 122 | void DefaultArgumentInstantiated(const ParmVarDecl *D) override; |
Craig Topper | afa7cb3 | 2014-03-13 06:07:04 +0000 | [diff] [blame] | 123 | void AddedObjCCategoryToInterface(const ObjCCategoryDecl *CatD, |
| 124 | const ObjCInterfaceDecl *IFD) override; |
Adrian Prantl | 5578e44 | 2015-06-18 16:41:53 +0000 | [diff] [blame] | 125 | void FunctionDefinitionInstantiated(const FunctionDecl *D) override; |
Craig Topper | a798a9d | 2014-03-02 09:32:10 +0000 | [diff] [blame] | 126 | void DeclarationMarkedUsed(const Decl *D) override; |
Alexey Bataev | 9772000 | 2014-11-11 04:05:39 +0000 | [diff] [blame] | 127 | void DeclarationMarkedOpenMPThreadPrivate(const Decl *D) override; |
Dmitry Polukhin | d69b505 | 2016-05-09 14:59:13 +0000 | [diff] [blame] | 128 | void DeclarationMarkedOpenMPDeclareTarget(const Decl *D, |
| 129 | const Attr *Attr) 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 | } |
John McCall | 32791cc | 2016-01-06 22:34:54 +0000 | [diff] [blame] | 199 | void MultiplexASTMutationListener::DefaultArgumentInstantiated( |
| 200 | const ParmVarDecl *D) { |
| 201 | for (size_t i = 0, e = Listeners.size(); i != e; ++i) |
| 202 | Listeners[i]->DefaultArgumentInstantiated(D); |
| 203 | } |
Argyrios Kyrtzidis | 9262278 | 2012-02-10 20:10:36 +0000 | [diff] [blame] | 204 | void MultiplexASTMutationListener::AddedObjCCategoryToInterface( |
| 205 | const ObjCCategoryDecl *CatD, |
| 206 | const ObjCInterfaceDecl *IFD) { |
| 207 | for (size_t i = 0, e = Listeners.size(); i != e; ++i) |
| 208 | Listeners[i]->AddedObjCCategoryToInterface(CatD, IFD); |
| 209 | } |
Adrian Prantl | 5578e44 | 2015-06-18 16:41:53 +0000 | [diff] [blame] | 210 | void MultiplexASTMutationListener::FunctionDefinitionInstantiated( |
| 211 | const FunctionDecl *D) { |
| 212 | for (auto &Listener : Listeners) |
| 213 | Listener->FunctionDefinitionInstantiated(D); |
| 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 | } |
Dmitry Polukhin | 0b0da29 | 2016-04-06 11:38:59 +0000 | [diff] [blame] | 224 | void MultiplexASTMutationListener::DeclarationMarkedOpenMPDeclareTarget( |
Dmitry Polukhin | d69b505 | 2016-05-09 14:59:13 +0000 | [diff] [blame] | 225 | const Decl *D, const Attr *Attr) { |
Dmitry Polukhin | 0b0da29 | 2016-04-06 11:38:59 +0000 | [diff] [blame] | 226 | for (auto *L : Listeners) |
Dmitry Polukhin | d69b505 | 2016-05-09 14:59:13 +0000 | [diff] [blame] | 227 | L->DeclarationMarkedOpenMPDeclareTarget(D, Attr); |
Dmitry Polukhin | 0b0da29 | 2016-04-06 11:38:59 +0000 | [diff] [blame] | 228 | } |
Richard Smith | 4caa449 | 2015-05-15 02:34:32 +0000 | [diff] [blame] | 229 | void MultiplexASTMutationListener::RedefinedHiddenDefinition(const NamedDecl *D, |
| 230 | Module *M) { |
Richard Smith | 65ebb4a | 2015-03-26 04:09:53 +0000 | [diff] [blame] | 231 | for (auto *L : Listeners) |
Richard Smith | 4caa449 | 2015-05-15 02:34:32 +0000 | [diff] [blame] | 232 | L->RedefinedHiddenDefinition(D, M); |
Richard Smith | 65ebb4a | 2015-03-26 04:09:53 +0000 | [diff] [blame] | 233 | } |
Alex Denisov | fde6495 | 2015-06-26 05:28:36 +0000 | [diff] [blame] | 234 | |
| 235 | void MultiplexASTMutationListener::AddedAttributeToRecord( |
| 236 | const Attr *Attr, |
| 237 | const RecordDecl *Record) { |
| 238 | for (auto *L : Listeners) |
| 239 | L->AddedAttributeToRecord(Attr, Record); |
| 240 | } |
Nico Weber | 2992efa | 2011-01-25 20:34:14 +0000 | [diff] [blame] | 241 | |
| 242 | } // end namespace clang |
| 243 | |
David Blaikie | 6beb6aa | 2014-08-10 19:56:51 +0000 | [diff] [blame] | 244 | MultiplexConsumer::MultiplexConsumer( |
| 245 | std::vector<std::unique_ptr<ASTConsumer>> C) |
| 246 | : Consumers(std::move(C)), MutationListener(), DeserializationListener() { |
Nico Weber | 2992efa | 2011-01-25 20:34:14 +0000 | [diff] [blame] | 247 | // Collect the mutation listeners and deserialization listeners of all |
| 248 | // children, and create a multiplex listener each if so. |
| 249 | std::vector<ASTMutationListener*> mutationListeners; |
| 250 | std::vector<ASTDeserializationListener*> serializationListeners; |
David Blaikie | 6beb6aa | 2014-08-10 19:56:51 +0000 | [diff] [blame] | 251 | for (auto &Consumer : Consumers) { |
| 252 | if (auto *mutationListener = Consumer->GetASTMutationListener()) |
Nico Weber | 2992efa | 2011-01-25 20:34:14 +0000 | [diff] [blame] | 253 | mutationListeners.push_back(mutationListener); |
David Blaikie | 6beb6aa | 2014-08-10 19:56:51 +0000 | [diff] [blame] | 254 | if (auto *serializationListener = Consumer->GetASTDeserializationListener()) |
Nico Weber | 2992efa | 2011-01-25 20:34:14 +0000 | [diff] [blame] | 255 | serializationListeners.push_back(serializationListener); |
| 256 | } |
David Blaikie | 6beb6aa | 2014-08-10 19:56:51 +0000 | [diff] [blame] | 257 | if (!mutationListeners.empty()) { |
| 258 | MutationListener = |
| 259 | llvm::make_unique<MultiplexASTMutationListener>(mutationListeners); |
Nico Weber | 2992efa | 2011-01-25 20:34:14 +0000 | [diff] [blame] | 260 | } |
David Blaikie | 6beb6aa | 2014-08-10 19:56:51 +0000 | [diff] [blame] | 261 | if (!serializationListeners.empty()) { |
| 262 | DeserializationListener = |
| 263 | llvm::make_unique<MultiplexASTDeserializationListener>( |
| 264 | serializationListeners); |
Nico Weber | 2992efa | 2011-01-25 20:34:14 +0000 | [diff] [blame] | 265 | } |
| 266 | } |
| 267 | |
Angel Garcia Gomez | 637d1e6 | 2015-10-20 13:23:58 +0000 | [diff] [blame] | 268 | MultiplexConsumer::~MultiplexConsumer() {} |
Nico Weber | 2992efa | 2011-01-25 20:34:14 +0000 | [diff] [blame] | 269 | |
| 270 | void MultiplexConsumer::Initialize(ASTContext &Context) { |
David Blaikie | 6beb6aa | 2014-08-10 19:56:51 +0000 | [diff] [blame] | 271 | for (auto &Consumer : Consumers) |
| 272 | Consumer->Initialize(Context); |
Nico Weber | 2992efa | 2011-01-25 20:34:14 +0000 | [diff] [blame] | 273 | } |
| 274 | |
Argyrios Kyrtzidis | 841dd88 | 2011-11-18 00:26:59 +0000 | [diff] [blame] | 275 | bool MultiplexConsumer::HandleTopLevelDecl(DeclGroupRef D) { |
Argyrios Kyrtzidis | b11f5a4 | 2011-11-28 04:56:00 +0000 | [diff] [blame] | 276 | bool Continue = true; |
David Blaikie | 6beb6aa | 2014-08-10 19:56:51 +0000 | [diff] [blame] | 277 | for (auto &Consumer : Consumers) |
| 278 | Continue = Continue && Consumer->HandleTopLevelDecl(D); |
Argyrios Kyrtzidis | b11f5a4 | 2011-11-28 04:56:00 +0000 | [diff] [blame] | 279 | return Continue; |
Nico Weber | 2992efa | 2011-01-25 20:34:14 +0000 | [diff] [blame] | 280 | } |
| 281 | |
Stephan Bergmann | 17d7d14 | 2016-03-30 06:27:31 +0000 | [diff] [blame] | 282 | void MultiplexConsumer::HandleInlineFunctionDefinition(FunctionDecl *D) { |
David Blaikie | 6beb6aa | 2014-08-10 19:56:51 +0000 | [diff] [blame] | 283 | for (auto &Consumer : Consumers) |
Stephan Bergmann | 17d7d14 | 2016-03-30 06:27:31 +0000 | [diff] [blame] | 284 | Consumer->HandleInlineFunctionDefinition(D); |
Hans Wennborg | a926d84 | 2014-05-23 20:37:38 +0000 | [diff] [blame] | 285 | } |
| 286 | |
David Blaikie | 6beb6aa | 2014-08-10 19:56:51 +0000 | [diff] [blame] | 287 | void MultiplexConsumer::HandleCXXStaticMemberVarInstantiation(VarDecl *VD) { |
| 288 | for (auto &Consumer : Consumers) |
| 289 | Consumer->HandleCXXStaticMemberVarInstantiation(VD); |
Rafael Espindola | 189fa74 | 2012-03-05 10:54:55 +0000 | [diff] [blame] | 290 | } |
| 291 | |
Nico Weber | 2992efa | 2011-01-25 20:34:14 +0000 | [diff] [blame] | 292 | void MultiplexConsumer::HandleInterestingDecl(DeclGroupRef D) { |
David Blaikie | 6beb6aa | 2014-08-10 19:56:51 +0000 | [diff] [blame] | 293 | for (auto &Consumer : Consumers) |
| 294 | Consumer->HandleInterestingDecl(D); |
Nico Weber | 2992efa | 2011-01-25 20:34:14 +0000 | [diff] [blame] | 295 | } |
| 296 | |
| 297 | void MultiplexConsumer::HandleTranslationUnit(ASTContext &Ctx) { |
David Blaikie | 6beb6aa | 2014-08-10 19:56:51 +0000 | [diff] [blame] | 298 | for (auto &Consumer : Consumers) |
| 299 | Consumer->HandleTranslationUnit(Ctx); |
Nico Weber | 2992efa | 2011-01-25 20:34:14 +0000 | [diff] [blame] | 300 | } |
| 301 | |
| 302 | void MultiplexConsumer::HandleTagDeclDefinition(TagDecl *D) { |
David Blaikie | 6beb6aa | 2014-08-10 19:56:51 +0000 | [diff] [blame] | 303 | for (auto &Consumer : Consumers) |
| 304 | Consumer->HandleTagDeclDefinition(D); |
Nico Weber | 2992efa | 2011-01-25 20:34:14 +0000 | [diff] [blame] | 305 | } |
| 306 | |
David Blaikie | 1326975 | 2014-07-16 23:52:46 +0000 | [diff] [blame] | 307 | void MultiplexConsumer::HandleTagDeclRequiredDefinition(const TagDecl *D) { |
David Blaikie | 6beb6aa | 2014-08-10 19:56:51 +0000 | [diff] [blame] | 308 | for (auto &Consumer : Consumers) |
| 309 | Consumer->HandleTagDeclRequiredDefinition(D); |
David Blaikie | 1326975 | 2014-07-16 23:52:46 +0000 | [diff] [blame] | 310 | } |
| 311 | |
Argyrios Kyrtzidis | e5dc5b3 | 2012-02-10 20:10:44 +0000 | [diff] [blame] | 312 | void MultiplexConsumer::HandleCXXImplicitFunctionInstantiation(FunctionDecl *D){ |
David Blaikie | 6beb6aa | 2014-08-10 19:56:51 +0000 | [diff] [blame] | 313 | for (auto &Consumer : Consumers) |
| 314 | Consumer->HandleCXXImplicitFunctionInstantiation(D); |
Argyrios Kyrtzidis | e5dc5b3 | 2012-02-10 20:10:44 +0000 | [diff] [blame] | 315 | } |
| 316 | |
Argyrios Kyrtzidis | b11f5a4 | 2011-11-28 04:56:00 +0000 | [diff] [blame] | 317 | void MultiplexConsumer::HandleTopLevelDeclInObjCContainer(DeclGroupRef D) { |
David Blaikie | 6beb6aa | 2014-08-10 19:56:51 +0000 | [diff] [blame] | 318 | for (auto &Consumer : Consumers) |
| 319 | Consumer->HandleTopLevelDeclInObjCContainer(D); |
Argyrios Kyrtzidis | b11f5a4 | 2011-11-28 04:56:00 +0000 | [diff] [blame] | 320 | } |
| 321 | |
David Blaikie | 1326975 | 2014-07-16 23:52:46 +0000 | [diff] [blame] | 322 | void MultiplexConsumer::HandleImplicitImportDecl(ImportDecl *D) { |
David Blaikie | 6beb6aa | 2014-08-10 19:56:51 +0000 | [diff] [blame] | 323 | for (auto &Consumer : Consumers) |
| 324 | Consumer->HandleImplicitImportDecl(D); |
David Blaikie | 1326975 | 2014-07-16 23:52:46 +0000 | [diff] [blame] | 325 | } |
| 326 | |
Nico Weber | 2992efa | 2011-01-25 20:34:14 +0000 | [diff] [blame] | 327 | void MultiplexConsumer::CompleteTentativeDefinition(VarDecl *D) { |
David Blaikie | 6beb6aa | 2014-08-10 19:56:51 +0000 | [diff] [blame] | 328 | for (auto &Consumer : Consumers) |
| 329 | Consumer->CompleteTentativeDefinition(D); |
Nico Weber | 2992efa | 2011-01-25 20:34:14 +0000 | [diff] [blame] | 330 | } |
| 331 | |
David Majnemer | 929025d | 2016-01-26 19:30:26 +0000 | [diff] [blame] | 332 | void MultiplexConsumer::AssignInheritanceModel(CXXRecordDecl *RD) { |
| 333 | for (auto &Consumer : Consumers) |
| 334 | Consumer->AssignInheritanceModel(RD); |
| 335 | } |
| 336 | |
Nico Weber | b6a5d05 | 2015-01-15 04:07:35 +0000 | [diff] [blame] | 337 | void MultiplexConsumer::HandleVTable(CXXRecordDecl *RD) { |
David Blaikie | 6beb6aa | 2014-08-10 19:56:51 +0000 | [diff] [blame] | 338 | for (auto &Consumer : Consumers) |
Nico Weber | b6a5d05 | 2015-01-15 04:07:35 +0000 | [diff] [blame] | 339 | Consumer->HandleVTable(RD); |
Nico Weber | 2992efa | 2011-01-25 20:34:14 +0000 | [diff] [blame] | 340 | } |
| 341 | |
| 342 | ASTMutationListener *MultiplexConsumer::GetASTMutationListener() { |
| 343 | return MutationListener.get(); |
| 344 | } |
| 345 | |
| 346 | ASTDeserializationListener *MultiplexConsumer::GetASTDeserializationListener() { |
| 347 | return DeserializationListener.get(); |
| 348 | } |
| 349 | |
| 350 | void MultiplexConsumer::PrintStats() { |
David Blaikie | 6beb6aa | 2014-08-10 19:56:51 +0000 | [diff] [blame] | 351 | for (auto &Consumer : Consumers) |
| 352 | Consumer->PrintStats(); |
Nico Weber | 2992efa | 2011-01-25 20:34:14 +0000 | [diff] [blame] | 353 | } |
| 354 | |
Argyrios Kyrtzidis | 4c3131d | 2016-02-09 19:07:16 +0000 | [diff] [blame] | 355 | bool MultiplexConsumer::shouldSkipFunctionBody(Decl *D) { |
| 356 | bool Skip = true; |
| 357 | for (auto &Consumer : Consumers) |
| 358 | Skip = Skip && Consumer->shouldSkipFunctionBody(D); |
| 359 | return Skip; |
| 360 | } |
| 361 | |
Nico Weber | 2992efa | 2011-01-25 20:34:14 +0000 | [diff] [blame] | 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 | } |