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 #include "clang/Basic/SourceLocation.h" 17 18 namespace clang { 19 class CXXRecordDecl; 20 class ClassTemplateDecl; 21 class ClassTemplateSpecializationDecl; 22 class Decl; 23 class DeclContext; 24 class FunctionDecl; 25 class FunctionTemplateDecl; 26 class ObjCCategoryDecl; 27 class ObjCContainerDecl; 28 class ObjCInterfaceDecl; 29 class ObjCPropertyDecl; 30 class QualType; 31 class TagDecl; 32 class VarDecl; 33 class VarTemplateDecl; 34 class VarTemplateSpecializationDecl; 35 36 /// \brief An abstract interface that should be implemented by listeners 37 /// that want to be notified when an AST entity gets modified after its 38 /// initial creation. 39 class ASTMutationListener { 40 public: 41 virtual ~ASTMutationListener(); 42 43 /// \brief A new TagDecl definition was completed. CompletedTagDefinition(const TagDecl * D)44 virtual void CompletedTagDefinition(const TagDecl *D) { } 45 46 /// \brief A new declaration with name has been added to a DeclContext. AddedVisibleDecl(const DeclContext * DC,const Decl * D)47 virtual void AddedVisibleDecl(const DeclContext *DC, const Decl *D) {} 48 49 /// \brief An implicit member was added after the definition was completed. AddedCXXImplicitMember(const CXXRecordDecl * RD,const Decl * D)50 virtual void AddedCXXImplicitMember(const CXXRecordDecl *RD, const Decl *D) {} 51 52 /// \brief A template specialization (or partial one) was added to the 53 /// template declaration. AddedCXXTemplateSpecialization(const ClassTemplateDecl * TD,const ClassTemplateSpecializationDecl * D)54 virtual void AddedCXXTemplateSpecialization(const ClassTemplateDecl *TD, 55 const ClassTemplateSpecializationDecl *D) {} 56 57 /// \brief A template specialization (or partial one) was added to the 58 /// template declaration. 59 virtual void AddedCXXTemplateSpecialization(const VarTemplateDecl * TD,const VarTemplateSpecializationDecl * D)60 AddedCXXTemplateSpecialization(const VarTemplateDecl *TD, 61 const VarTemplateSpecializationDecl *D) {} 62 63 /// \brief A template specialization (or partial one) was added to the 64 /// template declaration. AddedCXXTemplateSpecialization(const FunctionTemplateDecl * TD,const FunctionDecl * D)65 virtual void AddedCXXTemplateSpecialization(const FunctionTemplateDecl *TD, 66 const FunctionDecl *D) {} 67 68 /// \brief A function's exception specification has been evaluated or 69 /// instantiated. ResolvedExceptionSpec(const FunctionDecl * FD)70 virtual void ResolvedExceptionSpec(const FunctionDecl *FD) {} 71 72 /// \brief A function's return type has been deduced. 73 virtual void DeducedReturnType(const FunctionDecl *FD, QualType ReturnType); 74 75 /// \brief An implicit member got a definition. CompletedImplicitDefinition(const FunctionDecl * D)76 virtual void CompletedImplicitDefinition(const FunctionDecl *D) {} 77 78 /// \brief A static data member was implicitly instantiated. StaticDataMemberInstantiated(const VarDecl * D)79 virtual void StaticDataMemberInstantiated(const VarDecl *D) {} 80 81 /// \brief A function template's definition was instantiated. FunctionDefinitionInstantiated(const FunctionDecl * D)82 virtual void FunctionDefinitionInstantiated(const FunctionDecl *D) {} 83 84 /// \brief A new objc category class was added for an interface. AddedObjCCategoryToInterface(const ObjCCategoryDecl * CatD,const ObjCInterfaceDecl * IFD)85 virtual void AddedObjCCategoryToInterface(const ObjCCategoryDecl *CatD, 86 const ObjCInterfaceDecl *IFD) {} 87 88 /// \brief A objc class extension redeclared or introduced a property. 89 /// 90 /// \param Prop the property in the class extension 91 /// 92 /// \param OrigProp the property from the original interface that was declared 93 /// or null if the property was introduced. 94 /// 95 /// \param ClassExt the class extension. AddedObjCPropertyInClassExtension(const ObjCPropertyDecl * Prop,const ObjCPropertyDecl * OrigProp,const ObjCCategoryDecl * ClassExt)96 virtual void AddedObjCPropertyInClassExtension(const ObjCPropertyDecl *Prop, 97 const ObjCPropertyDecl *OrigProp, 98 const ObjCCategoryDecl *ClassExt) {} 99 100 /// \brief A declaration is marked used which was not previously marked used. 101 /// 102 /// \param D the declaration marked used DeclarationMarkedUsed(const Decl * D)103 virtual void DeclarationMarkedUsed(const Decl *D) {} 104 105 // NOTE: If new methods are added they should also be added to 106 // MultiplexASTMutationListener. 107 }; 108 109 } // end namespace clang 110 111 #endif 112