ExternalSemaSource.h revision a2ee20aa9660851080135219cac5b31fbac08b78
16f56ab789cb470620554d624c37f488285b3b04eDan Albert//===--- ExternalSemaSource.h - External Sema Interface ---------*- C++ -*-===// 26f56ab789cb470620554d624c37f488285b3b04eDan Albert// 36f56ab789cb470620554d624c37f488285b3b04eDan Albert// The LLVM Compiler Infrastructure 46f56ab789cb470620554d624c37f488285b3b04eDan Albert// 56f56ab789cb470620554d624c37f488285b3b04eDan Albert// This file is distributed under the University of Illinois Open Source 66f56ab789cb470620554d624c37f488285b3b04eDan Albert// License. See LICENSE.TXT for details. 76f56ab789cb470620554d624c37f488285b3b04eDan Albert// 86f56ab789cb470620554d624c37f488285b3b04eDan Albert//===----------------------------------------------------------------------===// 96f56ab789cb470620554d624c37f488285b3b04eDan Albert// 106f56ab789cb470620554d624c37f488285b3b04eDan Albert// This file defines the ExternalSemaSource interface. 116f56ab789cb470620554d624c37f488285b3b04eDan Albert// 126f56ab789cb470620554d624c37f488285b3b04eDan Albert//===----------------------------------------------------------------------===// 136f56ab789cb470620554d624c37f488285b3b04eDan Albert#ifndef LLVM_CLANG_SEMA_EXTERNAL_SEMA_SOURCE_H 146f56ab789cb470620554d624c37f488285b3b04eDan Albert#define LLVM_CLANG_SEMA_EXTERNAL_SEMA_SOURCE_H 156f56ab789cb470620554d624c37f488285b3b04eDan Albert 166f56ab789cb470620554d624c37f488285b3b04eDan Albert#include "clang/AST/ExternalASTSource.h" 176f56ab789cb470620554d624c37f488285b3b04eDan Albert#include <utility> 186f56ab789cb470620554d624c37f488285b3b04eDan Albert 196f56ab789cb470620554d624c37f488285b3b04eDan Albertnamespace clang { 206f56ab789cb470620554d624c37f488285b3b04eDan Albert 216f56ab789cb470620554d624c37f488285b3b04eDan Albertclass DeclaratorDecl; 226f56ab789cb470620554d624c37f488285b3b04eDan Albertclass LookupResult; 236f56ab789cb470620554d624c37f488285b3b04eDan Albertstruct ObjCMethodList; 246f56ab789cb470620554d624c37f488285b3b04eDan Albertclass Scope; 256f56ab789cb470620554d624c37f488285b3b04eDan Albertclass Sema; 266f56ab789cb470620554d624c37f488285b3b04eDan Albertclass VarDecl; 276f56ab789cb470620554d624c37f488285b3b04eDan Albert 28/// \brief An abstract interface that should be implemented by 29/// external AST sources that also provide information for semantic 30/// analysis. 31class ExternalSemaSource : public ExternalASTSource { 32public: 33 ExternalSemaSource() { 34 ExternalASTSource::SemaSource = true; 35 } 36 37 ~ExternalSemaSource(); 38 39 /// \brief Initialize the semantic source with the Sema instance 40 /// being used to perform semantic analysis on the abstract syntax 41 /// tree. 42 virtual void InitializeSema(Sema &S) {} 43 44 /// \brief Inform the semantic consumer that Sema is no longer available. 45 virtual void ForgetSema() {} 46 47 /// \brief Load the contents of the global method pool for a given 48 /// selector. 49 /// 50 /// \returns a pair of Objective-C methods lists containing the 51 /// instance and factory methods, respectively, with this selector. 52 virtual std::pair<ObjCMethodList,ObjCMethodList> ReadMethodPool(Selector Sel); 53 54 /// \brief Load the set of namespaces that are known to the external source, 55 /// which will be used during typo correction. 56 virtual void ReadKnownNamespaces( 57 SmallVectorImpl<NamespaceDecl *> &Namespaces); 58 59 /// \brief Do last resort, unqualified lookup on a LookupResult that 60 /// Sema cannot find. 61 /// 62 /// \param R a LookupResult that is being recovered. 63 /// 64 /// \param S the Scope of the identifier occurrence. 65 /// 66 /// \return true to tell Sema to recover using the LookupResult. 67 virtual bool LookupUnqualified(LookupResult &R, Scope *S) { return false; } 68 69 /// \brief Read the set of tentative definitions known to the external Sema 70 /// source. 71 /// 72 /// The external source should append its own tentative definitions to the 73 /// given vector of tentative definitions. Note that this routine may be 74 /// invoked multiple times; the external source should take care not to 75 /// introduce the same declarations repeatedly. 76 virtual void ReadTentativeDefinitions( 77 SmallVectorImpl<VarDecl *> &TentativeDefs) {} 78 79 /// \brief Read the set of unused file-scope declarations known to the 80 /// external Sema source. 81 /// 82 /// The external source should append its own unused, filed-scope to the 83 /// given vector of declarations. Note that this routine may be 84 /// invoked multiple times; the external source should take care not to 85 /// introduce the same declarations repeatedly. 86 virtual void ReadUnusedFileScopedDecls( 87 SmallVectorImpl<const DeclaratorDecl *> &Decls) {} 88 89 90 // isa/cast/dyn_cast support 91 static bool classof(const ExternalASTSource *Source) { 92 return Source->SemaSource; 93 } 94 static bool classof(const ExternalSemaSource *) { return true; } 95}; 96 97} // end namespace clang 98 99#endif 100