ExternalSemaSource.h revision d58a0a55e64a7c410a80e9d6dcd899e61e99cc4d
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 <utility> 18 19namespace clang { 20 21class CXXConstructorDecl; 22class DeclaratorDecl; 23class LookupResult; 24struct ObjCMethodList; 25class Scope; 26class Sema; 27class TypedefNameDecl; 28class VarDecl; 29 30/// \brief An abstract interface that should be implemented by 31/// external AST sources that also provide information for semantic 32/// analysis. 33class ExternalSemaSource : public ExternalASTSource { 34public: 35 ExternalSemaSource() { 36 ExternalASTSource::SemaSource = true; 37 } 38 39 ~ExternalSemaSource(); 40 41 /// \brief Initialize the semantic source with the Sema instance 42 /// being used to perform semantic analysis on the abstract syntax 43 /// tree. 44 virtual void InitializeSema(Sema &S) {} 45 46 /// \brief Inform the semantic consumer that Sema is no longer available. 47 virtual void ForgetSema() {} 48 49 /// \brief Load the contents of the global method pool for a given 50 /// selector. 51 /// 52 /// \returns a pair of Objective-C methods lists containing the 53 /// instance and factory methods, respectively, with this selector. 54 virtual std::pair<ObjCMethodList,ObjCMethodList> ReadMethodPool(Selector Sel); 55 56 /// \brief Load the set of namespaces that are known to the external source, 57 /// which will be used during typo correction. 58 virtual void ReadKnownNamespaces( 59 SmallVectorImpl<NamespaceDecl *> &Namespaces); 60 61 /// \brief Do last resort, unqualified lookup on a LookupResult that 62 /// Sema cannot find. 63 /// 64 /// \param R a LookupResult that is being recovered. 65 /// 66 /// \param S the Scope of the identifier occurrence. 67 /// 68 /// \return true to tell Sema to recover using the LookupResult. 69 virtual bool LookupUnqualified(LookupResult &R, Scope *S) { return false; } 70 71 /// \brief Read the set of tentative definitions known to the external Sema 72 /// source. 73 /// 74 /// The external source should append its own tentative definitions to the 75 /// given vector of tentative definitions. Note that this routine may be 76 /// invoked multiple times; the external source should take care not to 77 /// introduce the same declarations repeatedly. 78 virtual void ReadTentativeDefinitions( 79 SmallVectorImpl<VarDecl *> &TentativeDefs) {} 80 81 /// \brief Read the set of unused file-scope declarations known to the 82 /// external Sema source. 83 /// 84 /// The external source should append its own unused, filed-scope to the 85 /// given vector of declarations. 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 ReadUnusedFileScopedDecls( 89 SmallVectorImpl<const DeclaratorDecl *> &Decls) {} 90 91 /// \brief Read the set of delegating constructors known to the 92 /// external Sema source. 93 /// 94 /// The external source should append its own delegating constructors 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 ReadDelegatingConstructors( 99 SmallVectorImpl<CXXConstructorDecl *> &Decls) {} 100 101 /// \brief Read the set of ext_vector type declarations known to the 102 /// external Sema source. 103 /// 104 /// The external source should append its own ext_vector type declarations to 105 /// the 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 ReadExtVectorDecls(SmallVectorImpl<TypedefNameDecl *> &Decls) {} 109 110 // isa/cast/dyn_cast support 111 static bool classof(const ExternalASTSource *Source) { 112 return Source->SemaSource; 113 } 114 static bool classof(const ExternalSemaSource *) { return true; } 115}; 116 117} // end namespace clang 118 119#endif 120