Go to the documentation of this file.
19 using namespace clang;
24 const std::vector<ASTDeserializationListener*>& L)
30 for (
size_t i = 0, e = Listeners.size(); i != e; ++i)
31 Listeners[i]->ReaderInitialized(Reader);
36 for (
size_t i = 0, e = Listeners.size(); i != e; ++i)
37 Listeners[i]->IdentifierRead(
ID, II);
42 for (
auto &Listener : Listeners)
43 Listener->MacroRead(
ID, MI);
48 for (
size_t i = 0, e = Listeners.size(); i != e; ++i)
49 Listeners[i]->TypeRead(Idx, T);
54 for (
size_t i = 0, e = Listeners.size(); i != e; ++i)
55 Listeners[i]->DeclRead(
ID, D);
60 for (
size_t i = 0, e = Listeners.size(); i != e; ++i)
61 Listeners[i]->SelectorRead(
ID, Sel);
66 for (
size_t i = 0, e = Listeners.size(); i != e; ++i)
67 Listeners[i]->MacroDefinitionRead(
ID, MD);
72 for (
auto &Listener : Listeners)
73 Listener->ModuleRead(
ID, Mod);
78 for (
auto &Listener : Listeners)
79 Listener->ModuleImportRead(
ID, ImportLoc);
101 Expr *ThisArg)
override;
120 std::vector<ASTMutationListener*> Listeners;
125 : Listeners(L.begin(), L.end()) {
129 for (
size_t i = 0, e = Listeners.size(); i != e; ++i)
130 Listeners[i]->CompletedTagDefinition(D);
135 for (
size_t i = 0, e = Listeners.size(); i != e; ++i)
136 Listeners[i]->AddedVisibleDecl(DC, D);
141 for (
size_t i = 0, e = Listeners.size(); i != e; ++i)
142 Listeners[i]->AddedCXXImplicitMember(RD, D);
146 for (
size_t i = 0, e = Listeners.size(); i != e; ++i)
147 Listeners[i]->AddedCXXTemplateSpecialization(TD, D);
151 for (
size_t i = 0, e = Listeners.size(); i != e; ++i)
152 Listeners[i]->AddedCXXTemplateSpecialization(TD, D);
156 for (
size_t i = 0, e = Listeners.size(); i != e; ++i)
157 Listeners[i]->AddedCXXTemplateSpecialization(TD, D);
161 for (
auto &Listener : Listeners)
162 Listener->ResolvedExceptionSpec(FD);
166 for (
size_t i = 0, e = Listeners.size(); i != e; ++i)
167 Listeners[i]->DeducedReturnType(FD, ReturnType);
171 for (
auto *L : Listeners)
172 L->ResolvedOperatorDelete(DD,
Delete, ThisArg);
176 for (
size_t i = 0, e = Listeners.size(); i != e; ++i)
177 Listeners[i]->CompletedImplicitDefinition(D);
180 for (
size_t i = 0, e = Listeners.size(); i != e; ++i)
181 Listeners[i]->InstantiationRequested(D);
185 for (
size_t i = 0, e = Listeners.size(); i != e; ++i)
186 Listeners[i]->VariableDefinitionInstantiated(D);
190 for (
auto &Listener : Listeners)
191 Listener->FunctionDefinitionInstantiated(D);
195 for (
size_t i = 0, e = Listeners.size(); i != e; ++i)
196 Listeners[i]->DefaultArgumentInstantiated(D);
200 for (
size_t i = 0, e = Listeners.size(); i != e; ++i)
201 Listeners[i]->DefaultMemberInitializerInstantiated(D);
206 for (
size_t i = 0, e = Listeners.size(); i != e; ++i)
207 Listeners[i]->AddedObjCCategoryToInterface(CatD, IFD);
210 for (
size_t i = 0, e = Listeners.size(); i != e; ++i)
211 Listeners[i]->DeclarationMarkedUsed(D);
215 for (
size_t i = 0, e = Listeners.size(); i != e; ++i)
216 Listeners[i]->DeclarationMarkedOpenMPThreadPrivate(D);
221 L->DeclarationMarkedOpenMPAllocate(D, A);
225 for (
auto *L : Listeners)
226 L->DeclarationMarkedOpenMPDeclareTarget(D,
Attr);
230 for (
auto *L : Listeners)
231 L->RedefinedHiddenDefinition(D, M);
237 for (
auto *L : Listeners)
238 L->AddedAttributeToRecord(
Attr, Record);
243 MultiplexConsumer::MultiplexConsumer(
244 std::vector<std::unique_ptr<ASTConsumer>>
C)
245 : Consumers(
std::move(
C)) {
248 std::vector<ASTMutationListener *> mutationListeners;
249 std::vector<ASTDeserializationListener*> serializationListeners;
250 for (
auto &Consumer : Consumers) {
251 if (
auto *mutationListener = Consumer->GetASTMutationListener())
252 mutationListeners.push_back(mutationListener);
253 if (
auto *serializationListener = Consumer->GetASTDeserializationListener())
254 serializationListeners.push_back(serializationListener);
256 if (!mutationListeners.empty()) {
258 std::make_unique<MultiplexASTMutationListener>(mutationListeners);
260 if (!serializationListeners.empty()) {
261 DeserializationListener =
262 std::make_unique<MultiplexASTDeserializationListener>(
263 serializationListeners);
270 for (
auto &Consumer : Consumers)
271 Consumer->Initialize(Context);
275 bool Continue =
true;
276 for (
auto &Consumer : Consumers)
277 Continue = Continue && Consumer->HandleTopLevelDecl(D);
282 for (
auto &Consumer : Consumers)
283 Consumer->HandleInlineFunctionDefinition(D);
287 for (
auto &Consumer : Consumers)
288 Consumer->HandleCXXStaticMemberVarInstantiation(VD);
292 for (
auto &Consumer : Consumers)
293 Consumer->HandleInterestingDecl(D);
297 for (
auto &Consumer : Consumers)
298 Consumer->HandleTranslationUnit(Ctx);
302 for (
auto &Consumer : Consumers)
303 Consumer->HandleTagDeclDefinition(D);
307 for (
auto &Consumer : Consumers)
308 Consumer->HandleTagDeclRequiredDefinition(D);
312 for (
auto &Consumer : Consumers)
313 Consumer->HandleCXXImplicitFunctionInstantiation(D);
317 for (
auto &Consumer : Consumers)
318 Consumer->HandleTopLevelDeclInObjCContainer(D);
322 for (
auto &Consumer : Consumers)
323 Consumer->HandleImplicitImportDecl(D);
327 for (
auto &Consumer : Consumers)
328 Consumer->CompleteTentativeDefinition(D);
332 for (
auto &Consumer : Consumers)
333 Consumer->CompleteExternalDeclaration(D);
337 for (
auto &Consumer : Consumers)
338 Consumer->AssignInheritanceModel(RD);
342 for (
auto &Consumer : Consumers)
343 Consumer->HandleVTable(RD);
347 return MutationListener.get();
351 return DeserializationListener.get();
355 for (
auto &Consumer : Consumers)
356 Consumer->PrintStats();
361 for (
auto &Consumer : Consumers)
362 Skip = Skip && Consumer->shouldSkipFunctionBody(D);
367 for (
auto &Consumer : Consumers)
368 if (
SemaConsumer *SC = dyn_cast<SemaConsumer>(Consumer.get()))
369 SC->InitializeSema(S);
373 for (
auto &Consumer : Consumers)
374 if (
SemaConsumer *SC = dyn_cast<SemaConsumer>(Consumer.get()))
Represents an ObjC class declaration.
ASTDeserializationListener * GetASTDeserializationListener() override
If the consumer is interested in entities being deserialized from AST files, it should return a point...
void SelectorRead(serialization::SelectorID iD, Selector Sel) override
A selector was read from the AST file.
A type index; the type ID with the qualifier bits removed.
void DefaultArgumentInstantiated(const ParmVarDecl *D) override
A default argument was instantiated.
void AddedVisibleDecl(const DeclContext *DC, const Decl *D) override
A new declaration with name has been added to a DeclContext.
void AddedObjCCategoryToInterface(const ObjCCategoryDecl *CatD, const ObjCInterfaceDecl *IFD) override
A new objc category class was added for an interface.
bool shouldSkipFunctionBody(Decl *D) override
This callback is called for each function if the Parser was initialized with SkipFunctionBodies set t...
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
void HandleInterestingDecl(DeclGroupRef D) override
HandleInterestingDecl - Handle the specified interesting declaration.
Encodes a location in the source.
void InstantiationRequested(const ValueDecl *D) override
The instantiation of a templated function or variable was requested.
void HandleTagDeclDefinition(TagDecl *D) override
HandleTagDeclDefinition - This callback is invoked each time a TagDecl (e.g.
This represents a decl that may have a name.
uint32_t IdentID
An ID number that refers to an identifier in an AST file.
~MultiplexConsumer() override
void TypeRead(serialization::TypeIdx Idx, QualType T) override
A type was deserialized from the AST file.
A (possibly-)qualified type.
void HandleImplicitImportDecl(ImportDecl *D) override
Handle an ImportDecl that was implicitly created due to an inclusion directive.
Represents a member of a struct/union/class.
void ModuleImportRead(serialization::SubmoduleID ID, SourceLocation ImportLoc) override
A module import was read from the AST file.
Represents a parameter to a function.
void MacroDefinitionRead(serialization::PreprocessedEntityID, MacroDefinitionRecord *MD) override
A macro definition was read from the AST file.
void PrintStats() override
PrintStats - If desired, print any statistics.
Encapsulates the data about a macro definition (e.g.
void CompleteTentativeDefinition(VarDecl *D) override
CompleteTentativeDefinition - Callback invoked at the end of a translation unit to notify the consume...
void InitializeSema(Sema &S) override
Initialize the semantic consumer with the Sema instance being used to perform semantic analysis on th...
void FunctionDefinitionInstantiated(const FunctionDecl *D) override
A function template's definition was instantiated.
void DeclRead(serialization::DeclID ID, const Decl *D) override
A decl was deserialized from the AST file.
Represents a variable template specialization, which refers to a variable template with a given set o...
void DeclarationMarkedUsed(const Decl *D) override
A declaration is marked used which was not previously marked used.
uint32_t MacroID
An ID number that refers to a macro in an AST file.
Declaration of a template function.
uint32_t SubmoduleID
An ID number that refers to a submodule in a module file.
void ResolvedExceptionSpec(const FunctionDecl *FD) override
A function's exception specification has been evaluated or instantiated.
void IdentifierRead(serialization::IdentID ID, IdentifierInfo *II) override
An identifier was deserialized from the AST file.
An abstract interface that should be implemented by clients that read ASTs and then require further s...
Describes a module or submodule.
Describes a module import declaration, which makes the contents of the named module visible in the cu...
void DeclarationMarkedOpenMPAllocate(const Decl *D, const Attr *A) override
A declaration is marked as a variable with OpenMP allocator.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
ASTMutationListener * GetASTMutationListener() override
If the consumer is interested in entities getting modified after their initial creation,...
Represents a C++ destructor within a class.
Record the location of a macro definition.
void HandleCXXImplicitFunctionInstantiation(FunctionDecl *D) override
Invoked when a function is implicitly instantiated.
Represents a variable declaration or definition.
Represents the declaration of a struct/union/class/enum.
void ResolvedOperatorDelete(const CXXDestructorDecl *DD, const FunctionDecl *Delete, Expr *ThisArg) override
A virtual destructor's operator delete has been resolved.
void ReaderInitialized(ASTReader *Reader) override
The ASTReader was initialized.
void AddedAttributeToRecord(const Attr *Attr, const RecordDecl *Record) override
An attribute was added to a RecordDecl.
void HandleCXXStaticMemberVarInstantiation(VarDecl *VD) override
HandleCXXStaticMemberVarInstantiation - Tell the consumer that this.
void Initialize(ASTContext &Context) override
Initialize - This is called to initialize the consumer, providing the ASTContext.
uint32_t PreprocessedEntityID
An ID number that refers to an entity in the detailed preprocessing record.
void DeclarationMarkedOpenMPThreadPrivate(const Decl *D) override
A declaration is marked as OpenMP threadprivate which was not previously marked as threadprivate.
ObjCCategoryDecl - Represents a category declaration.
MultiplexASTMutationListener(ArrayRef< ASTMutationListener * > L)
void HandleVTable(CXXRecordDecl *RD) override
Callback involved at the end of a translation unit to notify the consumer that a vtable for the given...
Represents a C++ struct/union/class.
void MacroRead(serialization::MacroID ID, MacroInfo *MI) override
A macro was read from the AST file.
void VariableDefinitionInstantiated(const VarDecl *D) override
A templated variable's definition was implicitly instantiated.
Declaration of a class template.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Decl - This represents one declaration (or definition), e.g.
void DefaultMemberInitializerInstantiated(const FieldDecl *D) override
A default member initializer was instantiated.
Sema - This implements semantic analysis and AST building for C.
void HandleTagDeclRequiredDefinition(const TagDecl *D) override
This callback is invoked the first time each TagDecl is required to be complete.
One of these records is kept for each identifier that is lexed.
void HandleInlineFunctionDefinition(FunctionDecl *D) override
This callback is invoked each time an inline (method or friend) function definition in a class is com...
Reads an AST files chain containing the contents of a translation unit.
void AddedCXXImplicitMember(const CXXRecordDecl *RD, const Decl *D) override
An implicit member was added after the definition was completed.
void ModuleRead(serialization::SubmoduleID ID, Module *Mod) override
A module definition was read from the AST file.
void AddedCXXTemplateSpecialization(const ClassTemplateDecl *TD, const ClassTemplateSpecializationDecl *D) override
A template specialization (or partial one) was added to the template declaration.
Smart pointer class that efficiently represents Objective-C method names.
void HandleTopLevelDeclInObjCContainer(DeclGroupRef D) override
Handle the specified top-level declaration that occurred inside and ObjC container.
bool HandleTopLevelDecl(DeclGroupRef D) override
HandleTopLevelDecl - Handle the specified top-level declaration.
Attr - This represents one attribute.
void DeducedReturnType(const FunctionDecl *FD, QualType ReturnType) override
A function's return type has been deduced.
void CompletedImplicitDefinition(const FunctionDecl *D) override
An implicit member got a definition.
MultiplexASTDeserializationListener(const std::vector< ASTDeserializationListener * > &L)
void CompletedTagDefinition(const TagDecl *D) override
A new TagDecl definition was completed.
void RedefinedHiddenDefinition(const NamedDecl *D, Module *M) override
A definition has been made visible by being redefined locally.
Declaration of a variable template.
This represents one expression.
uint32_t DeclID
An ID number that refers to a declaration in an AST file.
void HandleTranslationUnit(ASTContext &Ctx) override
HandleTranslationUnit - This method is called when the ASTs for entire translation unit have been par...
Represents a class template specialization, which refers to a class template with a given set of temp...
uint32_t SelectorID
An ID number that refers to an ObjC selector in an AST file.
Represents a function declaration or definition.
Represents a struct/union/class.
void CompleteExternalDeclaration(VarDecl *D) override
CompleteExternalDeclaration - Callback invoked at the end of a translation unit to notify the consume...
void DeclarationMarkedOpenMPDeclareTarget(const Decl *D, const Attr *Attr) override
A declaration is marked as OpenMP declaretarget which was not previously marked as declaretarget.
void AssignInheritanceModel(CXXRecordDecl *RD) override
Callback invoked when an MSInheritanceAttr has been attached to a CXXRecordDecl.
void ForgetSema() override
Inform the semantic consumer that Sema is no longer available.