clang 22.0.0git
ASTDeserializationListener.h
Go to the documentation of this file.
1//===- ASTDeserializationListener.h - Decl/Type PCH Read Events -*- 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 defines the ASTDeserializationListener class, which is notified
10// by the ASTReader whenever a type or declaration is deserialized.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CLANG_SERIALIZATION_ASTDESERIALIZATIONLISTENER_H
15#define LLVM_CLANG_SERIALIZATION_ASTDESERIALIZATIONLISTENER_H
16
19
20namespace clang {
21
22class Decl;
23class ASTReader;
24class QualType;
25class MacroDefinitionRecord;
26class MacroInfo;
27class Module;
28class SourceLocation;
29
30// IMPORTANT: when you add a new interface to this class, please update the
31// DelegatingDeserializationListener below.
33public:
35
36 /// The ASTReader was initialized.
37 virtual void ReaderInitialized(ASTReader *Reader) { }
38
39 /// An identifier was deserialized from the AST file.
41 IdentifierInfo *II) { }
42 /// A macro was read from the AST file.
44 /// A type was deserialized from the AST file. The ID here has the
45 /// qualifier bits already removed, and T is guaranteed to be locally
46 /// unqualified.
48 /// A decl was deserialized from the AST file.
49 //
50 // Note: Implementors should be cautious when introducing additional
51 // serialization (e.g., printing the qualified name of the declaration) within
52 // the callback. Doing so may lead to unintended and complex side effects, or
53 // even cause a crash.
54 virtual void DeclRead(GlobalDeclID ID, const Decl *D) {}
55 /// A predefined decl was built during the serialization.
57 /// A selector was read from the AST file.
59 /// A macro definition was read from the AST file.
62 /// A module definition was read from the AST file.
64 /// A module import was read from the AST file.
66 SourceLocation ImportLoc) {}
67};
68
71 bool DeletePrevious;
72
73public:
75 ASTDeserializationListener *Previous, bool DeletePrevious)
76 : Previous(Previous), DeletePrevious(DeletePrevious) {}
78 if (DeletePrevious)
79 delete Previous;
80 }
81
83 delete;
86
87 void ReaderInitialized(ASTReader *Reader) override {
88 if (Previous)
89 Previous->ReaderInitialized(Reader);
90 }
92 IdentifierInfo *II) override {
93 if (Previous)
94 Previous->IdentifierRead(ID, II);
95 }
97 if (Previous)
98 Previous->MacroRead(ID, MI);
99 }
101 if (Previous)
102 Previous->TypeRead(Idx, T);
103 }
104 void DeclRead(GlobalDeclID ID, const Decl *D) override {
105 if (Previous)
106 Previous->DeclRead(ID, D);
107 }
109 if (Previous)
110 Previous->PredefinedDeclBuilt(ID, D);
111 }
113 if (Previous)
114 Previous->SelectorRead(ID, Sel);
115 }
117 MacroDefinitionRecord *MD) override {
118 if (Previous)
119 Previous->MacroDefinitionRead(PPID, MD);
120 }
122 if (Previous)
123 Previous->ModuleRead(ID, Mod);
124 }
126 SourceLocation ImportLoc) override {
127 if (Previous)
128 Previous->ModuleImportRead(ID, ImportLoc);
129 }
130};
131
132} // namespace clang
133
134#endif
static char ID
Definition: Arena.cpp:183
const Decl * D
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
StateNode * Previous
virtual void MacroDefinitionRead(serialization::PreprocessedEntityID, MacroDefinitionRecord *MD)
A macro definition was read from the AST file.
virtual void TypeRead(serialization::TypeIdx Idx, QualType T)
A type was deserialized from the AST file.
virtual void MacroRead(serialization::MacroID ID, MacroInfo *MI)
A macro was read from the AST file.
virtual void ModuleImportRead(serialization::SubmoduleID ID, SourceLocation ImportLoc)
A module import was read from the AST file.
virtual void SelectorRead(serialization::SelectorID iD, Selector Sel)
A selector was read from the AST file.
virtual void ReaderInitialized(ASTReader *Reader)
The ASTReader was initialized.
virtual void DeclRead(GlobalDeclID ID, const Decl *D)
A decl was deserialized from the AST file.
virtual void PredefinedDeclBuilt(PredefinedDeclIDs ID, const Decl *D)
A predefined decl was built during the serialization.
virtual void IdentifierRead(serialization::IdentifierID ID, IdentifierInfo *II)
An identifier was deserialized from the AST file.
virtual void ModuleRead(serialization::SubmoduleID ID, Module *Mod)
A module definition was read from the AST file.
Reads an AST files chain containing the contents of a translation unit.
Definition: ASTReader.h:429
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:86
void PredefinedDeclBuilt(PredefinedDeclIDs ID, const Decl *D) override
A predefined decl was built during the serialization.
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 ReaderInitialized(ASTReader *Reader) override
The ASTReader was initialized.
void SelectorRead(serialization::SelectorID ID, Selector Sel) override
A selector was read from the AST file.
DelegatingDeserializationListener(ASTDeserializationListener *Previous, bool DeletePrevious)
void IdentifierRead(serialization::IdentifierID ID, IdentifierInfo *II) override
An identifier was deserialized from the AST file.
DelegatingDeserializationListener & operator=(const DelegatingDeserializationListener &)=delete
void MacroRead(serialization::MacroID ID, MacroInfo *MI) override
A macro was read from the AST file.
void MacroDefinitionRead(serialization::PreprocessedEntityID PPID, 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.
DelegatingDeserializationListener(const DelegatingDeserializationListener &)=delete
void ModuleImportRead(serialization::SubmoduleID ID, SourceLocation ImportLoc) override
A module import was read from the AST file.
One of these records is kept for each identifier that is lexed.
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:144
A (possibly-)qualified type.
Definition: TypeBase.h:937
Smart pointer class that efficiently represents Objective-C method names.
Encodes a location in the source.
A type index; the type ID with the qualifier bits removed.
Definition: ASTBitCodes.h:99
std::variant< struct RequiresDecl, struct HeaderDecl, struct UmbrellaDirDecl, struct ModuleDecl, struct ExcludeDecl, struct ExportDecl, struct ExportAsDecl, struct ExternModuleDecl, struct UseDecl, struct LinkDecl, struct ConfigMacrosDecl, struct ConflictDecl > Decl
All declarations that can appear in a module declaration.
Definition: ModuleMapFile.h:36
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.
@ Module
Module linkage, which indicates that the entity can be referred to from other translation units withi...
PredefinedDeclIDs
Predefined declaration IDs.
Definition: DeclID.h:31
const FunctionProtoType * T