1 //===--- ASTMutationListener.h - AST Mutation Interface --------*- 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 defines the ASTMutationListener interface. 11 // 12 //===----------------------------------------------------------------------===// 13 #ifndef LLVM_CLANG_AST_ASTMUTATIONLISTENER_H 14 #define LLVM_CLANG_AST_ASTMUTATIONLISTENER_H 15 16 namespace clang { 17 class Attr; 18 class ClassTemplateDecl; 19 class ClassTemplateSpecializationDecl; 20 class ConstructorUsingShadowDecl; 21 class CXXDestructorDecl; 22 class CXXRecordDecl; 23 class Decl; 24 class DeclContext; 25 class FieldDecl; 26 class FunctionDecl; 27 class FunctionTemplateDecl; 28 class Module; 29 class NamedDecl; 30 class ObjCCategoryDecl; 31 class ObjCContainerDecl; 32 class ObjCInterfaceDecl; 33 class ObjCPropertyDecl; 34 class ParmVarDecl; 35 class QualType; 36 class RecordDecl; 37 class TagDecl; 38 class VarDecl; 39 class VarTemplateDecl; 40 class VarTemplateSpecializationDecl; 41 42 /// \brief An abstract interface that should be implemented by listeners 43 /// that want to be notified when an AST entity gets modified after its 44 /// initial creation. 45 class ASTMutationListener { 46 public: 47 virtual ~ASTMutationListener(); 48 49 /// \brief A new TagDecl definition was completed. 50 virtual void CompletedTagDefinition(const TagDecl *D) { } 51 52 /// \brief A new declaration with name has been added to a DeclContext. 53 virtual void AddedVisibleDecl(const DeclContext *DC, const Decl *D) {} 54 55 /// \brief An implicit member was added after the definition was completed. 56 virtual void AddedCXXImplicitMember(const CXXRecordDecl *RD, const Decl *D) {} 57 58 /// \brief A template specialization (or partial one) was added to the 59 /// template declaration. 60 virtual void AddedCXXTemplateSpecialization(const ClassTemplateDecl *TD, 61 const ClassTemplateSpecializationDecl *D) {} 62 63 /// \brief A template specialization (or partial one) was added to the 64 /// template declaration. 65 virtual void 66 AddedCXXTemplateSpecialization(const VarTemplateDecl *TD, 67 const VarTemplateSpecializationDecl *D) {} 68 69 /// \brief A template specialization (or partial one) was added to the 70 /// template declaration. 71 virtual void AddedCXXTemplateSpecialization(const FunctionTemplateDecl *TD, 72 const FunctionDecl *D) {} 73 74 /// \brief A function's exception specification has been evaluated or 75 /// instantiated. 76 virtual void ResolvedExceptionSpec(const FunctionDecl *FD) {} 77 78 /// \brief A function's return type has been deduced. 79 virtual void DeducedReturnType(const FunctionDecl *FD, QualType ReturnType); 80 81 /// \brief A virtual destructor's operator delete has been resolved. 82 virtual void ResolvedOperatorDelete(const CXXDestructorDecl *DD, 83 const FunctionDecl *Delete) {} 84 85 /// \brief An implicit member got a definition. 86 virtual void CompletedImplicitDefinition(const FunctionDecl *D) {} 87 88 /// \brief A static data member was implicitly instantiated. 89 virtual void StaticDataMemberInstantiated(const VarDecl *D) {} 90 91 /// \brief A function template's definition was instantiated. 92 virtual void FunctionDefinitionInstantiated(const FunctionDecl *D) {} 93 94 /// \brief A default argument was instantiated. 95 virtual void DefaultArgumentInstantiated(const ParmVarDecl *D) {} 96 97 /// \brief A default member initializer was instantiated. 98 virtual void DefaultMemberInitializerInstantiated(const FieldDecl *D) {} 99 100 /// \brief A new objc category class was added for an interface. 101 virtual void AddedObjCCategoryToInterface(const ObjCCategoryDecl *CatD, 102 const ObjCInterfaceDecl *IFD) {} 103 104 /// \brief A declaration is marked used which was not previously marked used. 105 /// 106 /// \param D the declaration marked used 107 virtual void DeclarationMarkedUsed(const Decl *D) {} 108 109 /// \brief A declaration is marked as OpenMP threadprivate which was not 110 /// previously marked as threadprivate. 111 /// 112 /// \param D the declaration marked OpenMP threadprivate. 113 virtual void DeclarationMarkedOpenMPThreadPrivate(const Decl *D) {} 114 115 /// \brief A declaration is marked as OpenMP declaretarget which was not 116 /// previously marked as declaretarget. 117 /// 118 /// \param D the declaration marked OpenMP declaretarget. 119 /// \param Attr the added attribute. 120 virtual void DeclarationMarkedOpenMPDeclareTarget(const Decl *D, 121 const Attr *Attr) {} 122 123 /// \brief A definition has been made visible by being redefined locally. 124 /// 125 /// \param D The definition that was previously not visible. 126 /// \param M The containing module in which the definition was made visible, 127 /// if any. 128 virtual void RedefinedHiddenDefinition(const NamedDecl *D, Module *M) {} 129 130 /// \brief An attribute was added to a RecordDecl 131 /// 132 /// \param Attr The attribute that was added to the Record 133 /// 134 /// \param Record The RecordDecl that got a new attribute 135 virtual void AddedAttributeToRecord(const Attr *Attr, 136 const RecordDecl *Record) {} 137 138 // NOTE: If new methods are added they should also be added to 139 // MultiplexASTMutationListener. 140 }; 141 142 } // end namespace clang 143 144 #endif 145