ExternalSemaSource.h revision 252723
10SN/A//===--- ExternalSemaSource.h - External Sema Interface ---------*- C++ -*-===// 29595SN/A// 30SN/A// The LLVM Compiler Infrastructure 40SN/A// 50SN/A// This file is distributed under the University of Illinois Open Source 60SN/A// License. See LICENSE.TXT for details. 72362SN/A// 80SN/A//===----------------------------------------------------------------------===// 92362SN/A// 100SN/A// This file defines the ExternalSemaSource interface. 110SN/A// 120SN/A//===----------------------------------------------------------------------===// 130SN/A#ifndef LLVM_CLANG_SEMA_EXTERNAL_SEMA_SOURCE_H 140SN/A#define LLVM_CLANG_SEMA_EXTERNAL_SEMA_SOURCE_H 150SN/A 160SN/A#include "clang/AST/ExternalASTSource.h" 170SN/A#include "clang/Sema/Weak.h" 180SN/A#include "llvm/ADT/MapVector.h" 190SN/A#include <utility> 200SN/A 212362SN/Anamespace clang { 222362SN/A 232362SN/Aclass CXXConstructorDecl; 240SN/Aclass CXXRecordDecl; 250SN/Aclass DeclaratorDecl; 260SN/Aclass LookupResult; 270SN/Astruct ObjCMethodList; 280SN/Aclass Scope; 290SN/Aclass Sema; 300SN/Aclass TypedefNameDecl; 310SN/Aclass ValueDecl; 320SN/Aclass VarDecl; 330SN/A 340SN/A/// \brief A simple structure that captures a vtable use for the purposes of 350SN/A/// the \c ExternalSemaSource. 360SN/Astruct ExternalVTableUse { 370SN/A CXXRecordDecl *Record; 380SN/A SourceLocation Location; 390SN/A bool DefinitionRequired; 400SN/A}; 410SN/A 420SN/A/// \brief An abstract interface that should be implemented by 430SN/A/// external AST sources that also provide information for semantic 440SN/A/// analysis. 450SN/Aclass ExternalSemaSource : public ExternalASTSource { 460SN/Apublic: 470SN/A ExternalSemaSource() { 480SN/A ExternalASTSource::SemaSource = true; 490SN/A } 500SN/A 510SN/A ~ExternalSemaSource(); 520SN/A 530SN/A /// \brief Initialize the semantic source with the Sema instance 540SN/A /// being used to perform semantic analysis on the abstract syntax 550SN/A /// tree. 560SN/A virtual void InitializeSema(Sema &S) {} 570SN/A 580SN/A /// \brief Inform the semantic consumer that Sema is no longer available. 590SN/A virtual void ForgetSema() {} 600SN/A 610SN/A /// \brief Load the contents of the global method pool for a given 620SN/A /// selector. 630SN/A virtual void ReadMethodPool(Selector Sel); 640SN/A 650SN/A /// \brief Load the set of namespaces that are known to the external source, 660SN/A /// which will be used during typo correction. 670SN/A virtual void ReadKnownNamespaces( 680SN/A SmallVectorImpl<NamespaceDecl *> &Namespaces); 690SN/A 700SN/A /// \brief Load the set of used but not defined functions or variables with 710SN/A /// internal linkage, or used but not defined internal functions. 720SN/A virtual void ReadUndefinedButUsed( 730SN/A llvm::DenseMap<NamedDecl*, SourceLocation> &Undefined); 740SN/A 750SN/A /// \brief Do last resort, unqualified lookup on a LookupResult that 760SN/A /// Sema cannot find. 770SN/A /// 780SN/A /// \param R a LookupResult that is being recovered. 790SN/A /// 800SN/A /// \param S the Scope of the identifier occurrence. 810SN/A /// 820SN/A /// \return true to tell Sema to recover using the LookupResult. 830SN/A virtual bool LookupUnqualified(LookupResult &R, Scope *S) { return false; } 840SN/A 850SN/A /// \brief Read the set of tentative definitions known to the external Sema 860SN/A /// source. 870SN/A /// 880SN/A /// The external source should append its own tentative definitions to the 890SN/A /// given vector of tentative definitions. Note that this routine may be 900SN/A /// invoked multiple times; the external source should take care not to 910SN/A /// introduce the same declarations repeatedly. 920SN/A virtual void ReadTentativeDefinitions( 930SN/A SmallVectorImpl<VarDecl *> &TentativeDefs) {} 949595SN/A 950SN/A /// \brief Read the set of unused file-scope declarations known to the 960SN/A /// external Sema source. 970SN/A /// 980SN/A /// The external source should append its own unused, filed-scope to the 990SN/A /// given vector of declarations. Note that this routine may be 1000SN/A /// invoked multiple times; the external source should take care not to 1010SN/A /// introduce the same declarations repeatedly. 1020SN/A virtual void ReadUnusedFileScopedDecls( 1030SN/A SmallVectorImpl<const DeclaratorDecl *> &Decls) {} 1040SN/A 1050SN/A /// \brief Read the set of delegating constructors known to the 1060SN/A /// external Sema source. 1070SN/A /// 1080SN/A /// The external source should append its own delegating constructors to the 1090SN/A /// given vector of declarations. Note that this routine may be 1100SN/A /// invoked multiple times; the external source should take care not to 1110SN/A /// introduce the same declarations repeatedly. 1120SN/A virtual void ReadDelegatingConstructors( 1130SN/A SmallVectorImpl<CXXConstructorDecl *> &Decls) {} 1140SN/A 1150SN/A /// \brief Read the set of ext_vector type declarations known to the 1160SN/A /// external Sema source. 1170SN/A /// 1180SN/A /// The external source should append its own ext_vector type declarations to 1190SN/A /// the given vector of declarations. Note that this routine may be 1200SN/A /// invoked multiple times; the external source should take care not to 1210SN/A /// introduce the same declarations repeatedly. 1220SN/A virtual void ReadExtVectorDecls(SmallVectorImpl<TypedefNameDecl *> &Decls) {} 1230SN/A 1240SN/A /// \brief Read the set of dynamic classes known to the external Sema source. 1250SN/A /// 1260SN/A /// The external source should append its own dynamic classes to 1270SN/A /// the given vector of declarations. Note that this routine may be 1280SN/A /// invoked multiple times; the external source should take care not to 1290SN/A /// introduce the same declarations repeatedly. 1300SN/A virtual void ReadDynamicClasses(SmallVectorImpl<CXXRecordDecl *> &Decls) {} 1310SN/A 1320SN/A /// \brief Read the set of locally-scoped external declarations known to the 1330SN/A /// external Sema source. 1340SN/A /// 1350SN/A /// The external source should append its own locally-scoped external 1360SN/A /// declarations to the given vector of declarations. Note that this routine 1370SN/A /// may be invoked multiple times; the external source should take care not 1380SN/A /// to introduce the same declarations repeatedly. 1390SN/A virtual void ReadLocallyScopedExternCDecls( 1400SN/A SmallVectorImpl<NamedDecl *> &Decls) {} 1410SN/A 1420SN/A /// \brief Read the set of referenced selectors known to the 1439595SN/A /// external Sema source. 1440SN/A /// 1450SN/A /// The external source should append its own referenced selectors to the 1460SN/A /// given vector of selectors. Note that this routine 1470SN/A /// may be invoked multiple times; the external source should take care not 1480SN/A /// to introduce the same selectors repeatedly. 1490SN/A virtual void ReadReferencedSelectors( 1500SN/A SmallVectorImpl<std::pair<Selector, SourceLocation> > &Sels) {} 1510SN/A 1520SN/A /// \brief Read the set of weak, undeclared identifiers known to the 1530SN/A /// external Sema source. 1540SN/A /// 1550SN/A /// The external source should append its own weak, undeclared identifiers to 1560SN/A /// the given vector. Note that this routine may be invoked multiple times; 1570SN/A /// the external source should take care not to introduce the same identifiers 1580SN/A /// repeatedly. 1590SN/A virtual void ReadWeakUndeclaredIdentifiers( 1600SN/A SmallVectorImpl<std::pair<IdentifierInfo *, WeakInfo> > &WI) {} 1610SN/A 1620SN/A /// \brief Read the set of used vtables known to the external Sema source. 1630SN/A /// 1640SN/A /// The external source should append its own used vtables to the given 1650SN/A /// vector. Note that this routine may be invoked multiple times; the external 1660SN/A /// source should take care not to introduce the same vtables repeatedly. 1670SN/A virtual void ReadUsedVTables(SmallVectorImpl<ExternalVTableUse> &VTables) {} 1680SN/A 169 /// \brief Read the set of pending instantiations known to the external 170 /// Sema source. 171 /// 172 /// The external source should append its own pending instantiations to the 173 /// given vector. Note that this routine may be invoked multiple times; the 174 /// external source should take care not to introduce the same instantiations 175 /// repeatedly. 176 virtual void ReadPendingInstantiations( 177 SmallVectorImpl<std::pair<ValueDecl *, 178 SourceLocation> > &Pending) {} 179 180 // isa/cast/dyn_cast support 181 static bool classof(const ExternalASTSource *Source) { 182 return Source->SemaSource; 183 } 184}; 185 186} // end namespace clang 187 188#endif 189