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