ASTMutationListener.h revision 86164e8f51fa89a3ec904607c3848dc4a21b12cf
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
18namespace 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.
39class ASTMutationListener {
40public:
41  virtual ~ASTMutationListener();
42
43  /// \brief A new TagDecl definition was completed.
44  virtual void CompletedTagDefinition(const TagDecl *D) { }
45
46  /// \brief A new declaration with name has been added to a DeclContext.
47  virtual void AddedVisibleDecl(const DeclContext *DC, const Decl *D) {}
48
49  /// \brief An implicit member was added after the definition was completed.
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.
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
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.
65  virtual void AddedCXXTemplateSpecialization(const FunctionTemplateDecl *TD,
66                                              const FunctionDecl *D) {}
67
68  /// \brief A function's return type has been deduced.
69  virtual void DeducedReturnType(const FunctionDecl *FD, QualType ReturnType);
70
71  /// \brief An implicit member got a definition.
72  virtual void CompletedImplicitDefinition(const FunctionDecl *D) {}
73
74  /// \brief A static data member was implicitly instantiated.
75  virtual void StaticDataMemberInstantiated(const VarDecl *D) {}
76
77  /// \brief A new objc category class was added for an interface.
78  virtual void AddedObjCCategoryToInterface(const ObjCCategoryDecl *CatD,
79                                            const ObjCInterfaceDecl *IFD) {}
80
81  /// \brief A objc class extension redeclared or introduced a property.
82  ///
83  /// \param Prop the property in the class extension
84  ///
85  /// \param OrigProp the property from the original interface that was declared
86  /// or null if the property was introduced.
87  ///
88  /// \param ClassExt the class extension.
89  virtual void AddedObjCPropertyInClassExtension(const ObjCPropertyDecl *Prop,
90                                            const ObjCPropertyDecl *OrigProp,
91                                            const ObjCCategoryDecl *ClassExt) {}
92
93  /// \brief A declaration is marked used which was not previously marked used.
94  ///
95  /// \param D the declaration marked used
96  virtual void DeclarationMarkedUsed(const Decl *D) {}
97
98  // NOTE: If new methods are added they should also be added to
99  // MultiplexASTMutationListener.
100};
101
102} // end namespace clang
103
104#endif
105