1 //===--- ASTMutationListener.h - AST Mutation Interface --------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines the ASTMutationListener interface.
12 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_CLANG_AST_ASTMUTATIONLISTENER_H
14 #define LLVM_CLANG_AST_ASTMUTATIONLISTENER_H
18 class ClassTemplateDecl;
19 class ClassTemplateSpecializationDecl;
20 class ConstructorUsingShadowDecl;
21 class CXXDestructorDecl;
28 class FunctionTemplateDecl;
31 class ObjCCategoryDecl;
32 class ObjCContainerDecl;
33 class ObjCInterfaceDecl;
34 class ObjCPropertyDecl;
41 class VarTemplateDecl;
42 class VarTemplateSpecializationDecl;
44 /// \brief An abstract interface that should be implemented by listeners
45 /// that want to be notified when an AST entity gets modified after its
47 class ASTMutationListener {
49 virtual ~ASTMutationListener();
51 /// \brief A new TagDecl definition was completed.
52 virtual void CompletedTagDefinition(const TagDecl *D) { }
54 /// \brief A new declaration with name has been added to a DeclContext.
55 virtual void AddedVisibleDecl(const DeclContext *DC, const Decl *D) {}
57 /// \brief An implicit member was added after the definition was completed.
58 virtual void AddedCXXImplicitMember(const CXXRecordDecl *RD, const Decl *D) {}
60 /// \brief A template specialization (or partial one) was added to the
61 /// template declaration.
62 virtual void AddedCXXTemplateSpecialization(const ClassTemplateDecl *TD,
63 const ClassTemplateSpecializationDecl *D) {}
65 /// \brief A template specialization (or partial one) was added to the
66 /// template declaration.
68 AddedCXXTemplateSpecialization(const VarTemplateDecl *TD,
69 const VarTemplateSpecializationDecl *D) {}
71 /// \brief A template specialization (or partial one) was added to the
72 /// template declaration.
73 virtual void AddedCXXTemplateSpecialization(const FunctionTemplateDecl *TD,
74 const FunctionDecl *D) {}
76 /// \brief A function's exception specification has been evaluated or
78 virtual void ResolvedExceptionSpec(const FunctionDecl *FD) {}
80 /// \brief A function's return type has been deduced.
81 virtual void DeducedReturnType(const FunctionDecl *FD, QualType ReturnType);
83 /// \brief A virtual destructor's operator delete has been resolved.
84 virtual void ResolvedOperatorDelete(const CXXDestructorDecl *DD,
85 const FunctionDecl *Delete,
88 /// \brief An implicit member got a definition.
89 virtual void CompletedImplicitDefinition(const FunctionDecl *D) {}
91 /// \brief The instantiation of a templated function or variable was
92 /// requested. In particular, the point of instantiation and template
93 /// specialization kind of \p D may have changed.
94 virtual void InstantiationRequested(const ValueDecl *D) {}
96 /// \brief A templated variable's definition was implicitly instantiated.
97 virtual void VariableDefinitionInstantiated(const VarDecl *D) {}
99 /// \brief A function template's definition was instantiated.
100 virtual void FunctionDefinitionInstantiated(const FunctionDecl *D) {}
102 /// \brief A default argument was instantiated.
103 virtual void DefaultArgumentInstantiated(const ParmVarDecl *D) {}
105 /// \brief A default member initializer was instantiated.
106 virtual void DefaultMemberInitializerInstantiated(const FieldDecl *D) {}
108 /// \brief A new objc category class was added for an interface.
109 virtual void AddedObjCCategoryToInterface(const ObjCCategoryDecl *CatD,
110 const ObjCInterfaceDecl *IFD) {}
112 /// \brief A declaration is marked used which was not previously marked used.
114 /// \param D the declaration marked used
115 virtual void DeclarationMarkedUsed(const Decl *D) {}
117 /// \brief A declaration is marked as OpenMP threadprivate which was not
118 /// previously marked as threadprivate.
120 /// \param D the declaration marked OpenMP threadprivate.
121 virtual void DeclarationMarkedOpenMPThreadPrivate(const Decl *D) {}
123 /// \brief A declaration is marked as OpenMP declaretarget which was not
124 /// previously marked as declaretarget.
126 /// \param D the declaration marked OpenMP declaretarget.
127 /// \param Attr the added attribute.
128 virtual void DeclarationMarkedOpenMPDeclareTarget(const Decl *D,
131 /// \brief A definition has been made visible by being redefined locally.
133 /// \param D The definition that was previously not visible.
134 /// \param M The containing module in which the definition was made visible,
136 virtual void RedefinedHiddenDefinition(const NamedDecl *D, Module *M) {}
138 /// \brief An attribute was added to a RecordDecl
140 /// \param Attr The attribute that was added to the Record
142 /// \param Record The RecordDecl that got a new attribute
143 virtual void AddedAttributeToRecord(const Attr *Attr,
144 const RecordDecl *Record) {}
146 // NOTE: If new methods are added they should also be added to
147 // MultiplexASTMutationListener.
150 } // end namespace clang