clang  7.0.0svn
MultiplexConsumer.h
Go to the documentation of this file.
1 //===-- MultiplexConsumer.h - 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 declares the MultiplexConsumer class, which can be used to
11 // multiplex ASTConsumer and SemaConsumer messages to many consumers.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_CLANG_FRONTEND_MULTIPLEXCONSUMER_H
16 #define LLVM_CLANG_FRONTEND_MULTIPLEXCONSUMER_H
17 
18 #include "clang/Basic/LLVM.h"
21 #include <memory>
22 #include <vector>
23 
24 namespace clang {
25 
26 class MultiplexASTMutationListener;
27 
28 // This ASTDeserializationListener forwards its notifications to a set of
29 // child listeners.
31 public:
32  // Does NOT take ownership of the elements in L.
34  const std::vector<ASTDeserializationListener *> &L);
35  void ReaderInitialized(ASTReader *Reader) override;
37  void MacroRead(serialization::MacroID ID, MacroInfo *MI) override;
38  void TypeRead(serialization::TypeIdx Idx, QualType T) override;
39  void DeclRead(serialization::DeclID ID, const Decl *D) override;
40  void SelectorRead(serialization::SelectorID iD, Selector Sel) override;
42  MacroDefinitionRecord *MD) override;
43  void ModuleRead(serialization::SubmoduleID ID, Module *Mod) override;
44 
45 private:
46  std::vector<ASTDeserializationListener *> Listeners;
47 };
48 
49 // Has a list of ASTConsumers and calls each of them. Owns its children.
51 public:
52  // Takes ownership of the pointers in C.
53  MultiplexConsumer(std::vector<std::unique_ptr<ASTConsumer>> C);
54  ~MultiplexConsumer() override;
55 
56  // ASTConsumer
57  void Initialize(ASTContext &Context) override;
58  void HandleCXXStaticMemberVarInstantiation(VarDecl *VD) override;
59  bool HandleTopLevelDecl(DeclGroupRef D) override;
60  void HandleInlineFunctionDefinition(FunctionDecl *D) override;
61  void HandleInterestingDecl(DeclGroupRef D) override;
62  void HandleTranslationUnit(ASTContext &Ctx) override;
63  void HandleTagDeclDefinition(TagDecl *D) override;
64  void HandleTagDeclRequiredDefinition(const TagDecl *D) override;
65  void HandleCXXImplicitFunctionInstantiation(FunctionDecl *D) override;
66  void HandleTopLevelDeclInObjCContainer(DeclGroupRef D) override;
67  void HandleImplicitImportDecl(ImportDecl *D) override;
68  void CompleteTentativeDefinition(VarDecl *D) override;
69  void AssignInheritanceModel(CXXRecordDecl *RD) override;
70  void HandleVTable(CXXRecordDecl *RD) override;
71  ASTMutationListener *GetASTMutationListener() override;
72  ASTDeserializationListener *GetASTDeserializationListener() override;
73  void PrintStats() override;
74  bool shouldSkipFunctionBody(Decl *D) override;
75 
76  // SemaConsumer
77  void InitializeSema(Sema &S) override;
78  void ForgetSema() override;
79 
80 private:
81  std::vector<std::unique_ptr<ASTConsumer>> Consumers; // Owns these.
82  std::unique_ptr<MultiplexASTMutationListener> MutationListener;
83  std::unique_ptr<MultiplexASTDeserializationListener> DeserializationListener;
84 };
85 
86 } // end namespace clang
87 
88 #endif
Represents a function declaration or definition.
Definition: Decl.h:1714
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.
A (possibly-)qualified type.
Definition: Type.h:655
void TypeRead(serialization::TypeIdx Idx, QualType T) override
A type was deserialized from the AST file.
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:86
void DeclRead(serialization::DeclID ID, const Decl *D) override
A decl was deserialized from the AST file.
Represents a variable declaration or definition.
Definition: Decl.h:812
void MacroDefinitionRead(serialization::PreprocessedEntityID, MacroDefinitionRecord *MD) override
A macro definition was read from the AST file.
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 ...
Definition: ASTContext.h:150
Record the location of a macro definition.
uint32_t MacroID
An ID number that refers to a macro in an AST file.
Definition: ASTBitCodes.h:141
Describes a module or submodule.
Definition: Module.h:65
An abstract interface that should be implemented by clients that read ASTs and then require further s...
Definition: SemaConsumer.h:26
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
void ReaderInitialized(ASTReader *Reader) override
The ASTReader was initialized.
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:277
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
void IdentifierRead(serialization::IdentID ID, IdentifierInfo *II) override
An identifier was deserialized from the AST file.
uint32_t SubmoduleID
An ID number that refers to a submodule in a module file.
Definition: ASTBitCodes.h:172
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.
Definition: Decl.h:3010
uint32_t PreprocessedEntityID
An ID number that refers to an entity in the detailed preprocessing record.
Definition: ASTBitCodes.h:169
Describes a module import declaration, which makes the contents of the named module visible in the cu...
Definition: Decl.h:4124
uint32_t SelectorID
An ID number that refers to an ObjC selector in an AST file.
Definition: ASTBitCodes.h:154
Dataflow Directional Tag Classes.
Reads an AST files chain containing the contents of a translation unit.
Definition: ASTReader.h:354
uint32_t DeclID
An ID number that refers to a declaration in an AST file.
Definition: ASTBitCodes.h:69
Encapsulates the data about a macro definition (e.g.
Definition: MacroInfo.h:40
uint32_t IdentID
An ID number that refers to an identifier in an AST file.
Definition: ASTBitCodes.h:135
MultiplexASTDeserializationListener(const std::vector< ASTDeserializationListener *> &L)
Represents a C++ struct/union/class.
Definition: DeclCXX.h:300
void MacroRead(serialization::MacroID ID, MacroInfo *MI) override
A macro was read from the AST file.
A type index; the type ID with the qualifier bits removed.
Definition: ASTBitCodes.h:89