@@ -29,130 +29,122 @@ namespace clang {
2929 class ImportDecl ;
3030 class OpenACCRoutineDecl ;
3131
32- // / ASTConsumer - This is an abstract interface that should be implemented by
33- // / clients that read ASTs. This abstraction layer allows the client to be
34- // / independent of the AST producer (e.g. parser vs AST dump file reader,
35- // / etc).
36- class ASTConsumer {
37- // / Whether this AST consumer also requires information about
38- // / semantic analysis.
39- bool SemaConsumer = false ;
40-
41- friend class SemaConsumer ;
42-
43- public:
44- ASTConsumer () = default ;
45-
46- virtual ~ASTConsumer () {}
47-
48- // / Initialize - This is called to initialize the consumer, providing the
49- // / ASTContext.
50- virtual void Initialize (ASTContext &Context) {}
51-
52- // / HandleTopLevelDecl - Handle the specified top-level declaration. This
53- // / is called by the parser to process every top-level Decl*.
54- // /
55- // / \returns true to continue parsing, or false to abort parsing.
56- virtual bool HandleTopLevelDecl (DeclGroupRef D);
57-
58- // / This callback is invoked each time an inline (method or friend)
59- // / function definition in a class is completed.
60- virtual void HandleInlineFunctionDefinition (FunctionDecl *D) {}
61-
62- // / HandleInterestingDecl - Handle the specified interesting declaration.
63- // / This is called by the AST reader when deserializing things that might
64- // / interest the consumer. The default implementation forwards to
65- // / HandleTopLevelDecl.
66- virtual void HandleInterestingDecl (DeclGroupRef D);
67-
68- // / HandleTranslationUnit - This method is called when the ASTs for entire
69- // / translation unit have been parsed.
70- virtual void HandleTranslationUnit (ASTContext &Ctx) {}
71-
72- // / HandleTagDeclDefinition - This callback is invoked each time a TagDecl
73- // / (e.g. struct, union, enum, class) is completed. This allows the client
74- // / to hack on the type, which can occur at any point in the file (because
75- // / these can be defined in declspecs).
76- virtual void HandleTagDeclDefinition (TagDecl *D) {}
77-
78- // / This callback is invoked the first time each TagDecl is required to
79- // / be complete.
80- virtual void HandleTagDeclRequiredDefinition (const TagDecl *D) {}
81-
82- // / Invoked when a function is implicitly instantiated.
83- // / Note that at this point it does not have a body, its body is
84- // / instantiated at the end of the translation unit and passed to
85- // / HandleTopLevelDecl.
86- virtual void HandleCXXImplicitFunctionInstantiation (FunctionDecl *D) {}
87-
88- // / Handle the specified top-level declaration that occurred inside
89- // / and ObjC container.
90- // / The default implementation ignored them.
91- virtual void HandleTopLevelDeclInObjCContainer (DeclGroupRef D);
92-
93- // / Handle an ImportDecl that was implicitly created due to an
94- // / inclusion directive.
95- // / The default implementation passes it to HandleTopLevelDecl.
96- virtual void HandleImplicitImportDecl (ImportDecl *D);
97-
98- // / CompleteTentativeDefinition - Callback invoked at the end of a
99- // / translation unit to notify the consumer that the given tentative
100- // / definition should be completed.
101- // /
102- // / The variable declaration itself will be a tentative
103- // / definition. If it had an incomplete array type, its type will
104- // / have already been changed to an array of size 1. However, the
105- // / declaration remains a tentative definition and has not been
106- // / modified by the introduction of an implicit zero initializer.
107- virtual void CompleteTentativeDefinition (VarDecl *D) {}
108-
109- // / CompleteExternalDeclaration - Callback invoked at the end of a
110- // / translation unit to notify the consumer that the given external
111- // / declaration should be completed.
112- virtual void CompleteExternalDeclaration (DeclaratorDecl *D) {}
113-
114- // / Callback invoked when an MSInheritanceAttr has been attached to a
115- // / CXXRecordDecl.
116- virtual void AssignInheritanceModel (CXXRecordDecl *RD) {}
117-
118- // / HandleCXXStaticMemberVarInstantiation - Tell the consumer that this
119- // variable has been instantiated.
120- virtual void HandleCXXStaticMemberVarInstantiation (VarDecl *D) {}
121-
122- // / Callback to handle the end-of-translation unit attachment of OpenACC
123- // / routine declaration information.
124- virtual void HandleOpenACCRoutineReference (const FunctionDecl *FD,
125- const OpenACCRoutineDecl *RD) {}
126-
127- // / Callback involved at the end of a translation unit to
128- // / notify the consumer that a vtable for the given C++ class is
129- // / required.
130- // /
131- // / \param RD The class whose vtable was used.
132- virtual void HandleVTable (CXXRecordDecl *RD) {}
133-
134- // / If the consumer is interested in entities getting modified after
135- // / their initial creation, it should return a pointer to
136- // / an ASTMutationListener here.
137- virtual ASTMutationListener *GetASTMutationListener () { return nullptr ; }
138-
139- // / If the consumer is interested in entities being deserialized from
140- // / AST files, it should return a pointer to a ASTDeserializationListener
141- // / here
142- virtual ASTDeserializationListener *GetASTDeserializationListener () {
143- return nullptr ;
144- }
145-
146- // / PrintStats - If desired, print any statistics.
147- virtual void PrintStats () {}
148-
149- // / This callback is called for each function if the Parser was
150- // / initialized with \c SkipFunctionBodies set to \c true.
151- // /
152- // / \return \c true if the function's body should be skipped. The function
153- // / body may be parsed anyway if it is needed (for instance, if it contains
154- // / the code completion point or is constexpr).
155- virtual bool shouldSkipFunctionBody (Decl *D) { return true ; }
32+ // / ASTConsumer - This is an abstract interface that should be implemented by
33+ // / clients that read ASTs. This abstraction layer allows the client to be
34+ // / independent of the AST producer (e.g. parser vs AST dump file reader, etc).
35+ class ASTConsumer {
36+ // / Whether this AST consumer also requires information about
37+ // / semantic analysis.
38+ bool SemaConsumer = false ;
39+
40+ friend class SemaConsumer ;
41+
42+ public:
43+ ASTConsumer () = default ;
44+
45+ virtual ~ASTConsumer () {}
46+
47+ // / Initialize - This is called to initialize the consumer, providing the
48+ // / ASTContext.
49+ virtual void Initialize (ASTContext &Context) {}
50+
51+ // / HandleTopLevelDecl - Handle the specified top-level declaration. This is
52+ // / called by the parser to process every top-level Decl*.
53+ // /
54+ // / \returns true to continue parsing, or false to abort parsing.
55+ virtual bool HandleTopLevelDecl (DeclGroupRef D);
56+
57+ // / This callback is invoked each time an inline (method or friend)
58+ // / function definition in a class is completed.
59+ virtual void HandleInlineFunctionDefinition (FunctionDecl *D) {}
60+
61+ // / HandleInterestingDecl - Handle the specified interesting declaration. This
62+ // / is called by the AST reader when deserializing things that might interest
63+ // / the consumer. The default implementation forwards to HandleTopLevelDecl.
64+ virtual void HandleInterestingDecl (DeclGroupRef D);
65+
66+ // / HandleTranslationUnit - This method is called when the ASTs for entire
67+ // / translation unit have been parsed.
68+ virtual void HandleTranslationUnit (ASTContext &Ctx) {}
69+
70+ // / HandleTagDeclDefinition - This callback is invoked each time a TagDecl
71+ // / (e.g. struct, union, enum, class) is completed. This allows the client to
72+ // / hack on the type, which can occur at any point in the file (because these
73+ // / can be defined in declspecs).
74+ virtual void HandleTagDeclDefinition (TagDecl *D) {}
75+
76+ // / This callback is invoked the first time each TagDecl is required to
77+ // / be complete.
78+ virtual void HandleTagDeclRequiredDefinition (const TagDecl *D) {}
79+
80+ // / Invoked when a function is implicitly instantiated.
81+ // / Note that at this point it does not have a body, its body is
82+ // / instantiated at the end of the translation unit and passed to
83+ // / HandleTopLevelDecl.
84+ virtual void HandleCXXImplicitFunctionInstantiation (FunctionDecl *D) {}
85+
86+ // / Handle the specified top-level declaration that occurred inside
87+ // / and ObjC container.
88+ // / The default implementation ignored them.
89+ virtual void HandleTopLevelDeclInObjCContainer (DeclGroupRef D);
90+
91+ // / Handle an ImportDecl that was implicitly created due to an
92+ // / inclusion directive.
93+ // / The default implementation passes it to HandleTopLevelDecl.
94+ virtual void HandleImplicitImportDecl (ImportDecl *D);
95+
96+ // / CompleteTentativeDefinition - Callback invoked at the end of a translation
97+ // / unit to notify the consumer that the given tentative definition should be
98+ // / completed.
99+ // /
100+ // / The variable declaration itself will be a tentative
101+ // / definition. If it had an incomplete array type, its type will
102+ // / have already been changed to an array of size 1. However, the
103+ // / declaration remains a tentative definition and has not been
104+ // / modified by the introduction of an implicit zero initializer.
105+ virtual void CompleteTentativeDefinition (VarDecl *D) {}
106+
107+ // / CompleteExternalDeclaration - Callback invoked at the end of a translation
108+ // / unit to notify the consumer that the given external declaration should be
109+ // / completed.
110+ virtual void CompleteExternalDeclaration (DeclaratorDecl *D) {}
111+
112+ // / Callback invoked when an MSInheritanceAttr has been attached to a
113+ // / CXXRecordDecl.
114+ virtual void AssignInheritanceModel (CXXRecordDecl *RD) {}
115+
116+ // / HandleCXXStaticMemberVarInstantiation - Tell the consumer that this
117+ // variable has been instantiated.
118+ virtual void HandleCXXStaticMemberVarInstantiation (VarDecl *D) {}
119+
120+ // / Callback involved at the end of a translation unit to
121+ // / notify the consumer that a vtable for the given C++ class is
122+ // / required.
123+ // /
124+ // / \param RD The class whose vtable was used.
125+ virtual void HandleVTable (CXXRecordDecl *RD) {}
126+
127+ // / If the consumer is interested in entities getting modified after
128+ // / their initial creation, it should return a pointer to
129+ // / an ASTMutationListener here.
130+ virtual ASTMutationListener *GetASTMutationListener () { return nullptr ; }
131+
132+ // / If the consumer is interested in entities being deserialized from
133+ // / AST files, it should return a pointer to a ASTDeserializationListener here
134+ virtual ASTDeserializationListener *GetASTDeserializationListener () {
135+ return nullptr ;
136+ }
137+
138+ // / PrintStats - If desired, print any statistics.
139+ virtual void PrintStats () {}
140+
141+ // / This callback is called for each function if the Parser was
142+ // / initialized with \c SkipFunctionBodies set to \c true.
143+ // /
144+ // / \return \c true if the function's body should be skipped. The function
145+ // / body may be parsed anyway if it is needed (for instance, if it contains
146+ // / the code completion point or is constexpr).
147+ virtual bool shouldSkipFunctionBody (Decl *D) { return true ; }
156148};
157149
158150} // end namespace clang.
0 commit comments