ExternalSemaSource.h revision ac32d9044b9c1e7492cef929a322d23ce899d276
15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//===--- ExternalSemaSource.h - External Sema Interface ---------*- C++ -*-===// 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// The LLVM Compiler Infrastructure 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// This file is distributed under the University of Illinois Open Source 65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// License. See LICENSE.TXT for details. 75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//===----------------------------------------------------------------------===// 92a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// 102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// This file defines the ExternalSemaSource interface. 115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//===----------------------------------------------------------------------===// 13868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#ifndef LLVM_CLANG_SEMA_EXTERNAL_SEMA_SOURCE_H 145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define LLVM_CLANG_SEMA_EXTERNAL_SEMA_SOURCE_H 155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "clang/AST/ExternalASTSource.h" 175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "clang/Sema/Weak.h" 185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "llvm/ADT/MapVector.h" 195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <utility> 205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace clang { 225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class CXXConstructorDecl; 245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class CXXRecordDecl; 255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class DeclaratorDecl; 265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class LookupResult; 275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)struct ObjCMethodList; 285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class Scope; 295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class Sema; 305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class TypedefNameDecl; 315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class ValueDecl; 325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class VarDecl; 335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct LateParsedTemplate; 345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/// \brief A simple structure that captures a vtable use for the purposes of 3690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)/// the \c ExternalSemaSource. 375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct ExternalVTableUse { 385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) CXXRecordDecl *Record; 395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SourceLocation Location; 405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool DefinitionRequired; 415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}; 425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/// \brief An abstract interface that should be implemented by 445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/// external AST sources that also provide information for semantic 455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/// analysis. 465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class ExternalSemaSource : public ExternalASTSource { 475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)public: 485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ExternalSemaSource() { 495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ExternalASTSource::SemaSource = true; 505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ~ExternalSemaSource(); 535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// \brief Initialize the semantic source with the Sema instance 555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// being used to perform semantic analysis on the abstract syntax 565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// tree. 572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual void InitializeSema(Sema &S) {} 582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) /// \brief Inform the semantic consumer that Sema is no longer available. 605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void ForgetSema() {} 615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// \brief Load the contents of the global method pool for a given 635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// selector. 645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void ReadMethodPool(Selector Sel); 655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// \brief Load the set of namespaces that are known to the external source, 675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// which will be used during typo correction. 685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void ReadKnownNamespaces( 695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SmallVectorImpl<NamespaceDecl *> &Namespaces); 705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// \brief Load the set of used but not defined functions or variables with 725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// internal linkage, or used but not defined internal functions. 735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void ReadUndefinedButUsed( 745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) llvm::DenseMap<NamedDecl*, SourceLocation> &Undefined); 755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// \brief Do last resort, unqualified lookup on a LookupResult that 775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// Sema cannot find. 785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) /// 795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) /// \param R a LookupResult that is being recovered. 805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) /// 815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// \param S the Scope of the identifier occurrence. 825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// 835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// \return true to tell Sema to recover using the LookupResult. 845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool LookupUnqualified(LookupResult &R, Scope *S) { return false; } 855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// \brief Read the set of tentative definitions known to the external Sema 875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// source. 885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// 895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// The external source should append its own tentative definitions to the 905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// given vector of tentative definitions. Note that this routine may be 915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// invoked multiple times; the external source should take care not to 925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// introduce the same declarations repeatedly. 935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void ReadTentativeDefinitions( 945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SmallVectorImpl<VarDecl *> &TentativeDefs) {} 955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// \brief Read the set of unused file-scope declarations known to the 975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// external Sema source. 985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// 995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// The external source should append its own unused, filed-scope to the 1005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// given vector of declarations. Note that this routine may be 1015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// invoked multiple times; the external source should take care not to 1025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// introduce the same declarations repeatedly. 1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void ReadUnusedFileScopedDecls( 1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SmallVectorImpl<const DeclaratorDecl *> &Decls) {} 1055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// \brief Read the set of delegating constructors known to the 1075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// external Sema source. 1085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// 1095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// The external source should append its own delegating constructors to the 1105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// given vector of declarations. Note that this routine may be 1115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// invoked multiple times; the external source should take care not to 1125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// introduce the same declarations repeatedly. 1135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void ReadDelegatingConstructors( 1145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SmallVectorImpl<CXXConstructorDecl *> &Decls) {} 1155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// \brief Read the set of ext_vector type declarations known to the 1175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// external Sema source. 1185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// 1195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// The external source should append its own ext_vector type declarations to 1205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// the given vector of declarations. Note that this routine may be 121a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) /// invoked multiple times; the external source should take care not to 122a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) /// introduce the same declarations repeatedly. 123a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) virtual void ReadExtVectorDecls(SmallVectorImpl<TypedefNameDecl *> &Decls) {} 124a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 1255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// \brief Read the set of dynamic classes known to the external Sema source. 1265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// 1275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// The external source should append its own dynamic classes to 1285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// the given vector of declarations. Note that this routine may be 1295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// invoked multiple times; the external source should take care not to 1305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// introduce the same declarations repeatedly. 1315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void ReadDynamicClasses(SmallVectorImpl<CXXRecordDecl *> &Decls) {} 1325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// \brief Read the set of locally-scoped external declarations known to the 1345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// external Sema source. 1355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// 1365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// The external source should append its own locally-scoped external 1375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// declarations to the given vector of declarations. Note that this routine 138a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) /// may be invoked multiple times; the external source should take care not 139a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) /// to introduce the same declarations repeatedly. 140a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) virtual void ReadLocallyScopedExternCDecls( 141a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) SmallVectorImpl<NamedDecl *> &Decls) {} 142a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 143a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) /// \brief Read the set of referenced selectors known to the 1445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// external Sema source. 1455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// 1465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// The external source should append its own referenced selectors to the 1475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// given vector of selectors. Note that this routine 1485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// may be invoked multiple times; the external source should take care not 1495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// to introduce the same selectors repeatedly. 1505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void ReadReferencedSelectors( 1515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SmallVectorImpl<std::pair<Selector, SourceLocation> > &Sels) {} 1525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// \brief Read the set of weak, undeclared identifiers known to the 1545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// external Sema source. 1555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// 1565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// The external source should append its own weak, undeclared identifiers to 1575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// the given vector. Note that this routine may be invoked multiple times; 1585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// the external source should take care not to introduce the same identifiers 1595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// repeatedly. 16090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) virtual void ReadWeakUndeclaredIdentifiers( 1615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SmallVectorImpl<std::pair<IdentifierInfo *, WeakInfo> > &WI) {} 1625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// \brief Read the set of used vtables known to the external Sema source. 1645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// 165 /// The external source should append its own used vtables to the given 166 /// vector. Note that this routine may be invoked multiple times; the external 167 /// source should take care not to introduce the same vtables repeatedly. 168 virtual void ReadUsedVTables(SmallVectorImpl<ExternalVTableUse> &VTables) {} 169 170 /// \brief Read the set of pending instantiations known to the external 171 /// Sema source. 172 /// 173 /// The external source should append its own pending instantiations to the 174 /// given vector. Note that this routine may be invoked multiple times; the 175 /// external source should take care not to introduce the same instantiations 176 /// repeatedly. 177 virtual void ReadPendingInstantiations( 178 SmallVectorImpl<std::pair<ValueDecl *, 179 SourceLocation> > &Pending) {} 180 181 /// \brief Read the set of late parsed template functions for this source. 182 /// 183 /// The external source should insert its own late parsed template functions 184 /// into the map. Note that this routine may be invoked multiple times; the 185 /// external source should take care not to introduce the same map entries 186 /// repeatedly. 187 virtual void ReadLateParsedTemplates( 188 llvm::DenseMap<const FunctionDecl *, LateParsedTemplate *> &LPTMap) {} 189 190 // isa/cast/dyn_cast support 191 static bool classof(const ExternalASTSource *Source) { 192 return Source->SemaSource; 193 } 194}; 195 196} // end namespace clang 197 198#endif 199