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"
18 #include "llvm/ADT/MapVector.h"
23 class CXXConstructorDecl;
27 struct ObjCMethodList;
30 class TypedefNameDecl;
34 /// \brief A simple structure that captures a vtable use for the purposes of
35 /// the \c ExternalSemaSource.
36 struct ExternalVTableUse {
37 CXXRecordDecl *Record;
38 SourceLocation Location;
39 bool DefinitionRequired;
42 /// \brief An abstract interface that should be implemented by
43 /// external AST sources that also provide information for semantic
45 class ExternalSemaSource : public ExternalASTSource {
47 ExternalSemaSource() {
48 ExternalASTSource::SemaSource = true;
51 ~ExternalSemaSource();
53 /// \brief Initialize the semantic source with the Sema instance
54 /// being used to perform semantic analysis on the abstract syntax
56 virtual void InitializeSema(Sema &S) {}
58 /// \brief Inform the semantic consumer that Sema is no longer available.
59 virtual void ForgetSema() {}
61 /// \brief Load the contents of the global method pool for a given
63 virtual void ReadMethodPool(Selector Sel);
65 /// \brief Load the set of namespaces that are known to the external source,
66 /// which will be used during typo correction.
67 virtual void ReadKnownNamespaces(
68 SmallVectorImpl<NamespaceDecl *> &Namespaces);
70 /// \brief Load the set of used but not defined functions or variables with
71 /// internal linkage, or used but not defined internal functions.
72 virtual void ReadUndefinedButUsed(
73 llvm::DenseMap<NamedDecl*, SourceLocation> &Undefined);
75 /// \brief Do last resort, unqualified lookup on a LookupResult that
78 /// \param R a LookupResult that is being recovered.
80 /// \param S the Scope of the identifier occurrence.
82 /// \return true to tell Sema to recover using the LookupResult.
83 virtual bool LookupUnqualified(LookupResult &R, Scope *S) { return false; }
85 /// \brief Read the set of tentative definitions known to the external Sema
88 /// The external source should append its own tentative definitions to the
89 /// given vector of tentative definitions. Note that this routine may be
90 /// invoked multiple times; the external source should take care not to
91 /// introduce the same declarations repeatedly.
92 virtual void ReadTentativeDefinitions(
93 SmallVectorImpl<VarDecl *> &TentativeDefs) {}
95 /// \brief Read the set of unused file-scope declarations known to the
96 /// external Sema source.
98 /// The external source should append its own unused, filed-scope to the
99 /// given vector of declarations. Note that this routine may be
100 /// invoked multiple times; the external source should take care not to
101 /// introduce the same declarations repeatedly.
102 virtual void ReadUnusedFileScopedDecls(
103 SmallVectorImpl<const DeclaratorDecl *> &Decls) {}
105 /// \brief Read the set of delegating constructors known to the
106 /// external Sema source.
108 /// The external source should append its own delegating constructors to the
109 /// given vector of declarations. Note that this routine may be
110 /// invoked multiple times; the external source should take care not to
111 /// introduce the same declarations repeatedly.
112 virtual void ReadDelegatingConstructors(
113 SmallVectorImpl<CXXConstructorDecl *> &Decls) {}
115 /// \brief Read the set of ext_vector type declarations known to the
116 /// external Sema source.
118 /// The external source should append its own ext_vector type declarations to
119 /// the given vector of declarations. Note that this routine may be
120 /// invoked multiple times; the external source should take care not to
121 /// introduce the same declarations repeatedly.
122 virtual void ReadExtVectorDecls(SmallVectorImpl<TypedefNameDecl *> &Decls) {}
124 /// \brief Read the set of dynamic classes known to the external Sema source.
126 /// The external source should append its own dynamic classes to
127 /// the given vector of declarations. Note that this routine may be
128 /// invoked multiple times; the external source should take care not to
129 /// introduce the same declarations repeatedly.
130 virtual void ReadDynamicClasses(SmallVectorImpl<CXXRecordDecl *> &Decls) {}
132 /// \brief Read the set of locally-scoped external declarations known to the
133 /// external Sema source.
135 /// The external source should append its own locally-scoped external
136 /// declarations to the given vector of declarations. Note that this routine
137 /// may be invoked multiple times; the external source should take care not
138 /// to introduce the same declarations repeatedly.
139 virtual void ReadLocallyScopedExternCDecls(
140 SmallVectorImpl<NamedDecl *> &Decls) {}
142 /// \brief Read the set of referenced selectors known to the
143 /// external Sema source.
145 /// The external source should append its own referenced selectors to the
146 /// given vector of selectors. Note that this routine
147 /// may be invoked multiple times; the external source should take care not
148 /// to introduce the same selectors repeatedly.
149 virtual void ReadReferencedSelectors(
150 SmallVectorImpl<std::pair<Selector, SourceLocation> > &Sels) {}
152 /// \brief Read the set of weak, undeclared identifiers known to the
153 /// external Sema source.
155 /// The external source should append its own weak, undeclared identifiers to
156 /// the given vector. Note that this routine may be invoked multiple times;
157 /// the external source should take care not to introduce the same identifiers
159 virtual void ReadWeakUndeclaredIdentifiers(
160 SmallVectorImpl<std::pair<IdentifierInfo *, WeakInfo> > &WI) {}
162 /// \brief Read the set of used vtables known to the external Sema source.
164 /// The external source should append its own used vtables to the given
165 /// vector. Note that this routine may be invoked multiple times; the external
166 /// source should take care not to introduce the same vtables repeatedly.
167 virtual void ReadUsedVTables(SmallVectorImpl<ExternalVTableUse> &VTables) {}
169 /// \brief Read the set of pending instantiations known to the external
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
176 virtual void ReadPendingInstantiations(
177 SmallVectorImpl<std::pair<ValueDecl *,
178 SourceLocation> > &Pending) {}
180 // isa/cast/dyn_cast support
181 static bool classof(const ExternalASTSource *Source) {
182 return Source->SemaSource;
186 } // end namespace clang