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