1 //===--- ASTMutationListener.h - AST Mutation Interface --------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 // This file defines the ASTMutationListener interface.
11 //===----------------------------------------------------------------------===//
12 #ifndef LLVM_CLANG_AST_ASTMUTATIONLISTENER_H
13 #define LLVM_CLANG_AST_ASTMUTATIONLISTENER_H
17 class ClassTemplateDecl;
18 class ClassTemplateSpecializationDecl;
19 class ConstructorUsingShadowDecl;
20 class CXXDestructorDecl;
27 class FunctionTemplateDecl;
30 class ObjCCategoryDecl;
31 class ObjCContainerDecl;
32 class ObjCInterfaceDecl;
33 class ObjCPropertyDecl;
40 class VarTemplateDecl;
41 class VarTemplateSpecializationDecl;
43 /// An abstract interface that should be implemented by listeners
44 /// that want to be notified when an AST entity gets modified after its
46 class ASTMutationListener {
48 virtual ~ASTMutationListener();
50 /// A new TagDecl definition was completed.
51 virtual void CompletedTagDefinition(const TagDecl *D) { }
53 /// A new declaration with name has been added to a DeclContext.
54 virtual void AddedVisibleDecl(const DeclContext *DC, const Decl *D) {}
56 /// An implicit member was added after the definition was completed.
57 virtual void AddedCXXImplicitMember(const CXXRecordDecl *RD, const Decl *D) {}
59 /// A template specialization (or partial one) was added to the
60 /// template declaration.
61 virtual void AddedCXXTemplateSpecialization(const ClassTemplateDecl *TD,
62 const ClassTemplateSpecializationDecl *D) {}
64 /// A template specialization (or partial one) was added to the
65 /// template declaration.
67 AddedCXXTemplateSpecialization(const VarTemplateDecl *TD,
68 const VarTemplateSpecializationDecl *D) {}
70 /// A template specialization (or partial one) was added to the
71 /// template declaration.
72 virtual void AddedCXXTemplateSpecialization(const FunctionTemplateDecl *TD,
73 const FunctionDecl *D) {}
75 /// A function's exception specification has been evaluated or
77 virtual void ResolvedExceptionSpec(const FunctionDecl *FD) {}
79 /// A function's return type has been deduced.
80 virtual void DeducedReturnType(const FunctionDecl *FD, QualType ReturnType);
82 /// A virtual destructor's operator delete has been resolved.
83 virtual void ResolvedOperatorDelete(const CXXDestructorDecl *DD,
84 const FunctionDecl *Delete,
87 /// An implicit member got a definition.
88 virtual void CompletedImplicitDefinition(const FunctionDecl *D) {}
90 /// The instantiation of a templated function or variable was
91 /// requested. In particular, the point of instantiation and template
92 /// specialization kind of \p D may have changed.
93 virtual void InstantiationRequested(const ValueDecl *D) {}
95 /// A templated variable's definition was implicitly instantiated.
96 virtual void VariableDefinitionInstantiated(const VarDecl *D) {}
98 /// A function template's definition was instantiated.
99 virtual void FunctionDefinitionInstantiated(const FunctionDecl *D) {}
101 /// A default argument was instantiated.
102 virtual void DefaultArgumentInstantiated(const ParmVarDecl *D) {}
104 /// A default member initializer was instantiated.
105 virtual void DefaultMemberInitializerInstantiated(const FieldDecl *D) {}
107 /// A new objc category class was added for an interface.
108 virtual void AddedObjCCategoryToInterface(const ObjCCategoryDecl *CatD,
109 const ObjCInterfaceDecl *IFD) {}
111 /// A declaration is marked used which was not previously marked used.
113 /// \param D the declaration marked used
114 virtual void DeclarationMarkedUsed(const Decl *D) {}
116 /// A declaration is marked as OpenMP threadprivate which was not
117 /// previously marked as threadprivate.
119 /// \param D the declaration marked OpenMP threadprivate.
120 virtual void DeclarationMarkedOpenMPThreadPrivate(const Decl *D) {}
122 /// A declaration is marked as OpenMP declaretarget which was not
123 /// previously marked as declaretarget.
125 /// \param D the declaration marked OpenMP declaretarget.
126 /// \param Attr the added attribute.
127 virtual void DeclarationMarkedOpenMPDeclareTarget(const Decl *D,
130 /// A declaration is marked as a variable with OpenMP allocator.
132 /// \param D the declaration marked as a variable with OpenMP allocator.
133 virtual void DeclarationMarkedOpenMPAllocate(const Decl *D, const Attr *A) {}
135 /// A definition has been made visible by being redefined locally.
137 /// \param D The definition that was previously not visible.
138 /// \param M The containing module in which the definition was made visible,
140 virtual void RedefinedHiddenDefinition(const NamedDecl *D, Module *M) {}
142 /// An attribute was added to a RecordDecl
144 /// \param Attr The attribute that was added to the Record
146 /// \param Record The RecordDecl that got a new attribute
147 virtual void AddedAttributeToRecord(const Attr *Attr,
148 const RecordDecl *Record) {}
150 // NOTE: If new methods are added they should also be added to
151 // MultiplexASTMutationListener.
154 } // end namespace clang