20 using namespace clang;
25 const std::vector<ASTDeserializationListener*>& L)
31 for (
size_t i = 0, e = Listeners.size(); i != e; ++i)
37 for (
size_t i = 0, e = Listeners.size(); i != e; ++i)
43 for (
auto &Listener : Listeners)
44 Listener->MacroRead(ID, MI);
49 for (
size_t i = 0, e = Listeners.size(); i != e; ++i)
55 for (
size_t i = 0, e = Listeners.size(); i != e; ++i)
61 for (
size_t i = 0, e = Listeners.size(); i != e; ++i)
67 for (
size_t i = 0, e = Listeners.size(); i != e; ++i)
73 for (
auto &Listener : Listeners)
74 Listener->ModuleRead(ID, Mod);
83 void CompletedTagDefinition(
const TagDecl *D)
override;
92 void ResolvedExceptionSpec(
const FunctionDecl *FD)
override;
96 Expr *ThisArg)
override;
97 void CompletedImplicitDefinition(
const FunctionDecl *D)
override;
98 void InstantiationRequested(
const ValueDecl *D)
override;
99 void VariableDefinitionInstantiated(
const VarDecl *D)
override;
100 void FunctionDefinitionInstantiated(
const FunctionDecl *D)
override;
101 void DefaultArgumentInstantiated(
const ParmVarDecl *D)
override;
102 void DefaultMemberInitializerInstantiated(
const FieldDecl *D)
override;
105 void DeclarationMarkedUsed(
const Decl *D)
override;
106 void DeclarationMarkedOpenMPThreadPrivate(
const Decl *D)
override;
107 void DeclarationMarkedOpenMPDeclareTarget(
const Decl *D,
109 void RedefinedHiddenDefinition(
const NamedDecl *D,
Module *M)
override;
110 void AddedAttributeToRecord(
const Attr *Attr,
114 std::vector<ASTMutationListener*> Listeners;
119 : Listeners(L.begin(), L.end()) {
123 for (
size_t i = 0, e = Listeners.size(); i != e; ++i)
129 for (
size_t i = 0, e = Listeners.size(); i != e; ++i)
135 for (
size_t i = 0, e = Listeners.size(); i != e; ++i)
140 for (
size_t i = 0, e = Listeners.size(); i != e; ++i)
145 for (
size_t i = 0, e = Listeners.size(); i != e; ++i)
150 for (
size_t i = 0, e = Listeners.size(); i != e; ++i)
155 for (
auto &Listener : Listeners)
156 Listener->ResolvedExceptionSpec(FD);
160 for (
size_t i = 0, e = Listeners.size(); i != e; ++i)
165 for (
auto *L : Listeners)
166 L->ResolvedOperatorDelete(DD, Delete, ThisArg);
170 for (
size_t i = 0, e = Listeners.size(); i != e; ++i)
174 for (
size_t i = 0, e = Listeners.size(); i != e; ++i)
179 for (
size_t i = 0, e = Listeners.size(); i != e; ++i)
184 for (
auto &Listener : Listeners)
185 Listener->FunctionDefinitionInstantiated(D);
189 for (
size_t i = 0, e = Listeners.size(); i != e; ++i)
194 for (
size_t i = 0, e = Listeners.size(); i != e; ++i)
200 for (
size_t i = 0, e = Listeners.size(); i != e; ++i)
204 for (
size_t i = 0, e = Listeners.size(); i != e; ++i)
209 for (
size_t i = 0, e = Listeners.size(); i != e; ++i)
214 for (
auto *L : Listeners)
215 L->DeclarationMarkedOpenMPDeclareTarget(D, Attr);
219 for (
auto *L : Listeners)
220 L->RedefinedHiddenDefinition(D, M);
226 for (
auto *L : Listeners)
227 L->AddedAttributeToRecord(Attr, Record);
233 std::vector<std::unique_ptr<ASTConsumer>>
C)
234 : Consumers(
std::move(
C)), MutationListener(), DeserializationListener() {
237 std::vector<ASTMutationListener*> mutationListeners;
238 std::vector<ASTDeserializationListener*> serializationListeners;
239 for (
auto &Consumer : Consumers) {
240 if (
auto *mutationListener = Consumer->GetASTMutationListener())
241 mutationListeners.push_back(mutationListener);
242 if (
auto *serializationListener = Consumer->GetASTDeserializationListener())
243 serializationListeners.push_back(serializationListener);
245 if (!mutationListeners.empty()) {
247 llvm::make_unique<MultiplexASTMutationListener>(mutationListeners);
249 if (!serializationListeners.empty()) {
250 DeserializationListener =
251 llvm::make_unique<MultiplexASTDeserializationListener>(
252 serializationListeners);
259 for (
auto &Consumer : Consumers)
260 Consumer->Initialize(Context);
264 bool Continue =
true;
265 for (
auto &Consumer : Consumers)
266 Continue = Continue && Consumer->HandleTopLevelDecl(D);
271 for (
auto &Consumer : Consumers)
272 Consumer->HandleInlineFunctionDefinition(D);
276 for (
auto &Consumer : Consumers)
277 Consumer->HandleCXXStaticMemberVarInstantiation(VD);
281 for (
auto &Consumer : Consumers)
282 Consumer->HandleInterestingDecl(D);
286 for (
auto &Consumer : Consumers)
287 Consumer->HandleTranslationUnit(Ctx);
291 for (
auto &Consumer : Consumers)
292 Consumer->HandleTagDeclDefinition(D);
296 for (
auto &Consumer : Consumers)
297 Consumer->HandleTagDeclRequiredDefinition(D);
301 for (
auto &Consumer : Consumers)
302 Consumer->HandleCXXImplicitFunctionInstantiation(D);
306 for (
auto &Consumer : Consumers)
307 Consumer->HandleTopLevelDeclInObjCContainer(D);
311 for (
auto &Consumer : Consumers)
312 Consumer->HandleImplicitImportDecl(D);
316 for (
auto &Consumer : Consumers)
317 Consumer->CompleteTentativeDefinition(D);
321 for (
auto &Consumer : Consumers)
322 Consumer->AssignInheritanceModel(RD);
326 for (
auto &Consumer : Consumers)
327 Consumer->HandleVTable(RD);
331 return MutationListener.get();
335 return DeserializationListener.get();
339 for (
auto &Consumer : Consumers)
340 Consumer->PrintStats();
345 for (
auto &Consumer : Consumers)
346 Skip = Skip && Consumer->shouldSkipFunctionBody(D);
351 for (
auto &Consumer : Consumers)
352 if (
SemaConsumer *SC = dyn_cast<SemaConsumer>(Consumer.get()))
353 SC->InitializeSema(S);
357 for (
auto &Consumer : Consumers)
358 if (
SemaConsumer *SC = dyn_cast<SemaConsumer>(Consumer.get()))
MultiplexASTMutationListener(ArrayRef< ASTMutationListener *> L)
void AddedCXXImplicitMember(const CXXRecordDecl *RD, const Decl *D) override
An implicit member was added after the definition was completed.
Represents a function declaration or definition.
void DeclarationMarkedUsed(const Decl *D) override
A declaration is marked used which was not previously marked used.
ASTMutationListener * GetASTMutationListener() override
If the consumer is interested in entities getting modified after their initial creation, it should return a pointer to an ASTMutationListener here.
void CompletedImplicitDefinition(const FunctionDecl *D) override
An implicit member got a definition.
Smart pointer class that efficiently represents Objective-C method names.
void SelectorRead(serialization::SelectorID iD, Selector Sel) override
A selector was read from the AST file.
void HandleTopLevelDeclInObjCContainer(DeclGroupRef D) override
Handle the specified top-level declaration that occurred inside and ObjC container.
A (possibly-)qualified type.
void TypeRead(serialization::TypeIdx Idx, QualType T) override
A type was deserialized from the AST file.
void ResolvedExceptionSpec(const FunctionDecl *FD) override
A function's exception specification has been evaluated or instantiated.
void VariableDefinitionInstantiated(const VarDecl *D) override
A templated variable's definition was implicitly instantiated.
Decl - This represents one declaration (or definition), e.g.
void HandleInlineFunctionDefinition(FunctionDecl *D) override
This callback is invoked each time an inline (method or friend) function definition in a class is com...
void HandleVTable(CXXRecordDecl *RD) override
Callback involved at the end of a translation unit to notify the consumer that a vtable for the given...
Declaration of a variable template.
void DeclRead(serialization::DeclID ID, const Decl *D) override
A decl was deserialized from the AST file.
Represents a variable declaration or definition.
Represents a variable template specialization, which refers to a variable template with a given set o...
void MacroDefinitionRead(serialization::PreprocessedEntityID, MacroDefinitionRecord *MD) override
A macro definition was read from the AST file.
void CompleteTentativeDefinition(VarDecl *D) override
CompleteTentativeDefinition - Callback invoked at the end of a translation unit to notify the consume...
Represents a parameter to a function.
Represents a struct/union/class.
Represents a class template specialization, which refers to a class template with a given set of temp...
One of these records is kept for each identifier that is lexed.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Record the location of a macro definition.
Represents a member of a struct/union/class.
void ResolvedOperatorDelete(const CXXDestructorDecl *DD, const FunctionDecl *Delete, Expr *ThisArg) override
A virtual destructor's operator delete has been resolved.
void PrintStats() override
PrintStats - If desired, print any statistics.
uint32_t MacroID
An ID number that refers to a macro in an AST file.
void DeclarationMarkedOpenMPThreadPrivate(const Decl *D) override
A declaration is marked as OpenMP threadprivate which was not previously marked as threadprivate...
Describes a module or submodule.
An abstract interface that should be implemented by clients that read ASTs and then require further s...
bool HandleTopLevelDecl(DeclGroupRef D) override
HandleTopLevelDecl - Handle the specified top-level declaration.
MultiplexConsumer(std::vector< std::unique_ptr< ASTConsumer >> C)
void AddedAttributeToRecord(const Attr *Attr, const RecordDecl *Record) override
An attribute was added to a RecordDecl.
void DefaultArgumentInstantiated(const ParmVarDecl *D) override
A default argument was instantiated.
void HandleTagDeclRequiredDefinition(const TagDecl *D) override
This callback is invoked the first time each TagDecl is required to be complete.
Represents an ObjC class declaration.
void ReaderInitialized(ASTReader *Reader) override
The ASTReader was initialized.
Sema - This implements semantic analysis and AST building for C.
~MultiplexConsumer() override
void Initialize(ASTContext &Context) override
Initialize - This is called to initialize the consumer, providing the ASTContext. ...
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Expr - This represents one expression.
void AddedCXXTemplateSpecialization(const ClassTemplateDecl *TD, const ClassTemplateSpecializationDecl *D) override
A template specialization (or partial one) was added to the template declaration. ...
void FunctionDefinitionInstantiated(const FunctionDecl *D) override
A function template's definition was instantiated.
Represents a C++ destructor within a class.
void HandleTagDeclDefinition(TagDecl *D) override
HandleTagDeclDefinition - This callback is invoked each time a TagDecl (e.g.
void DefaultMemberInitializerInstantiated(const FieldDecl *D) override
A default member initializer was instantiated.
void DeducedReturnType(const FunctionDecl *FD, QualType ReturnType) override
A function's return type has been deduced.
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
void HandleInterestingDecl(DeclGroupRef D) override
HandleInterestingDecl - Handle the specified interesting declaration.
void IdentifierRead(serialization::IdentID ID, IdentifierInfo *II) override
An identifier was deserialized from the AST file.
void DeclarationMarkedOpenMPDeclareTarget(const Decl *D, const Attr *Attr) override
A declaration is marked as OpenMP declaretarget which was not previously marked as declaretarget...
void CompletedTagDefinition(const TagDecl *D) override
A new TagDecl definition was completed.
void AssignInheritanceModel(CXXRecordDecl *RD) override
Callback invoked when an MSInheritanceAttr has been attached to a CXXRecordDecl.
uint32_t SubmoduleID
An ID number that refers to a submodule in a module file.
void HandleCXXImplicitFunctionInstantiation(FunctionDecl *D) override
Invoked when a function is implicitly instantiated.
void ModuleRead(serialization::SubmoduleID ID, Module *Mod) override
A module definition was read from the AST file.
Represents the declaration of a struct/union/class/enum.
ObjCCategoryDecl - Represents a category declaration.
void AddedVisibleDecl(const DeclContext *DC, const Decl *D) override
A new declaration with name has been added to a DeclContext.
void HandleImplicitImportDecl(ImportDecl *D) override
Handle an ImportDecl that was implicitly created due to an inclusion directive.
uint32_t PreprocessedEntityID
An ID number that refers to an entity in the detailed preprocessing record.
void ForgetSema() override
Inform the semantic consumer that Sema is no longer available.
Describes a module import declaration, which makes the contents of the named module visible in the cu...
uint32_t SelectorID
An ID number that refers to an ObjC selector in an AST file.
Dataflow Directional Tag Classes.
void InitializeSema(Sema &S) override
Initialize the semantic consumer with the Sema instance being used to perform semantic analysis on th...
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Reads an AST files chain containing the contents of a translation unit.
uint32_t DeclID
An ID number that refers to a declaration in an AST file.
void InstantiationRequested(const ValueDecl *D) override
The instantiation of a templated function or variable was requested.
Encapsulates the data about a macro definition (e.g.
uint32_t IdentID
An ID number that refers to an identifier in an AST file.
MultiplexASTDeserializationListener(const std::vector< ASTDeserializationListener *> &L)
Represents a C++ struct/union/class.
void MacroRead(serialization::MacroID ID, MacroInfo *MI) override
A macro was read from the AST file.
Declaration of a class template.
void HandleTranslationUnit(ASTContext &Ctx) override
HandleTranslationUnit - This method is called when the ASTs for entire translation unit have been par...
ASTDeserializationListener * GetASTDeserializationListener() override
If the consumer is interested in entities being deserialized from AST files, it should return a point...
void AddedObjCCategoryToInterface(const ObjCCategoryDecl *CatD, const ObjCInterfaceDecl *IFD) override
A new objc category class was added for an interface.
This represents a decl that may have a name.
bool shouldSkipFunctionBody(Decl *D) override
This callback is called for each function if the Parser was initialized with SkipFunctionBodies set t...
Declaration of a template function.
A type index; the type ID with the qualifier bits removed.
Attr - This represents one attribute.
void HandleCXXStaticMemberVarInstantiation(VarDecl *VD) override
HandleCXXStaticMemberVarInstantiation - Tell the consumer that this.
void RedefinedHiddenDefinition(const NamedDecl *D, Module *M) override
A definition has been made visible by being redefined locally.