ExternalSemaSource.h revision dfe6543e12eca5c79421378b7fa6b3e8fc403e63
1//===--- ExternalSemaSource.h - External Sema 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 ExternalSemaSource interface. 11// 12//===----------------------------------------------------------------------===// 13#ifndef LLVM_CLANG_SEMA_EXTERNAL_SEMA_SOURCE_H 14#define LLVM_CLANG_SEMA_EXTERNAL_SEMA_SOURCE_H 15 16#include "clang/AST/ExternalASTSource.h" 17#include "clang/Sema/Weak.h" 18#include <utility> 19 20namespace clang { 21 22class CXXConstructorDecl; 23class CXXRecordDecl; 24class DeclaratorDecl; 25class LookupResult; 26struct ObjCMethodList; 27class Scope; 28class Sema; 29class TypedefNameDecl; 30class VarDecl; 31 32/// \brief A simple structure that captures a vtable use for the purposes of 33/// the \c ExternalSemaSource. 34struct ExternalVTableUse { 35 CXXRecordDecl *Record; 36 SourceLocation Location; 37 bool DefinitionRequired; 38}; 39 40/// \brief An abstract interface that should be implemented by 41/// external AST sources that also provide information for semantic 42/// analysis. 43class ExternalSemaSource : public ExternalASTSource { 44public: 45 ExternalSemaSource() { 46 ExternalASTSource::SemaSource = true; 47 } 48 49 ~ExternalSemaSource(); 50 51 /// \brief Initialize the semantic source with the Sema instance 52 /// being used to perform semantic analysis on the abstract syntax 53 /// tree. 54 virtual void InitializeSema(Sema &S) {} 55 56 /// \brief Inform the semantic consumer that Sema is no longer available. 57 virtual void ForgetSema() {} 58 59 /// \brief Load the contents of the global method pool for a given 60 /// selector. 61 /// 62 /// \returns a pair of Objective-C methods lists containing the 63 /// instance and factory methods, respectively, with this selector. 64 virtual std::pair<ObjCMethodList,ObjCMethodList> ReadMethodPool(Selector Sel); 65 66 /// \brief Load the set of namespaces that are known to the external source, 67 /// which will be used during typo correction. 68 virtual void ReadKnownNamespaces( 69 SmallVectorImpl<NamespaceDecl *> &Namespaces); 70 71 /// \brief Do last resort, unqualified lookup on a LookupResult that 72 /// Sema cannot find. 73 /// 74 /// \param R a LookupResult that is being recovered. 75 /// 76 /// \param S the Scope of the identifier occurrence. 77 /// 78 /// \return true to tell Sema to recover using the LookupResult. 79 virtual bool LookupUnqualified(LookupResult &R, Scope *S) { return false; } 80 81 /// \brief Read the set of tentative definitions known to the external Sema 82 /// source. 83 /// 84 /// The external source should append its own tentative definitions to the 85 /// given vector of tentative definitions. Note that this routine may be 86 /// invoked multiple times; the external source should take care not to 87 /// introduce the same declarations repeatedly. 88 virtual void ReadTentativeDefinitions( 89 SmallVectorImpl<VarDecl *> &TentativeDefs) {} 90 91 /// \brief Read the set of unused file-scope declarations known to the 92 /// external Sema source. 93 /// 94 /// The external source should append its own unused, filed-scope to the 95 /// given vector of declarations. Note that this routine may be 96 /// invoked multiple times; the external source should take care not to 97 /// introduce the same declarations repeatedly. 98 virtual void ReadUnusedFileScopedDecls( 99 SmallVectorImpl<const DeclaratorDecl *> &Decls) {} 100 101 /// \brief Read the set of delegating constructors known to the 102 /// external Sema source. 103 /// 104 /// The external source should append its own delegating constructors to the 105 /// given vector of declarations. Note that this routine may be 106 /// invoked multiple times; the external source should take care not to 107 /// introduce the same declarations repeatedly. 108 virtual void ReadDelegatingConstructors( 109 SmallVectorImpl<CXXConstructorDecl *> &Decls) {} 110 111 /// \brief Read the set of ext_vector type declarations known to the 112 /// external Sema source. 113 /// 114 /// The external source should append its own ext_vector type declarations to 115 /// the given vector of declarations. Note that this routine may be 116 /// invoked multiple times; the external source should take care not to 117 /// introduce the same declarations repeatedly. 118 virtual void ReadExtVectorDecls(SmallVectorImpl<TypedefNameDecl *> &Decls) {} 119 120 /// \brief Read the set of dynamic classes known to the external Sema source. 121 /// 122 /// The external source should append its own dynamic classes to 123 /// the given vector of declarations. Note that this routine may be 124 /// invoked multiple times; the external source should take care not to 125 /// introduce the same declarations repeatedly. 126 virtual void ReadDynamicClasses(SmallVectorImpl<CXXRecordDecl *> &Decls) {} 127 128 /// \brief Read the set of locally-scoped external declarations known to the 129 /// external Sema source. 130 /// 131 /// The external source should append its own locally-scoped external 132 /// declarations to the given vector of declarations. Note that this routine 133 /// may be invoked multiple times; the external source should take care not 134 /// to introduce the same declarations repeatedly. 135 virtual void ReadLocallyScopedExternalDecls( 136 SmallVectorImpl<NamedDecl *> &Decls) {} 137 138 /// \brief Read the set of referenced selectors known to the 139 /// external Sema source. 140 /// 141 /// The external source should append its own referenced selectors to the 142 /// given vector of selectors. Note that this routine 143 /// may be invoked multiple times; the external source should take care not 144 /// to introduce the same selectors repeatedly. 145 virtual void ReadReferencedSelectors( 146 SmallVectorImpl<std::pair<Selector, SourceLocation> > &Sels) {} 147 148 /// \brief Read the set of weak, undeclared identifiers known to the 149 /// external Sema source. 150 /// 151 /// The external source should append its own weak, undeclared identifiers to 152 /// the given vector. Note that this routine may be invoked multiple times; 153 /// the external source should take care not to introduce the same identifiers 154 /// repeatedly. 155 virtual void ReadWeakUndeclaredIdentifiers( 156 SmallVectorImpl<std::pair<IdentifierInfo *, WeakInfo> > &WI) {} 157 158 /// \brief Read the set of used vtables known to the external Sema source. 159 /// 160 /// The external source should append its own used vtables to the given 161 /// vector. Note that this routine may be invoked multiple times; the external 162 /// source should take care not to introduce the same vtables repeatedly. 163 virtual void ReadUsedVTables(SmallVectorImpl<ExternalVTableUse> &VTables) {} 164 165 // isa/cast/dyn_cast support 166 static bool classof(const ExternalASTSource *Source) { 167 return Source->SemaSource; 168 } 169 static bool classof(const ExternalSemaSource *) { return true; } 170}; 171 172} // end namespace clang 173 174#endif 175