clang  14.0.0git
ASTMutationListener.h
Go to the documentation of this file.
1 //===--- ASTMutationListener.h - AST Mutation Interface --------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines the ASTMutationListener interface.
10 //
11 //===----------------------------------------------------------------------===//
12 #ifndef LLVM_CLANG_AST_ASTMUTATIONLISTENER_H
13 #define LLVM_CLANG_AST_ASTMUTATIONLISTENER_H
14 
15 namespace clang {
16  class Attr;
17  class ClassTemplateDecl;
18  class ClassTemplateSpecializationDecl;
19  class ConstructorUsingShadowDecl;
20  class CXXDestructorDecl;
21  class CXXRecordDecl;
22  class Decl;
23  class DeclContext;
24  class Expr;
25  class FieldDecl;
26  class FunctionDecl;
27  class FunctionTemplateDecl;
28  class Module;
29  class NamedDecl;
30  class ObjCCategoryDecl;
31  class ObjCContainerDecl;
32  class ObjCInterfaceDecl;
33  class ObjCPropertyDecl;
34  class ParmVarDecl;
35  class QualType;
36  class RecordDecl;
37  class TagDecl;
38  class ValueDecl;
39  class VarDecl;
40  class VarTemplateDecl;
41  class VarTemplateSpecializationDecl;
42 
43 /// 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.
47 public:
48  virtual ~ASTMutationListener();
49 
50  /// A new TagDecl definition was completed.
51  virtual void CompletedTagDefinition(const TagDecl *D) { }
52 
53  /// A new declaration with name has been added to a DeclContext.
54  virtual void AddedVisibleDecl(const DeclContext *DC, const Decl *D) {}
55 
56  /// An implicit member was added after the definition was completed.
57  virtual void AddedCXXImplicitMember(const CXXRecordDecl *RD, const Decl *D) {}
58 
59  /// A template specialization (or partial one) was added to the
60  /// template declaration.
63 
64  /// A template specialization (or partial one) was added to the
65  /// template declaration.
66  virtual void
69 
70  /// A template specialization (or partial one) was added to the
71  /// template declaration.
73  const FunctionDecl *D) {}
74 
75  /// A function's exception specification has been evaluated or
76  /// instantiated.
77  virtual void ResolvedExceptionSpec(const FunctionDecl *FD) {}
78 
79  /// A function's return type has been deduced.
80  virtual void DeducedReturnType(const FunctionDecl *FD, QualType ReturnType);
81 
82  /// 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  /// An implicit member got a definition.
88  virtual void CompletedImplicitDefinition(const FunctionDecl *D) {}
89 
90  /// The instantiation of a templated function or variable was
91  /// requested. In particular, the point of instantiation and template
92  /// specialization kind of \p D may have changed.
93  virtual void InstantiationRequested(const ValueDecl *D) {}
94 
95  /// A templated variable's definition was implicitly instantiated.
96  virtual void VariableDefinitionInstantiated(const VarDecl *D) {}
97 
98  /// A function template's definition was instantiated.
99  virtual void FunctionDefinitionInstantiated(const FunctionDecl *D) {}
100 
101  /// A default argument was instantiated.
102  virtual void DefaultArgumentInstantiated(const ParmVarDecl *D) {}
103 
104  /// A default member initializer was instantiated.
106 
107  /// A new objc category class was added for an interface.
109  const ObjCInterfaceDecl *IFD) {}
110 
111  /// A declaration is marked used which was not previously marked used.
112  ///
113  /// \param D the declaration marked used
114  virtual void DeclarationMarkedUsed(const Decl *D) {}
115 
116  /// A declaration is marked as OpenMP threadprivate which was not
117  /// previously marked as threadprivate.
118  ///
119  /// \param D the declaration marked OpenMP threadprivate.
120  virtual void DeclarationMarkedOpenMPThreadPrivate(const Decl *D) {}
121 
122  /// A declaration is marked as OpenMP declaretarget which was not
123  /// previously marked as declaretarget.
124  ///
125  /// \param D the declaration marked OpenMP declaretarget.
126  /// \param Attr the added attribute.
128  const Attr *Attr) {}
129 
130  /// A declaration is marked as a variable with OpenMP allocator.
131  ///
132  /// \param D the declaration marked as a variable with OpenMP allocator.
133  virtual void DeclarationMarkedOpenMPAllocate(const Decl *D, const Attr *A) {}
134 
135  /// A definition has been made visible by being redefined locally.
136  ///
137  /// \param D The definition that was previously not visible.
138  /// \param M The containing module in which the definition was made visible,
139  /// if any.
140  virtual void RedefinedHiddenDefinition(const NamedDecl *D, Module *M) {}
141 
142  /// An attribute was added to a RecordDecl
143  ///
144  /// \param Attr The attribute that was added to the Record
145  ///
146  /// \param Record The RecordDecl that got a new attribute
147  virtual void AddedAttributeToRecord(const Attr *Attr,
148  const RecordDecl *Record) {}
149 
150  // NOTE: If new methods are added they should also be added to
151  // MultiplexASTMutationListener.
152 };
153 
154 } // end namespace clang
155 
156 #endif
clang::ObjCInterfaceDecl
Represents an ObjC class declaration.
Definition: DeclObjC.h:1151
clang::ASTMutationListener::VariableDefinitionInstantiated
virtual void VariableDefinitionInstantiated(const VarDecl *D)
A templated variable's definition was implicitly instantiated.
Definition: ASTMutationListener.h:96
clang::DeclContext
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1347
clang::NamedDecl
This represents a decl that may have a name.
Definition: Decl.h:249
clang::ASTMutationListener::CompletedImplicitDefinition
virtual void CompletedImplicitDefinition(const FunctionDecl *D)
An implicit member got a definition.
Definition: ASTMutationListener.h:88
clang::QualType
A (possibly-)qualified type.
Definition: Type.h:673
clang::ASTMutationListener::DeducedReturnType
virtual void DeducedReturnType(const FunctionDecl *FD, QualType ReturnType)
A function's return type has been deduced.
Definition: ASTContext.cpp:10402
clang::FieldDecl
Represents a member of a struct/union/class.
Definition: Decl.h:2840
clang::ParmVarDecl
Represents a parameter to a function.
Definition: Decl.h:1665
clang::ASTMutationListener::DeclarationMarkedOpenMPThreadPrivate
virtual void DeclarationMarkedOpenMPThreadPrivate(const Decl *D)
A declaration is marked as OpenMP threadprivate which was not previously marked as threadprivate.
Definition: ASTMutationListener.h:120
clang::VarTemplateSpecializationDecl
Represents a variable template specialization, which refers to a variable template with a given set o...
Definition: DeclTemplate.h:2665
clang::ASTMutationListener::FunctionDefinitionInstantiated
virtual void FunctionDefinitionInstantiated(const FunctionDecl *D)
A function template's definition was instantiated.
Definition: ASTMutationListener.h:99
clang::CodeGen::AlignmentSource::Decl
@ Decl
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
clang::ASTMutationListener::AddedCXXTemplateSpecialization
virtual void AddedCXXTemplateSpecialization(const FunctionTemplateDecl *TD, const FunctionDecl *D)
A template specialization (or partial one) was added to the template declaration.
Definition: ASTMutationListener.h:72
clang::FunctionTemplateDecl
Declaration of a template function.
Definition: DeclTemplate.h:979
clang::Module
Describes a module or submodule.
Definition: Module.h:96
clang::ASTMutationListener::RedefinedHiddenDefinition
virtual void RedefinedHiddenDefinition(const NamedDecl *D, Module *M)
A definition has been made visible by being redefined locally.
Definition: ASTMutationListener.h:140
clang::ASTMutationListener::DefaultArgumentInstantiated
virtual void DefaultArgumentInstantiated(const ParmVarDecl *D)
A default argument was instantiated.
Definition: ASTMutationListener.h:102
clang::ASTMutationListener::AddedVisibleDecl
virtual void AddedVisibleDecl(const DeclContext *DC, const Decl *D)
A new declaration with name has been added to a DeclContext.
Definition: ASTMutationListener.h:54
clang::index::SymbolKind::Module
@ Module
clang::ASTMutationListener::InstantiationRequested
virtual void InstantiationRequested(const ValueDecl *D)
The instantiation of a templated function or variable was requested.
Definition: ASTMutationListener.h:93
clang::ASTMutationListener
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
Definition: ASTMutationListener.h:46
clang::ASTMutationListener::DeclarationMarkedOpenMPDeclareTarget
virtual void DeclarationMarkedOpenMPDeclareTarget(const Decl *D, const Attr *Attr)
A declaration is marked as OpenMP declaretarget which was not previously marked as declaretarget.
Definition: ASTMutationListener.h:127
clang::CXXDestructorDecl
Represents a C++ destructor within a class.
Definition: DeclCXX.h:2668
clang::VarDecl
Represents a variable declaration or definition.
Definition: Decl.h:876
clang::TagDecl
Represents the declaration of a struct/union/class/enum.
Definition: Decl.h:3333
clang::ASTMutationListener::DeclarationMarkedOpenMPAllocate
virtual void DeclarationMarkedOpenMPAllocate(const Decl *D, const Attr *A)
A declaration is marked as a variable with OpenMP allocator.
Definition: ASTMutationListener.h:133
clang::ASTMutationListener::AddedCXXImplicitMember
virtual void AddedCXXImplicitMember(const CXXRecordDecl *RD, const Decl *D)
An implicit member was added after the definition was completed.
Definition: ASTMutationListener.h:57
clang::ASTMutationListener::DeclarationMarkedUsed
virtual void DeclarationMarkedUsed(const Decl *D)
A declaration is marked used which was not previously marked used.
Definition: ASTMutationListener.h:114
clang::ObjCCategoryDecl
ObjCCategoryDecl - Represents a category declaration.
Definition: DeclObjC.h:2274
clang::diff::Delete
@ Delete
Definition: ASTDiff.h:29
clang::ASTMutationListener::ResolvedOperatorDelete
virtual void ResolvedOperatorDelete(const CXXDestructorDecl *DD, const FunctionDecl *Delete, Expr *ThisArg)
A virtual destructor's operator delete has been resolved.
Definition: ASTMutationListener.h:83
clang::CXXRecordDecl
Represents a C++ struct/union/class.
Definition: DeclCXX.h:255
clang::ASTMutationListener::CompletedTagDefinition
virtual void CompletedTagDefinition(const TagDecl *D)
A new TagDecl definition was completed.
Definition: ASTMutationListener.h:51
clang::ASTMutationListener::AddedCXXTemplateSpecialization
virtual void AddedCXXTemplateSpecialization(const ClassTemplateDecl *TD, const ClassTemplateSpecializationDecl *D)
A template specialization (or partial one) was added to the template declaration.
Definition: ASTMutationListener.h:61
clang::ASTMutationListener::DefaultMemberInitializerInstantiated
virtual void DefaultMemberInitializerInstantiated(const FieldDecl *D)
A default member initializer was instantiated.
Definition: ASTMutationListener.h:105
clang::ClassTemplateDecl
Declaration of a class template.
Definition: DeclTemplate.h:2248
clang::ValueDecl
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:676
clang::Decl
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:89
clang::ASTMutationListener::AddedAttributeToRecord
virtual void AddedAttributeToRecord(const Attr *Attr, const RecordDecl *Record)
An attribute was added to a RecordDecl.
Definition: ASTMutationListener.h:147
clang::ASTMutationListener::ResolvedExceptionSpec
virtual void ResolvedExceptionSpec(const FunctionDecl *FD)
A function's exception specification has been evaluated or instantiated.
Definition: ASTMutationListener.h:77
clang::ASTMutationListener::~ASTMutationListener
virtual ~ASTMutationListener()
clang::ASTMutationListener::AddedCXXTemplateSpecialization
virtual void AddedCXXTemplateSpecialization(const VarTemplateDecl *TD, const VarTemplateSpecializationDecl *D)
A template specialization (or partial one) was added to the template declaration.
Definition: ASTMutationListener.h:67
clang
Definition: CalledOnceCheck.h:17
clang::Attr
Attr - This represents one attribute.
Definition: Attr.h:46
clang::VarTemplateDecl
Declaration of a variable template.
Definition: DeclTemplate.h:3080
clang::Expr
This represents one expression.
Definition: Expr.h:109
clang::ClassTemplateSpecializationDecl
Represents a class template specialization, which refers to a class template with a given set of temp...
Definition: DeclTemplate.h:1804
clang::FunctionDecl
Represents a function declaration or definition.
Definition: Decl.h:1857
clang::RecordDecl
Represents a struct/union/class.
Definition: Decl.h:3868
clang::ASTMutationListener::AddedObjCCategoryToInterface
virtual void AddedObjCCategoryToInterface(const ObjCCategoryDecl *CatD, const ObjCInterfaceDecl *IFD)
A new objc category class was added for an interface.
Definition: ASTMutationListener.h:108