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