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