1 | //===--- ASTMutationListener.h - AST Mutation Interface --------*- 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 ASTMutationListener interface. |
10 | // |
11 | //===----------------------------------------------------------------------===// |
12 | #ifndef LLVM_CLANG_AST_ASTMUTATIONLISTENER_H |
13 | #define LLVM_CLANG_AST_ASTMUTATIONLISTENER_H |
14 | |
15 | namespace clang { |
16 | class Attr; |
17 | class ClassTemplateDecl; |
18 | class ClassTemplateSpecializationDecl; |
19 | class ConstructorUsingShadowDecl; |
20 | class CXXDestructorDecl; |
21 | class CXXRecordDecl; |
22 | class Decl; |
23 | class DeclContext; |
24 | class Expr; |
25 | class FieldDecl; |
26 | class FunctionDecl; |
27 | class FunctionTemplateDecl; |
28 | class Module; |
29 | class NamedDecl; |
30 | class NamespaceDecl; |
31 | class ObjCCategoryDecl; |
32 | class ObjCContainerDecl; |
33 | class ObjCInterfaceDecl; |
34 | class ObjCPropertyDecl; |
35 | class ParmVarDecl; |
36 | class QualType; |
37 | class RecordDecl; |
38 | class TagDecl; |
39 | class TranslationUnitDecl; |
40 | class ValueDecl; |
41 | class VarDecl; |
42 | class VarTemplateDecl; |
43 | class VarTemplateSpecializationDecl; |
44 | |
45 | /// An abstract interface that should be implemented by listeners |
46 | /// that want to be notified when an AST entity gets modified after its |
47 | /// initial creation. |
48 | class ASTMutationListener { |
49 | public: |
50 | virtual ~ASTMutationListener(); |
51 | |
52 | /// A new TagDecl definition was completed. |
53 | virtual void CompletedTagDefinition(const TagDecl *D) { } |
54 | |
55 | /// A new declaration with name has been added to a DeclContext. |
56 | virtual void AddedVisibleDecl(const DeclContext *DC, const Decl *D) {} |
57 | |
58 | /// An implicit member was added after the definition was completed. |
59 | virtual void AddedCXXImplicitMember(const CXXRecordDecl *RD, const Decl *D) {} |
60 | |
61 | /// A template specialization (or partial one) was added to the |
62 | /// template declaration. |
63 | virtual void AddedCXXTemplateSpecialization(const ClassTemplateDecl *TD, |
64 | const ClassTemplateSpecializationDecl *D) {} |
65 | |
66 | /// A template specialization (or partial one) was added to the |
67 | /// template declaration. |
68 | virtual void |
69 | AddedCXXTemplateSpecialization(const VarTemplateDecl *TD, |
70 | const VarTemplateSpecializationDecl *D) {} |
71 | |
72 | /// A template specialization (or partial one) was added to the |
73 | /// template declaration. |
74 | virtual void AddedCXXTemplateSpecialization(const FunctionTemplateDecl *TD, |
75 | const FunctionDecl *D) {} |
76 | |
77 | /// A function's exception specification has been evaluated or |
78 | /// instantiated. |
79 | virtual void ResolvedExceptionSpec(const FunctionDecl *FD) {} |
80 | |
81 | /// A function's return type has been deduced. |
82 | virtual void DeducedReturnType(const FunctionDecl *FD, QualType ReturnType); |
83 | |
84 | /// A virtual destructor's operator delete has been resolved. |
85 | virtual void ResolvedOperatorDelete(const CXXDestructorDecl *DD, |
86 | const FunctionDecl *Delete, |
87 | Expr *ThisArg) {} |
88 | |
89 | /// An implicit member got a definition. |
90 | virtual void CompletedImplicitDefinition(const FunctionDecl *D) {} |
91 | |
92 | /// The instantiation of a templated function or variable was |
93 | /// requested. In particular, the point of instantiation and template |
94 | /// specialization kind of \p D may have changed. |
95 | virtual void InstantiationRequested(const ValueDecl *D) {} |
96 | |
97 | /// A templated variable's definition was implicitly instantiated. |
98 | virtual void VariableDefinitionInstantiated(const VarDecl *D) {} |
99 | |
100 | /// A function template's definition was instantiated. |
101 | virtual void FunctionDefinitionInstantiated(const FunctionDecl *D) {} |
102 | |
103 | /// A default argument was instantiated. |
104 | virtual void DefaultArgumentInstantiated(const ParmVarDecl *D) {} |
105 | |
106 | /// A default member initializer was instantiated. |
107 | virtual void DefaultMemberInitializerInstantiated(const FieldDecl *D) {} |
108 | |
109 | /// A new objc category class was added for an interface. |
110 | virtual void AddedObjCCategoryToInterface(const ObjCCategoryDecl *CatD, |
111 | const ObjCInterfaceDecl *IFD) {} |
112 | |
113 | /// A declaration is marked used which was not previously marked used. |
114 | /// |
115 | /// \param D the declaration marked used |
116 | virtual void DeclarationMarkedUsed(const Decl *D) {} |
117 | |
118 | /// A declaration is marked as OpenMP threadprivate which was not |
119 | /// previously marked as threadprivate. |
120 | /// |
121 | /// \param D the declaration marked OpenMP threadprivate. |
122 | virtual void DeclarationMarkedOpenMPThreadPrivate(const Decl *D) {} |
123 | |
124 | /// A declaration is marked as OpenMP declaretarget which was not |
125 | /// previously marked as declaretarget. |
126 | /// |
127 | /// \param D the declaration marked OpenMP declaretarget. |
128 | /// \param Attr the added attribute. |
129 | virtual void DeclarationMarkedOpenMPDeclareTarget(const Decl *D, |
130 | const Attr *Attr) {} |
131 | |
132 | /// A declaration is marked as a variable with OpenMP allocator. |
133 | /// |
134 | /// \param D the declaration marked as a variable with OpenMP allocator. |
135 | virtual void DeclarationMarkedOpenMPAllocate(const Decl *D, const Attr *A) {} |
136 | |
137 | /// A definition has been made visible by being redefined locally. |
138 | /// |
139 | /// \param D The definition that was previously not visible. |
140 | /// \param M The containing module in which the definition was made visible, |
141 | /// if any. |
142 | virtual void RedefinedHiddenDefinition(const NamedDecl *D, Module *M) {} |
143 | |
144 | /// An attribute was added to a RecordDecl |
145 | /// |
146 | /// \param Attr The attribute that was added to the Record |
147 | /// |
148 | /// \param Record The RecordDecl that got a new attribute |
149 | virtual void AddedAttributeToRecord(const Attr *Attr, |
150 | const RecordDecl *Record) {} |
151 | |
152 | /// The parser find the named module declaration. |
153 | virtual void EnteringModulePurview() {} |
154 | |
155 | /// An mangling number was added to a Decl |
156 | /// |
157 | /// \param D The decl that got a mangling number |
158 | /// |
159 | /// \param Number The mangling number that was added to the Decl |
160 | virtual void AddedManglingNumber(const Decl *D, unsigned Number) {} |
161 | |
162 | /// An static local number was added to a Decl |
163 | /// |
164 | /// \param D The decl that got a static local number |
165 | /// |
166 | /// \param Number The static local number that was added to the Decl |
167 | virtual void AddedStaticLocalNumbers(const Decl *D, unsigned Number) {} |
168 | |
169 | /// An anonymous namespace was added the translation unit decl |
170 | /// |
171 | /// \param TU The translation unit decl that got a new anonymous namespace |
172 | /// |
173 | /// \param AnonNamespace The anonymous namespace that was added |
174 | virtual void AddedAnonymousNamespace(const TranslationUnitDecl *TU, |
175 | NamespaceDecl *AnonNamespace) {} |
176 | |
177 | // NOTE: If new methods are added they should also be added to |
178 | // MultiplexASTMutationListener. |
179 | }; |
180 | |
181 | } // end namespace clang |
182 | |
183 | #endif |
184 | |