clang 19.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(serialization::DeclID ID, const Decl *D) override;
39 void SelectorRead(serialization::SelectorID iD, Selector Sel) override;
41 MacroDefinitionRecord *MD) override;
44 SourceLocation ImportLoc) override;
45
46private:
47 std::vector<ASTDeserializationListener *> Listeners;
48};
49
50// Has a list of ASTConsumers and calls each of them. Owns its children.
52public:
53 // Takes ownership of the pointers in C.
54 MultiplexConsumer(std::vector<std::unique_ptr<ASTConsumer>> C);
55 ~MultiplexConsumer() override;
56
57 // ASTConsumer
58 void Initialize(ASTContext &Context) override;
60 bool HandleTopLevelDecl(DeclGroupRef D) override;
62 void HandleInterestingDecl(DeclGroupRef D) override;
63 void HandleTranslationUnit(ASTContext &Ctx) override;
64 void HandleTagDeclDefinition(TagDecl *D) override;
65 void HandleTagDeclRequiredDefinition(const TagDecl *D) override;
68 void HandleImplicitImportDecl(ImportDecl *D) override;
69 void CompleteTentativeDefinition(VarDecl *D) override;
70 void CompleteExternalDeclaration(VarDecl *D) override;
71 void AssignInheritanceModel(CXXRecordDecl *RD) override;
72 void HandleVTable(CXXRecordDecl *RD) override;
75 void PrintStats() override;
76 bool shouldSkipFunctionBody(Decl *D) override;
77
78 // SemaConsumer
79 void InitializeSema(Sema &S) override;
80 void ForgetSema() override;
81
82private:
83 std::vector<std::unique_ptr<ASTConsumer>> Consumers; // Owns these.
84 std::unique_ptr<MultiplexASTMutationListener> MutationListener;
85 std::unique_ptr<MultiplexASTDeserializationListener> DeserializationListener;
86};
87
88} // end namespace clang
89
90#endif
static char ID
Definition: Arena.cpp:183
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:182
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:366
Represents a C++ struct/union/class.
Definition: DeclCXX.h:258
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:85
Represents a function declaration or definition.
Definition: Decl.h:1971
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:4800
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:105
void MacroDefinitionRead(serialization::PreprocessedEntityID, MacroDefinitionRecord *MD) override
A macro definition was read from the AST file.
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(serialization::DeclID ID, const Decl *D) override
A decl was deserialized from the AST file.
void IdentifierRead(serialization::IdentID ID, IdentifierInfo *II) override
An identifier 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.
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.
void CompleteExternalDeclaration(VarDecl *D) override
CompleteExternalDeclaration - Callback invoked at the end of a translation unit to notify the consume...
void HandleCXXStaticMemberVarInstantiation(VarDecl *VD) override
HandleCXXStaticMemberVarInstantiation - Tell the consumer that this.
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:738
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:457
Encodes a location in the source.
Represents the declaration of a struct/union/class/enum.
Definition: Decl.h:3585
Represents a variable declaration or definition.
Definition: Decl.h:918
A type index; the type ID with the qualifier bits removed.
Definition: ASTBitCodes.h:88
uint32_t SubmoduleID
An ID number that refers to a submodule in a module file.
Definition: ASTBitCodes.h:171
uint32_t SelectorID
An ID number that refers to an ObjC selector in an AST file.
Definition: ASTBitCodes.h:153
uint32_t PreprocessedEntityID
An ID number that refers to an entity in the detailed preprocessing record.
Definition: ASTBitCodes.h:168
uint32_t IdentID
An ID number that refers to an identifier in an AST file.
Definition: ASTBitCodes.h:134
uint32_t DeclID
An ID number that refers to a declaration in an AST file.
Definition: ASTBitCodes.h:68
uint32_t MacroID
An ID number that refers to a macro in an AST file.
Definition: ASTBitCodes.h:140
The JSON file list parser is used to communicate input to InstallAPI.
const FunctionProtoType * T