1668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor//===--- ExternalSemaSource.h - External Sema Interface ---------*- C++ -*-===// 2668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor// 3668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor// The LLVM Compiler Infrastructure 4668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor// 5668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor// This file is distributed under the University of Illinois Open Source 6668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor// License. See LICENSE.TXT for details. 7668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor// 8668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor//===----------------------------------------------------------------------===// 9668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor// 10668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor// This file defines the ExternalSemaSource interface. 11668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor// 12668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor//===----------------------------------------------------------------------===// 13668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor#ifndef LLVM_CLANG_SEMA_EXTERNAL_SEMA_SOURCE_H 14668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor#define LLVM_CLANG_SEMA_EXTERNAL_SEMA_SOURCE_H 15668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor 16668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor#include "clang/AST/ExternalASTSource.h" 1731e37b2d7b4815fdea6a35d49f33005562f0d494Douglas Gregor#include "clang/Sema/Weak.h" 188c84571f3e262569ba51d107db7ab31a23de79b3Sebastian Redl#include <utility> 19668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor 20668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregornamespace clang { 21668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor 220129b561a1452bf057f6b18b6a1de815d487ab81Douglas Gregorclass CXXConstructorDecl; 23a126f17ca83b985300c1f65cee647bea108db657Douglas Gregorclass CXXRecordDecl; 24a2ee20aa9660851080135219cac5b31fbac08b78Douglas Gregorclass DeclaratorDecl; 25a2ee20aa9660851080135219cac5b31fbac08b78Douglas Gregorclass LookupResult; 26b3737e4fcddbf1c3126eb853c0e3b366b35ceabaSebastian Redlstruct ObjCMethodList; 27f8291a190cc6765630312911f441d9e23564eda2Axel Naumannclass Scope; 28a2ee20aa9660851080135219cac5b31fbac08b78Douglas Gregorclass Sema; 29d58a0a55e64a7c410a80e9d6dcd899e61e99cc4dDouglas Gregorclass TypedefNameDecl; 306e4a3f5c59664af13e02e9bb58c2810b830e3b96Douglas Gregorclass ValueDecl; 31a862320972e63349524dc9aa744dec1b95f54ba1Douglas Gregorclass VarDecl; 32a862320972e63349524dc9aa744dec1b95f54ba1Douglas Gregor 33dfe6543e12eca5c79421378b7fa6b3e8fc403e63Douglas Gregor/// \brief A simple structure that captures a vtable use for the purposes of 34dfe6543e12eca5c79421378b7fa6b3e8fc403e63Douglas Gregor/// the \c ExternalSemaSource. 35dfe6543e12eca5c79421378b7fa6b3e8fc403e63Douglas Gregorstruct ExternalVTableUse { 36dfe6543e12eca5c79421378b7fa6b3e8fc403e63Douglas Gregor CXXRecordDecl *Record; 37dfe6543e12eca5c79421378b7fa6b3e8fc403e63Douglas Gregor SourceLocation Location; 38dfe6543e12eca5c79421378b7fa6b3e8fc403e63Douglas Gregor bool DefinitionRequired; 39dfe6543e12eca5c79421378b7fa6b3e8fc403e63Douglas Gregor}; 40dfe6543e12eca5c79421378b7fa6b3e8fc403e63Douglas Gregor 41668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor/// \brief An abstract interface that should be implemented by 42668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor/// external AST sources that also provide information for semantic 43668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor/// analysis. 44668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregorclass ExternalSemaSource : public ExternalASTSource { 45668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregorpublic: 46668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor ExternalSemaSource() { 47668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor ExternalASTSource::SemaSource = true; 48668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor } 49668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor 5076bd1f387e6a7b7abfe53f63b3bd429b97bb80f0John McCall ~ExternalSemaSource(); 5176bd1f387e6a7b7abfe53f63b3bd429b97bb80f0John McCall 52668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor /// \brief Initialize the semantic source with the Sema instance 53668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor /// being used to perform semantic analysis on the abstract syntax 54668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor /// tree. 55668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor virtual void InitializeSema(Sema &S) {} 56f0aaf7a59729a4ae0146e3464ee987745be95829Douglas Gregor 57ec2a4ed278a1112ebf84fdcb80ed66f53d8ec8baDaniel Dunbar /// \brief Inform the semantic consumer that Sema is no longer available. 58ec2a4ed278a1112ebf84fdcb80ed66f53d8ec8baDaniel Dunbar virtual void ForgetSema() {} 59ec2a4ed278a1112ebf84fdcb80ed66f53d8ec8baDaniel Dunbar 60f0aaf7a59729a4ae0146e3464ee987745be95829Douglas Gregor /// \brief Load the contents of the global method pool for a given 61f0aaf7a59729a4ae0146e3464ee987745be95829Douglas Gregor /// selector. 625ac4b6917aa34fae6da64036539023a6155a3d48Douglas Gregor virtual void ReadMethodPool(Selector Sel); 631eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 64d8bba9c15230d2b1b3893e272106aa79efc50251Douglas Gregor /// \brief Load the set of namespaces that are known to the external source, 65d8bba9c15230d2b1b3893e272106aa79efc50251Douglas Gregor /// which will be used during typo correction. 66d8bba9c15230d2b1b3893e272106aa79efc50251Douglas Gregor virtual void ReadKnownNamespaces( 67686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVectorImpl<NamespaceDecl *> &Namespaces); 68d8bba9c15230d2b1b3893e272106aa79efc50251Douglas Gregor 69f8291a190cc6765630312911f441d9e23564eda2Axel Naumann /// \brief Do last resort, unqualified lookup on a LookupResult that 70f8291a190cc6765630312911f441d9e23564eda2Axel Naumann /// Sema cannot find. 71f8291a190cc6765630312911f441d9e23564eda2Axel Naumann /// 72f8291a190cc6765630312911f441d9e23564eda2Axel Naumann /// \param R a LookupResult that is being recovered. 73f8291a190cc6765630312911f441d9e23564eda2Axel Naumann /// 74f8291a190cc6765630312911f441d9e23564eda2Axel Naumann /// \param S the Scope of the identifier occurrence. 75f8291a190cc6765630312911f441d9e23564eda2Axel Naumann /// 76f8291a190cc6765630312911f441d9e23564eda2Axel Naumann /// \return true to tell Sema to recover using the LookupResult. 77f8291a190cc6765630312911f441d9e23564eda2Axel Naumann virtual bool LookupUnqualified(LookupResult &R, Scope *S) { return false; } 78f8291a190cc6765630312911f441d9e23564eda2Axel Naumann 79a2ee20aa9660851080135219cac5b31fbac08b78Douglas Gregor /// \brief Read the set of tentative definitions known to the external Sema 80a862320972e63349524dc9aa744dec1b95f54ba1Douglas Gregor /// source. 81a862320972e63349524dc9aa744dec1b95f54ba1Douglas Gregor /// 82a862320972e63349524dc9aa744dec1b95f54ba1Douglas Gregor /// The external source should append its own tentative definitions to the 83a862320972e63349524dc9aa744dec1b95f54ba1Douglas Gregor /// given vector of tentative definitions. Note that this routine may be 84a862320972e63349524dc9aa744dec1b95f54ba1Douglas Gregor /// invoked multiple times; the external source should take care not to 85a862320972e63349524dc9aa744dec1b95f54ba1Douglas Gregor /// introduce the same declarations repeatedly. 86a862320972e63349524dc9aa744dec1b95f54ba1Douglas Gregor virtual void ReadTentativeDefinitions( 87a862320972e63349524dc9aa744dec1b95f54ba1Douglas Gregor SmallVectorImpl<VarDecl *> &TentativeDefs) {} 88a862320972e63349524dc9aa744dec1b95f54ba1Douglas Gregor 89a2ee20aa9660851080135219cac5b31fbac08b78Douglas Gregor /// \brief Read the set of unused file-scope declarations known to the 90a2ee20aa9660851080135219cac5b31fbac08b78Douglas Gregor /// external Sema source. 91a2ee20aa9660851080135219cac5b31fbac08b78Douglas Gregor /// 92a2ee20aa9660851080135219cac5b31fbac08b78Douglas Gregor /// The external source should append its own unused, filed-scope to the 93a2ee20aa9660851080135219cac5b31fbac08b78Douglas Gregor /// given vector of declarations. Note that this routine may be 94a2ee20aa9660851080135219cac5b31fbac08b78Douglas Gregor /// invoked multiple times; the external source should take care not to 95a2ee20aa9660851080135219cac5b31fbac08b78Douglas Gregor /// introduce the same declarations repeatedly. 96a2ee20aa9660851080135219cac5b31fbac08b78Douglas Gregor virtual void ReadUnusedFileScopedDecls( 97a2ee20aa9660851080135219cac5b31fbac08b78Douglas Gregor SmallVectorImpl<const DeclaratorDecl *> &Decls) {} 98a2ee20aa9660851080135219cac5b31fbac08b78Douglas Gregor 990129b561a1452bf057f6b18b6a1de815d487ab81Douglas Gregor /// \brief Read the set of delegating constructors known to the 1000129b561a1452bf057f6b18b6a1de815d487ab81Douglas Gregor /// external Sema source. 1010129b561a1452bf057f6b18b6a1de815d487ab81Douglas Gregor /// 1020129b561a1452bf057f6b18b6a1de815d487ab81Douglas Gregor /// The external source should append its own delegating constructors to the 1030129b561a1452bf057f6b18b6a1de815d487ab81Douglas Gregor /// given vector of declarations. Note that this routine may be 1040129b561a1452bf057f6b18b6a1de815d487ab81Douglas Gregor /// invoked multiple times; the external source should take care not to 1050129b561a1452bf057f6b18b6a1de815d487ab81Douglas Gregor /// introduce the same declarations repeatedly. 1060129b561a1452bf057f6b18b6a1de815d487ab81Douglas Gregor virtual void ReadDelegatingConstructors( 1070129b561a1452bf057f6b18b6a1de815d487ab81Douglas Gregor SmallVectorImpl<CXXConstructorDecl *> &Decls) {} 108d58a0a55e64a7c410a80e9d6dcd899e61e99cc4dDouglas Gregor 109d58a0a55e64a7c410a80e9d6dcd899e61e99cc4dDouglas Gregor /// \brief Read the set of ext_vector type declarations known to the 110d58a0a55e64a7c410a80e9d6dcd899e61e99cc4dDouglas Gregor /// external Sema source. 111d58a0a55e64a7c410a80e9d6dcd899e61e99cc4dDouglas Gregor /// 112d58a0a55e64a7c410a80e9d6dcd899e61e99cc4dDouglas Gregor /// The external source should append its own ext_vector type declarations to 113d58a0a55e64a7c410a80e9d6dcd899e61e99cc4dDouglas Gregor /// the given vector of declarations. Note that this routine may be 114d58a0a55e64a7c410a80e9d6dcd899e61e99cc4dDouglas Gregor /// invoked multiple times; the external source should take care not to 115d58a0a55e64a7c410a80e9d6dcd899e61e99cc4dDouglas Gregor /// introduce the same declarations repeatedly. 116d58a0a55e64a7c410a80e9d6dcd899e61e99cc4dDouglas Gregor virtual void ReadExtVectorDecls(SmallVectorImpl<TypedefNameDecl *> &Decls) {} 117d58a0a55e64a7c410a80e9d6dcd899e61e99cc4dDouglas Gregor 118a126f17ca83b985300c1f65cee647bea108db657Douglas Gregor /// \brief Read the set of dynamic classes known to the external Sema source. 119a126f17ca83b985300c1f65cee647bea108db657Douglas Gregor /// 120a126f17ca83b985300c1f65cee647bea108db657Douglas Gregor /// The external source should append its own dynamic classes to 121a126f17ca83b985300c1f65cee647bea108db657Douglas Gregor /// the given vector of declarations. Note that this routine may be 122a126f17ca83b985300c1f65cee647bea108db657Douglas Gregor /// invoked multiple times; the external source should take care not to 123a126f17ca83b985300c1f65cee647bea108db657Douglas Gregor /// introduce the same declarations repeatedly. 124a126f17ca83b985300c1f65cee647bea108db657Douglas Gregor virtual void ReadDynamicClasses(SmallVectorImpl<CXXRecordDecl *> &Decls) {} 125a126f17ca83b985300c1f65cee647bea108db657Douglas Gregor 126ec12ce2f6da44bfc9048772327a3924498099d60Douglas Gregor /// \brief Read the set of locally-scoped external declarations known to the 127ec12ce2f6da44bfc9048772327a3924498099d60Douglas Gregor /// external Sema source. 128ec12ce2f6da44bfc9048772327a3924498099d60Douglas Gregor /// 129ec12ce2f6da44bfc9048772327a3924498099d60Douglas Gregor /// The external source should append its own locally-scoped external 130ec12ce2f6da44bfc9048772327a3924498099d60Douglas Gregor /// declarations to the given vector of declarations. Note that this routine 131ec12ce2f6da44bfc9048772327a3924498099d60Douglas Gregor /// may be invoked multiple times; the external source should take care not 132ec12ce2f6da44bfc9048772327a3924498099d60Douglas Gregor /// to introduce the same declarations repeatedly. 133ec12ce2f6da44bfc9048772327a3924498099d60Douglas Gregor virtual void ReadLocallyScopedExternalDecls( 134ec12ce2f6da44bfc9048772327a3924498099d60Douglas Gregor SmallVectorImpl<NamedDecl *> &Decls) {} 1355b9dc7caaef0469babc45dd8e713727a136ce517Douglas Gregor 1365b9dc7caaef0469babc45dd8e713727a136ce517Douglas Gregor /// \brief Read the set of referenced selectors known to the 1375b9dc7caaef0469babc45dd8e713727a136ce517Douglas Gregor /// external Sema source. 1385b9dc7caaef0469babc45dd8e713727a136ce517Douglas Gregor /// 1395b9dc7caaef0469babc45dd8e713727a136ce517Douglas Gregor /// The external source should append its own referenced selectors to the 14031e37b2d7b4815fdea6a35d49f33005562f0d494Douglas Gregor /// given vector of selectors. Note that this routine 1415b9dc7caaef0469babc45dd8e713727a136ce517Douglas Gregor /// may be invoked multiple times; the external source should take care not 1425b9dc7caaef0469babc45dd8e713727a136ce517Douglas Gregor /// to introduce the same selectors repeatedly. 1435b9dc7caaef0469babc45dd8e713727a136ce517Douglas Gregor virtual void ReadReferencedSelectors( 1445b9dc7caaef0469babc45dd8e713727a136ce517Douglas Gregor SmallVectorImpl<std::pair<Selector, SourceLocation> > &Sels) {} 1455b9dc7caaef0469babc45dd8e713727a136ce517Douglas Gregor 14631e37b2d7b4815fdea6a35d49f33005562f0d494Douglas Gregor /// \brief Read the set of weak, undeclared identifiers known to the 14731e37b2d7b4815fdea6a35d49f33005562f0d494Douglas Gregor /// external Sema source. 14831e37b2d7b4815fdea6a35d49f33005562f0d494Douglas Gregor /// 14931e37b2d7b4815fdea6a35d49f33005562f0d494Douglas Gregor /// The external source should append its own weak, undeclared identifiers to 15031e37b2d7b4815fdea6a35d49f33005562f0d494Douglas Gregor /// the given vector. Note that this routine may be invoked multiple times; 15131e37b2d7b4815fdea6a35d49f33005562f0d494Douglas Gregor /// the external source should take care not to introduce the same identifiers 15231e37b2d7b4815fdea6a35d49f33005562f0d494Douglas Gregor /// repeatedly. 15331e37b2d7b4815fdea6a35d49f33005562f0d494Douglas Gregor virtual void ReadWeakUndeclaredIdentifiers( 15431e37b2d7b4815fdea6a35d49f33005562f0d494Douglas Gregor SmallVectorImpl<std::pair<IdentifierInfo *, WeakInfo> > &WI) {} 15531e37b2d7b4815fdea6a35d49f33005562f0d494Douglas Gregor 156dfe6543e12eca5c79421378b7fa6b3e8fc403e63Douglas Gregor /// \brief Read the set of used vtables known to the external Sema source. 157dfe6543e12eca5c79421378b7fa6b3e8fc403e63Douglas Gregor /// 158dfe6543e12eca5c79421378b7fa6b3e8fc403e63Douglas Gregor /// The external source should append its own used vtables to the given 159dfe6543e12eca5c79421378b7fa6b3e8fc403e63Douglas Gregor /// vector. Note that this routine may be invoked multiple times; the external 160dfe6543e12eca5c79421378b7fa6b3e8fc403e63Douglas Gregor /// source should take care not to introduce the same vtables repeatedly. 161dfe6543e12eca5c79421378b7fa6b3e8fc403e63Douglas Gregor virtual void ReadUsedVTables(SmallVectorImpl<ExternalVTableUse> &VTables) {} 162dfe6543e12eca5c79421378b7fa6b3e8fc403e63Douglas Gregor 1636e4a3f5c59664af13e02e9bb58c2810b830e3b96Douglas Gregor /// \brief Read the set of pending instantiations known to the external 1646e4a3f5c59664af13e02e9bb58c2810b830e3b96Douglas Gregor /// Sema source. 1656e4a3f5c59664af13e02e9bb58c2810b830e3b96Douglas Gregor /// 1666e4a3f5c59664af13e02e9bb58c2810b830e3b96Douglas Gregor /// The external source should append its own pending instantiations to the 1676e4a3f5c59664af13e02e9bb58c2810b830e3b96Douglas Gregor /// given vector. Note that this routine may be invoked multiple times; the 1686e4a3f5c59664af13e02e9bb58c2810b830e3b96Douglas Gregor /// external source should take care not to introduce the same instantiations 1696e4a3f5c59664af13e02e9bb58c2810b830e3b96Douglas Gregor /// repeatedly. 1706e4a3f5c59664af13e02e9bb58c2810b830e3b96Douglas Gregor virtual void ReadPendingInstantiations( 1716e4a3f5c59664af13e02e9bb58c2810b830e3b96Douglas Gregor SmallVectorImpl<std::pair<ValueDecl *, 1726e4a3f5c59664af13e02e9bb58c2810b830e3b96Douglas Gregor SourceLocation> > &Pending) {} 1736e4a3f5c59664af13e02e9bb58c2810b830e3b96Douglas Gregor 174668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor // isa/cast/dyn_cast support 1751eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const ExternalASTSource *Source) { 176668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor return Source->SemaSource; 177668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor } 178668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor static bool classof(const ExternalSemaSource *) { return true; } 179a862320972e63349524dc9aa744dec1b95f54ba1Douglas Gregor}; 180668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor 181668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor} // end namespace clang 182668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor 183668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor#endif 184