clang 20.0.0git
MultiplexConsumer.h
Go to the documentation of this file.
1//===-- MultiplexConsumer.h - AST Consumer for PCH Generation ---*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file declares the MultiplexConsumer class, which can be used to
10// multiplex ASTConsumer and SemaConsumer messages to many consumers.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CLANG_FRONTEND_MULTIPLEXCONSUMER_H
15#define LLVM_CLANG_FRONTEND_MULTIPLEXCONSUMER_H
16
17#include "clang/Basic/LLVM.h"
20#include <memory>
21#include <vector>
22
23namespace clang {
24
25class MultiplexASTMutationListener;
26
27// This ASTDeserializationListener forwards its notifications to a set of
28// child listeners.
30public:
31 // Does NOT take ownership of the elements in L.
33 const std::vector<ASTDeserializationListener *> &L);
34 void ReaderInitialized(ASTReader *Reader) override;
36 void MacroRead(serialization::MacroID ID, MacroInfo *MI) override;
37 void TypeRead(serialization::TypeIdx Idx, QualType T) override;
38 void DeclRead(GlobalDeclID ID, const Decl *D) override;
39 void PredefinedDeclBuilt(PredefinedDeclIDs ID, const Decl *D) override;
40 void SelectorRead(serialization::SelectorID iD, Selector Sel) override;
42 MacroDefinitionRecord *MD) override;
45 SourceLocation ImportLoc) override;
46
47private:
48 std::vector<ASTDeserializationListener *> Listeners;
49};
50
51// Has a list of ASTConsumers and calls each of them. Owns its children.
53public:
54 // Takes ownership of the pointers in C.
55 MultiplexConsumer(std::vector<std::unique_ptr<ASTConsumer>> C);
56 MultiplexConsumer(std::unique_ptr<ASTConsumer> C);
57 ~MultiplexConsumer() override;
58
59 // ASTConsumer
60 void Initialize(ASTContext &Context) override;
62 bool HandleTopLevelDecl(DeclGroupRef D) override;
65 void HandleTranslationUnit(ASTContext &Ctx) override;
66 void HandleTagDeclDefinition(TagDecl *D) override;
67 void HandleTagDeclRequiredDefinition(const TagDecl *D) override;
73 void AssignInheritanceModel(CXXRecordDecl *RD) override;
74 void HandleVTable(CXXRecordDecl *RD) override;
77 void PrintStats() override;
78 bool shouldSkipFunctionBody(Decl *D) override;
79
80 // SemaConsumer
81 void InitializeSema(Sema &S) override;
82 void ForgetSema() override;
83
84protected:
85 std::vector<std::unique_ptr<ASTConsumer>> Consumers; // Owns these.
86 std::unique_ptr<MultiplexASTMutationListener> MutationListener;
87 std::unique_ptr<MultiplexASTDeserializationListener> DeserializationListener;
88};
89
90} // end namespace clang
91
92#endif
static char ID
Definition: Arena.cpp:183
const Decl * D
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:188
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
Reads an AST files chain containing the contents of a translation unit.
Definition: ASTReader.h:383
Represents a C++ struct/union/class.
Definition: DeclCXX.h:258
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:86
Represents a ValueDecl that came out of a declarator.
Definition: Decl.h:735
Represents a function declaration or definition.
Definition: Decl.h:1935
One of these records is kept for each identifier that is lexed.
Describes a module import declaration, which makes the contents of the named module visible in the cu...
Definition: Decl.h:4786
Record the location of a macro definition.
Encapsulates the data about a macro definition (e.g.
Definition: MacroInfo.h:39
Describes a module or submodule.
Definition: Module.h:115
void IdentifierRead(serialization::IdentifierID ID, IdentifierInfo *II) override
An identifier was deserialized from the AST file.
void MacroDefinitionRead(serialization::PreprocessedEntityID, MacroDefinitionRecord *MD) override
A macro definition was read from the AST file.
void PredefinedDeclBuilt(PredefinedDeclIDs ID, const Decl *D) override
A predefined decl was built during the serialization.
void ModuleRead(serialization::SubmoduleID ID, Module *Mod) override
A module definition was read from the AST file.
void TypeRead(serialization::TypeIdx Idx, QualType T) override
A type was deserialized from the AST file.
void DeclRead(GlobalDeclID ID, const Decl *D) override
A decl was deserialized from the AST file.
void SelectorRead(serialization::SelectorID iD, Selector Sel) override
A selector was read from the AST file.
void MacroRead(serialization::MacroID ID, MacroInfo *MI) override
A macro was read from the AST file.
void ReaderInitialized(ASTReader *Reader) override
The ASTReader was initialized.
void ModuleImportRead(serialization::SubmoduleID ID, SourceLocation ImportLoc) override
A module import was read from the AST file.
void HandleImplicitImportDecl(ImportDecl *D) override
Handle an ImportDecl that was implicitly created due to an inclusion directive.
ASTDeserializationListener * GetASTDeserializationListener() override
If the consumer is interested in entities being deserialized from AST files, it should return a point...
void HandleCXXImplicitFunctionInstantiation(FunctionDecl *D) override
Invoked when a function is implicitly instantiated.
bool HandleTopLevelDecl(DeclGroupRef D) override
HandleTopLevelDecl - Handle the specified top-level declaration.
void HandleTagDeclRequiredDefinition(const TagDecl *D) override
This callback is invoked the first time each TagDecl is required to be complete.
void AssignInheritanceModel(CXXRecordDecl *RD) override
Callback invoked when an MSInheritanceAttr has been attached to a CXXRecordDecl.
void HandleTagDeclDefinition(TagDecl *D) override
HandleTagDeclDefinition - This callback is invoked each time a TagDecl (e.g.
std::unique_ptr< MultiplexASTDeserializationListener > DeserializationListener
std::unique_ptr< MultiplexASTMutationListener > MutationListener
void InitializeSema(Sema &S) override
Initialize the semantic consumer with the Sema instance being used to perform semantic analysis on th...
void HandleTranslationUnit(ASTContext &Ctx) override
HandleTranslationUnit - This method is called when the ASTs for entire translation unit have been par...
void CompleteTentativeDefinition(VarDecl *D) override
CompleteTentativeDefinition - Callback invoked at the end of a translation unit to notify the consume...
void HandleInterestingDecl(DeclGroupRef D) override
HandleInterestingDecl - Handle the specified interesting declaration.
std::vector< std::unique_ptr< ASTConsumer > > Consumers
void HandleCXXStaticMemberVarInstantiation(VarDecl *VD) override
HandleCXXStaticMemberVarInstantiation - Tell the consumer that this.
void CompleteExternalDeclaration(DeclaratorDecl *D) override
CompleteExternalDeclaration - Callback invoked at the end of a translation unit to notify the consume...
void HandleVTable(CXXRecordDecl *RD) override
Callback involved at the end of a translation unit to notify the consumer that a vtable for the given...
bool shouldSkipFunctionBody(Decl *D) override
This callback is called for each function if the Parser was initialized with SkipFunctionBodies set t...
ASTMutationListener * GetASTMutationListener() override
If the consumer is interested in entities getting modified after their initial creation,...
void PrintStats() override
PrintStats - If desired, print any statistics.
void HandleTopLevelDeclInObjCContainer(DeclGroupRef D) override
Handle the specified top-level declaration that occurred inside and ObjC container.
void ForgetSema() override
Inform the semantic consumer that Sema is no longer available.
void HandleInlineFunctionDefinition(FunctionDecl *D) override
This callback is invoked each time an inline (method or friend) function definition in a class is com...
void Initialize(ASTContext &Context) override
Initialize - This is called to initialize the consumer, providing the ASTContext.
A (possibly-)qualified type.
Definition: Type.h:929
Smart pointer class that efficiently represents Objective-C method names.
An abstract interface that should be implemented by clients that read ASTs and then require further s...
Definition: SemaConsumer.h:25
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:463
Encodes a location in the source.
Represents the declaration of a struct/union/class/enum.
Definition: Decl.h:3564
Represents a variable declaration or definition.
Definition: Decl.h:882
A type index; the type ID with the qualifier bits removed.
Definition: ASTBitCodes.h:99
uint32_t SubmoduleID
An ID number that refers to a submodule in a module file.
Definition: ASTBitCodes.h:185
uint32_t SelectorID
An ID number that refers to an ObjC selector in an AST file.
Definition: ASTBitCodes.h:167
uint32_t PreprocessedEntityID
An ID number that refers to an entity in the detailed preprocessing record.
Definition: ASTBitCodes.h:182
uint64_t IdentifierID
An ID number that refers to an identifier in an AST file.
Definition: ASTBitCodes.h:63
uint32_t MacroID
An ID number that refers to a macro in an AST file.
Definition: ASTBitCodes.h:154
The JSON file list parser is used to communicate input to InstallAPI.
PredefinedDeclIDs
Predefined declaration IDs.
Definition: DeclID.h:31
const FunctionProtoType * T