clang API Documentation

ExternalSemaSource.h
Go to the documentation of this file.
00001 //===--- ExternalSemaSource.h - External Sema Interface ---------*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 //  This file defines the ExternalSemaSource interface.
00011 //
00012 //===----------------------------------------------------------------------===//
00013 #ifndef LLVM_CLANG_SEMA_EXTERNAL_SEMA_SOURCE_H
00014 #define LLVM_CLANG_SEMA_EXTERNAL_SEMA_SOURCE_H
00015 
00016 #include "clang/AST/ExternalASTSource.h"
00017 #include "clang/Sema/Weak.h"
00018 #include <utility>
00019 
00020 namespace clang {
00021 
00022 class CXXConstructorDecl;
00023 class CXXRecordDecl;
00024 class DeclaratorDecl;
00025 class LookupResult;
00026 struct ObjCMethodList;
00027 class Scope;
00028 class Sema;
00029 class TypedefNameDecl;
00030 class ValueDecl;
00031 class VarDecl;
00032   
00033 /// \brief A simple structure that captures a vtable use for the purposes of
00034 /// the \c ExternalSemaSource.
00035 struct ExternalVTableUse {
00036   CXXRecordDecl *Record;
00037   SourceLocation Location;
00038   bool DefinitionRequired;
00039 };
00040   
00041 /// \brief An abstract interface that should be implemented by
00042 /// external AST sources that also provide information for semantic
00043 /// analysis.
00044 class ExternalSemaSource : public ExternalASTSource {
00045 public:
00046   ExternalSemaSource() {
00047     ExternalASTSource::SemaSource = true;
00048   }
00049 
00050   ~ExternalSemaSource();
00051 
00052   /// \brief Initialize the semantic source with the Sema instance
00053   /// being used to perform semantic analysis on the abstract syntax
00054   /// tree.
00055   virtual void InitializeSema(Sema &S) {}
00056 
00057   /// \brief Inform the semantic consumer that Sema is no longer available.
00058   virtual void ForgetSema() {}
00059 
00060   /// \brief Load the contents of the global method pool for a given
00061   /// selector.
00062   virtual void ReadMethodPool(Selector Sel);
00063 
00064   /// \brief Load the set of namespaces that are known to the external source,
00065   /// which will be used during typo correction.
00066   virtual void ReadKnownNamespaces(
00067                            SmallVectorImpl<NamespaceDecl *> &Namespaces);
00068   
00069   /// \brief Do last resort, unqualified lookup on a LookupResult that
00070   /// Sema cannot find.
00071   ///
00072   /// \param R a LookupResult that is being recovered.
00073   ///
00074   /// \param S the Scope of the identifier occurrence.
00075   ///
00076   /// \return true to tell Sema to recover using the LookupResult.
00077   virtual bool LookupUnqualified(LookupResult &R, Scope *S) { return false; }
00078 
00079   /// \brief Read the set of tentative definitions known to the external Sema
00080   /// source.
00081   ///
00082   /// The external source should append its own tentative definitions to the
00083   /// given vector of tentative definitions. Note that this routine may be
00084   /// invoked multiple times; the external source should take care not to
00085   /// introduce the same declarations repeatedly.
00086   virtual void ReadTentativeDefinitions(
00087                                   SmallVectorImpl<VarDecl *> &TentativeDefs) {}
00088   
00089   /// \brief Read the set of unused file-scope declarations known to the
00090   /// external Sema source.
00091   ///
00092   /// The external source should append its own unused, filed-scope to the
00093   /// given vector of declarations. Note that this routine may be
00094   /// invoked multiple times; the external source should take care not to
00095   /// introduce the same declarations repeatedly.
00096   virtual void ReadUnusedFileScopedDecls(
00097                  SmallVectorImpl<const DeclaratorDecl *> &Decls) {}
00098   
00099   /// \brief Read the set of delegating constructors known to the
00100   /// external Sema source.
00101   ///
00102   /// The external source should append its own delegating constructors to the
00103   /// given vector of declarations. Note that this routine may be
00104   /// invoked multiple times; the external source should take care not to
00105   /// introduce the same declarations repeatedly.
00106   virtual void ReadDelegatingConstructors(
00107                  SmallVectorImpl<CXXConstructorDecl *> &Decls) {}
00108 
00109   /// \brief Read the set of ext_vector type declarations known to the
00110   /// external Sema source.
00111   ///
00112   /// The external source should append its own ext_vector type declarations to
00113   /// the given vector of declarations. Note that this routine may be
00114   /// invoked multiple times; the external source should take care not to
00115   /// introduce the same declarations repeatedly.
00116   virtual void ReadExtVectorDecls(SmallVectorImpl<TypedefNameDecl *> &Decls) {}
00117 
00118   /// \brief Read the set of dynamic classes known to the external Sema source.
00119   ///
00120   /// The external source should append its own dynamic classes to
00121   /// the given vector of declarations. Note that this routine may be
00122   /// invoked multiple times; the external source should take care not to
00123   /// introduce the same declarations repeatedly.
00124   virtual void ReadDynamicClasses(SmallVectorImpl<CXXRecordDecl *> &Decls) {}
00125 
00126   /// \brief Read the set of locally-scoped external declarations known to the
00127   /// external Sema source.
00128   ///
00129   /// The external source should append its own locally-scoped external
00130   /// declarations to the given vector of declarations. Note that this routine 
00131   /// may be invoked multiple times; the external source should take care not 
00132   /// to introduce the same declarations repeatedly.
00133   virtual void ReadLocallyScopedExternalDecls(
00134                  SmallVectorImpl<NamedDecl *> &Decls) {}
00135 
00136   /// \brief Read the set of referenced selectors known to the
00137   /// external Sema source.
00138   ///
00139   /// The external source should append its own referenced selectors to the 
00140   /// given vector of selectors. Note that this routine 
00141   /// may be invoked multiple times; the external source should take care not 
00142   /// to introduce the same selectors repeatedly.
00143   virtual void ReadReferencedSelectors(
00144                  SmallVectorImpl<std::pair<Selector, SourceLocation> > &Sels) {}
00145 
00146   /// \brief Read the set of weak, undeclared identifiers known to the
00147   /// external Sema source.
00148   ///
00149   /// The external source should append its own weak, undeclared identifiers to
00150   /// the given vector. Note that this routine may be invoked multiple times; 
00151   /// the external source should take care not to introduce the same identifiers
00152   /// repeatedly.
00153   virtual void ReadWeakUndeclaredIdentifiers(
00154                  SmallVectorImpl<std::pair<IdentifierInfo *, WeakInfo> > &WI) {}
00155 
00156   /// \brief Read the set of used vtables known to the external Sema source.
00157   ///
00158   /// The external source should append its own used vtables to the given
00159   /// vector. Note that this routine may be invoked multiple times; the external
00160   /// source should take care not to introduce the same vtables repeatedly.
00161   virtual void ReadUsedVTables(SmallVectorImpl<ExternalVTableUse> &VTables) {}
00162 
00163   /// \brief Read the set of pending instantiations known to the external
00164   /// Sema source.
00165   ///
00166   /// The external source should append its own pending instantiations to the
00167   /// given vector. Note that this routine may be invoked multiple times; the
00168   /// external source should take care not to introduce the same instantiations
00169   /// repeatedly.
00170   virtual void ReadPendingInstantiations(
00171                  SmallVectorImpl<std::pair<ValueDecl *, 
00172                                            SourceLocation> > &Pending) {}
00173 
00174   // isa/cast/dyn_cast support
00175   static bool classof(const ExternalASTSource *Source) {
00176     return Source->SemaSource;
00177   }
00178   static bool classof(const ExternalSemaSource *) { return true; }
00179 }; 
00180 
00181 } // end namespace clang
00182 
00183 #endif