1 //===--- ExternalSemaSource.h - External Sema Interface ---------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines the ExternalSemaSource interface.
12 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_CLANG_SEMA_EXTERNAL_SEMA_SOURCE_H
14 #define LLVM_CLANG_SEMA_EXTERNAL_SEMA_SOURCE_H
16 #include "clang/AST/ExternalASTSource.h"
17 #include "clang/Sema/Weak.h"
22 class CXXConstructorDecl;
26 struct ObjCMethodList;
29 class TypedefNameDecl;
33 /// \brief A simple structure that captures a vtable use for the purposes of
34 /// the \c ExternalSemaSource.
35 struct ExternalVTableUse {
36 CXXRecordDecl *Record;
37 SourceLocation Location;
38 bool DefinitionRequired;
41 /// \brief An abstract interface that should be implemented by
42 /// external AST sources that also provide information for semantic
44 class ExternalSemaSource : public ExternalASTSource {
46 ExternalSemaSource() {
47 ExternalASTSource::SemaSource = true;
50 ~ExternalSemaSource();
52 /// \brief Initialize the semantic source with the Sema instance
53 /// being used to perform semantic analysis on the abstract syntax
55 virtual void InitializeSema(Sema &S) {}
57 /// \brief Inform the semantic consumer that Sema is no longer available.
58 virtual void ForgetSema() {}
60 /// \brief Load the contents of the global method pool for a given
63 /// \returns a pair of Objective-C methods lists containing the
64 /// instance and factory methods, respectively, with this selector.
65 virtual std::pair<ObjCMethodList,ObjCMethodList> ReadMethodPool(Selector Sel);
67 /// \brief Load the set of namespaces that are known to the external source,
68 /// which will be used during typo correction.
69 virtual void ReadKnownNamespaces(
70 SmallVectorImpl<NamespaceDecl *> &Namespaces);
72 /// \brief Do last resort, unqualified lookup on a LookupResult that
75 /// \param R a LookupResult that is being recovered.
77 /// \param S the Scope of the identifier occurrence.
79 /// \return true to tell Sema to recover using the LookupResult.
80 virtual bool LookupUnqualified(LookupResult &R, Scope *S) { return false; }
82 /// \brief Read the set of tentative definitions known to the external Sema
85 /// The external source should append its own tentative definitions to the
86 /// given vector of tentative definitions. Note that this routine may be
87 /// invoked multiple times; the external source should take care not to
88 /// introduce the same declarations repeatedly.
89 virtual void ReadTentativeDefinitions(
90 SmallVectorImpl<VarDecl *> &TentativeDefs) {}
92 /// \brief Read the set of unused file-scope declarations known to the
93 /// external Sema source.
95 /// The external source should append its own unused, filed-scope to the
96 /// given vector of declarations. Note that this routine may be
97 /// invoked multiple times; the external source should take care not to
98 /// introduce the same declarations repeatedly.
99 virtual void ReadUnusedFileScopedDecls(
100 SmallVectorImpl<const DeclaratorDecl *> &Decls) {}
102 /// \brief Read the set of delegating constructors known to the
103 /// external Sema source.
105 /// The external source should append its own delegating constructors to the
106 /// given vector of declarations. Note that this routine may be
107 /// invoked multiple times; the external source should take care not to
108 /// introduce the same declarations repeatedly.
109 virtual void ReadDelegatingConstructors(
110 SmallVectorImpl<CXXConstructorDecl *> &Decls) {}
112 /// \brief Read the set of ext_vector type declarations known to the
113 /// external Sema source.
115 /// The external source should append its own ext_vector type declarations to
116 /// the given vector of declarations. Note that this routine may be
117 /// invoked multiple times; the external source should take care not to
118 /// introduce the same declarations repeatedly.
119 virtual void ReadExtVectorDecls(SmallVectorImpl<TypedefNameDecl *> &Decls) {}
121 /// \brief Read the set of dynamic classes known to the external Sema source.
123 /// The external source should append its own dynamic classes to
124 /// the given vector of declarations. Note that this routine may be
125 /// invoked multiple times; the external source should take care not to
126 /// introduce the same declarations repeatedly.
127 virtual void ReadDynamicClasses(SmallVectorImpl<CXXRecordDecl *> &Decls) {}
129 /// \brief Read the set of locally-scoped external declarations known to the
130 /// external Sema source.
132 /// The external source should append its own locally-scoped external
133 /// declarations to the given vector of declarations. Note that this routine
134 /// may be invoked multiple times; the external source should take care not
135 /// to introduce the same declarations repeatedly.
136 virtual void ReadLocallyScopedExternalDecls(
137 SmallVectorImpl<NamedDecl *> &Decls) {}
139 /// \brief Read the set of referenced selectors known to the
140 /// external Sema source.
142 /// The external source should append its own referenced selectors to the
143 /// given vector of selectors. Note that this routine
144 /// may be invoked multiple times; the external source should take care not
145 /// to introduce the same selectors repeatedly.
146 virtual void ReadReferencedSelectors(
147 SmallVectorImpl<std::pair<Selector, SourceLocation> > &Sels) {}
149 /// \brief Read the set of weak, undeclared identifiers known to the
150 /// external Sema source.
152 /// The external source should append its own weak, undeclared identifiers to
153 /// the given vector. Note that this routine may be invoked multiple times;
154 /// the external source should take care not to introduce the same identifiers
156 virtual void ReadWeakUndeclaredIdentifiers(
157 SmallVectorImpl<std::pair<IdentifierInfo *, WeakInfo> > &WI) {}
159 /// \brief Read the set of used vtables known to the external Sema source.
161 /// The external source should append its own used vtables to the given
162 /// vector. Note that this routine may be invoked multiple times; the external
163 /// source should take care not to introduce the same vtables repeatedly.
164 virtual void ReadUsedVTables(SmallVectorImpl<ExternalVTableUse> &VTables) {}
166 /// \brief Read the set of pending instantiations known to the external
169 /// The external source should append its own pending instantiations to the
170 /// given vector. Note that this routine may be invoked multiple times; the
171 /// external source should take care not to introduce the same instantiations
173 virtual void ReadPendingInstantiations(
174 SmallVectorImpl<std::pair<ValueDecl *,
175 SourceLocation> > &Pending) {}
177 // isa/cast/dyn_cast support
178 static bool classof(const ExternalASTSource *Source) {
179 return Source->SemaSource;
181 static bool classof(const ExternalSemaSource *) { return true; }
184 } // end namespace clang