|
|
|||
File indexing completed on 2026-05-10 08:36:27
0001 //===--- ASTConsumer.h - Abstract interface for reading ASTs ----*- C++ -*-===// 0002 // 0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 0004 // See https://llvm.org/LICENSE.txt for license information. 0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 0006 // 0007 //===----------------------------------------------------------------------===// 0008 // 0009 // This file defines the ASTConsumer class. 0010 // 0011 //===----------------------------------------------------------------------===// 0012 0013 #ifndef LLVM_CLANG_AST_ASTCONSUMER_H 0014 #define LLVM_CLANG_AST_ASTCONSUMER_H 0015 0016 namespace clang { 0017 class ASTContext; 0018 class CXXMethodDecl; 0019 class CXXRecordDecl; 0020 class Decl; 0021 class DeclGroupRef; 0022 class ASTMutationListener; 0023 class ASTDeserializationListener; // layering violation because void* is ugly 0024 class SemaConsumer; // layering violation required for safe SemaConsumer 0025 class TagDecl; 0026 class DeclaratorDecl; 0027 class VarDecl; 0028 class FunctionDecl; 0029 class ImportDecl; 0030 0031 /// ASTConsumer - This is an abstract interface that should be implemented by 0032 /// clients that read ASTs. This abstraction layer allows the client to be 0033 /// independent of the AST producer (e.g. parser vs AST dump file reader, etc). 0034 class ASTConsumer { 0035 /// Whether this AST consumer also requires information about 0036 /// semantic analysis. 0037 bool SemaConsumer = false; 0038 0039 friend class SemaConsumer; 0040 0041 public: 0042 ASTConsumer() = default; 0043 0044 virtual ~ASTConsumer() {} 0045 0046 /// Initialize - This is called to initialize the consumer, providing the 0047 /// ASTContext. 0048 virtual void Initialize(ASTContext &Context) {} 0049 0050 /// HandleTopLevelDecl - Handle the specified top-level declaration. This is 0051 /// called by the parser to process every top-level Decl*. 0052 /// 0053 /// \returns true to continue parsing, or false to abort parsing. 0054 virtual bool HandleTopLevelDecl(DeclGroupRef D); 0055 0056 /// This callback is invoked each time an inline (method or friend) 0057 /// function definition in a class is completed. 0058 virtual void HandleInlineFunctionDefinition(FunctionDecl *D) {} 0059 0060 /// HandleInterestingDecl - Handle the specified interesting declaration. This 0061 /// is called by the AST reader when deserializing things that might interest 0062 /// the consumer. The default implementation forwards to HandleTopLevelDecl. 0063 virtual void HandleInterestingDecl(DeclGroupRef D); 0064 0065 /// HandleTranslationUnit - This method is called when the ASTs for entire 0066 /// translation unit have been parsed. 0067 virtual void HandleTranslationUnit(ASTContext &Ctx) {} 0068 0069 /// HandleTagDeclDefinition - This callback is invoked each time a TagDecl 0070 /// (e.g. struct, union, enum, class) is completed. This allows the client to 0071 /// hack on the type, which can occur at any point in the file (because these 0072 /// can be defined in declspecs). 0073 virtual void HandleTagDeclDefinition(TagDecl *D) {} 0074 0075 /// This callback is invoked the first time each TagDecl is required to 0076 /// be complete. 0077 virtual void HandleTagDeclRequiredDefinition(const TagDecl *D) {} 0078 0079 /// Invoked when a function is implicitly instantiated. 0080 /// Note that at this point it does not have a body, its body is 0081 /// instantiated at the end of the translation unit and passed to 0082 /// HandleTopLevelDecl. 0083 virtual void HandleCXXImplicitFunctionInstantiation(FunctionDecl *D) {} 0084 0085 /// Handle the specified top-level declaration that occurred inside 0086 /// and ObjC container. 0087 /// The default implementation ignored them. 0088 virtual void HandleTopLevelDeclInObjCContainer(DeclGroupRef D); 0089 0090 /// Handle an ImportDecl that was implicitly created due to an 0091 /// inclusion directive. 0092 /// The default implementation passes it to HandleTopLevelDecl. 0093 virtual void HandleImplicitImportDecl(ImportDecl *D); 0094 0095 /// CompleteTentativeDefinition - Callback invoked at the end of a translation 0096 /// unit to notify the consumer that the given tentative definition should be 0097 /// completed. 0098 /// 0099 /// The variable declaration itself will be a tentative 0100 /// definition. If it had an incomplete array type, its type will 0101 /// have already been changed to an array of size 1. However, the 0102 /// declaration remains a tentative definition and has not been 0103 /// modified by the introduction of an implicit zero initializer. 0104 virtual void CompleteTentativeDefinition(VarDecl *D) {} 0105 0106 /// CompleteExternalDeclaration - Callback invoked at the end of a translation 0107 /// unit to notify the consumer that the given external declaration should be 0108 /// completed. 0109 virtual void CompleteExternalDeclaration(DeclaratorDecl *D) {} 0110 0111 /// Callback invoked when an MSInheritanceAttr has been attached to a 0112 /// CXXRecordDecl. 0113 virtual void AssignInheritanceModel(CXXRecordDecl *RD) {} 0114 0115 /// HandleCXXStaticMemberVarInstantiation - Tell the consumer that this 0116 // variable has been instantiated. 0117 virtual void HandleCXXStaticMemberVarInstantiation(VarDecl *D) {} 0118 0119 /// Callback involved at the end of a translation unit to 0120 /// notify the consumer that a vtable for the given C++ class is 0121 /// required. 0122 /// 0123 /// \param RD The class whose vtable was used. 0124 virtual void HandleVTable(CXXRecordDecl *RD) {} 0125 0126 /// If the consumer is interested in entities getting modified after 0127 /// their initial creation, it should return a pointer to 0128 /// an ASTMutationListener here. 0129 virtual ASTMutationListener *GetASTMutationListener() { return nullptr; } 0130 0131 /// If the consumer is interested in entities being deserialized from 0132 /// AST files, it should return a pointer to a ASTDeserializationListener here 0133 virtual ASTDeserializationListener *GetASTDeserializationListener() { 0134 return nullptr; 0135 } 0136 0137 /// PrintStats - If desired, print any statistics. 0138 virtual void PrintStats() {} 0139 0140 /// This callback is called for each function if the Parser was 0141 /// initialized with \c SkipFunctionBodies set to \c true. 0142 /// 0143 /// \return \c true if the function's body should be skipped. The function 0144 /// body may be parsed anyway if it is needed (for instance, if it contains 0145 /// the code completion point or is constexpr). 0146 virtual bool shouldSkipFunctionBody(Decl *D) { return true; } 0147 }; 0148 0149 } // end namespace clang. 0150 0151 #endif
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|