]> git.proxmox.com Git - rustc.git/blob - src/llvm/tools/clang/include/clang/Sema/ExternalSemaSource.h
Imported Upstream version 0.6
[rustc.git] / src / llvm / tools / clang / include / clang / Sema / ExternalSemaSource.h
1 //===--- ExternalSemaSource.h - External Sema Interface ---------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines the ExternalSemaSource interface.
11 //
12 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_CLANG_SEMA_EXTERNAL_SEMA_SOURCE_H
14 #define LLVM_CLANG_SEMA_EXTERNAL_SEMA_SOURCE_H
15
16 #include "clang/AST/ExternalASTSource.h"
17 #include "clang/Sema/Weak.h"
18 #include <utility>
19
20 namespace clang {
21
22 class CXXConstructorDecl;
23 class CXXRecordDecl;
24 class DeclaratorDecl;
25 class LookupResult;
26 struct ObjCMethodList;
27 class Scope;
28 class Sema;
29 class TypedefNameDecl;
30 class ValueDecl;
31 class VarDecl;
32
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;
39 };
40
41 /// \brief An abstract interface that should be implemented by
42 /// external AST sources that also provide information for semantic
43 /// analysis.
44 class ExternalSemaSource : public ExternalASTSource {
45 public:
46 ExternalSemaSource() {
47 ExternalASTSource::SemaSource = true;
48 }
49
50 ~ExternalSemaSource();
51
52 /// \brief Initialize the semantic source with the Sema instance
53 /// being used to perform semantic analysis on the abstract syntax
54 /// tree.
55 virtual void InitializeSema(Sema &S) {}
56
57 /// \brief Inform the semantic consumer that Sema is no longer available.
58 virtual void ForgetSema() {}
59
60 /// \brief Load the contents of the global method pool for a given
61 /// selector.
62 virtual void ReadMethodPool(Selector Sel);
63
64 /// \brief Load the set of namespaces that are known to the external source,
65 /// which will be used during typo correction.
66 virtual void ReadKnownNamespaces(
67 SmallVectorImpl<NamespaceDecl *> &Namespaces);
68
69 /// \brief Do last resort, unqualified lookup on a LookupResult that
70 /// Sema cannot find.
71 ///
72 /// \param R a LookupResult that is being recovered.
73 ///
74 /// \param S the Scope of the identifier occurrence.
75 ///
76 /// \return true to tell Sema to recover using the LookupResult.
77 virtual bool LookupUnqualified(LookupResult &R, Scope *S) { return false; }
78
79 /// \brief Read the set of tentative definitions known to the external Sema
80 /// source.
81 ///
82 /// The external source should append its own tentative definitions to the
83 /// given vector of tentative definitions. Note that this routine may be
84 /// invoked multiple times; the external source should take care not to
85 /// introduce the same declarations repeatedly.
86 virtual void ReadTentativeDefinitions(
87 SmallVectorImpl<VarDecl *> &TentativeDefs) {}
88
89 /// \brief Read the set of unused file-scope declarations known to the
90 /// external Sema source.
91 ///
92 /// The external source should append its own unused, filed-scope to the
93 /// given vector of declarations. Note that this routine may be
94 /// invoked multiple times; the external source should take care not to
95 /// introduce the same declarations repeatedly.
96 virtual void ReadUnusedFileScopedDecls(
97 SmallVectorImpl<const DeclaratorDecl *> &Decls) {}
98
99 /// \brief Read the set of delegating constructors known to the
100 /// external Sema source.
101 ///
102 /// The external source should append its own delegating constructors to the
103 /// given vector of declarations. Note that this routine may be
104 /// invoked multiple times; the external source should take care not to
105 /// introduce the same declarations repeatedly.
106 virtual void ReadDelegatingConstructors(
107 SmallVectorImpl<CXXConstructorDecl *> &Decls) {}
108
109 /// \brief Read the set of ext_vector type declarations known to the
110 /// external Sema source.
111 ///
112 /// The external source should append its own ext_vector type declarations to
113 /// the given vector of declarations. Note that this routine may be
114 /// invoked multiple times; the external source should take care not to
115 /// introduce the same declarations repeatedly.
116 virtual void ReadExtVectorDecls(SmallVectorImpl<TypedefNameDecl *> &Decls) {}
117
118 /// \brief Read the set of dynamic classes known to the external Sema source.
119 ///
120 /// The external source should append its own dynamic classes to
121 /// the given vector of declarations. Note that this routine may be
122 /// invoked multiple times; the external source should take care not to
123 /// introduce the same declarations repeatedly.
124 virtual void ReadDynamicClasses(SmallVectorImpl<CXXRecordDecl *> &Decls) {}
125
126 /// \brief Read the set of locally-scoped external declarations known to the
127 /// external Sema source.
128 ///
129 /// The external source should append its own locally-scoped external
130 /// declarations to the given vector of declarations. Note that this routine
131 /// may be invoked multiple times; the external source should take care not
132 /// to introduce the same declarations repeatedly.
133 virtual void ReadLocallyScopedExternalDecls(
134 SmallVectorImpl<NamedDecl *> &Decls) {}
135
136 /// \brief Read the set of referenced selectors known to the
137 /// external Sema source.
138 ///
139 /// The external source should append its own referenced selectors to the
140 /// given vector of selectors. Note that this routine
141 /// may be invoked multiple times; the external source should take care not
142 /// to introduce the same selectors repeatedly.
143 virtual void ReadReferencedSelectors(
144 SmallVectorImpl<std::pair<Selector, SourceLocation> > &Sels) {}
145
146 /// \brief Read the set of weak, undeclared identifiers known to the
147 /// external Sema source.
148 ///
149 /// The external source should append its own weak, undeclared identifiers to
150 /// the given vector. Note that this routine may be invoked multiple times;
151 /// the external source should take care not to introduce the same identifiers
152 /// repeatedly.
153 virtual void ReadWeakUndeclaredIdentifiers(
154 SmallVectorImpl<std::pair<IdentifierInfo *, WeakInfo> > &WI) {}
155
156 /// \brief Read the set of used vtables known to the external Sema source.
157 ///
158 /// The external source should append its own used vtables to the given
159 /// vector. Note that this routine may be invoked multiple times; the external
160 /// source should take care not to introduce the same vtables repeatedly.
161 virtual void ReadUsedVTables(SmallVectorImpl<ExternalVTableUse> &VTables) {}
162
163 /// \brief Read the set of pending instantiations known to the external
164 /// Sema source.
165 ///
166 /// The external source should append its own pending instantiations to the
167 /// given vector. Note that this routine may be invoked multiple times; the
168 /// external source should take care not to introduce the same instantiations
169 /// repeatedly.
170 virtual void ReadPendingInstantiations(
171 SmallVectorImpl<std::pair<ValueDecl *,
172 SourceLocation> > &Pending) {}
173
174 // isa/cast/dyn_cast support
175 static bool classof(const ExternalASTSource *Source) {
176 return Source->SemaSource;
177 }
178 static bool classof(const ExternalSemaSource *) { return true; }
179 };
180
181 } // end namespace clang
182
183 #endif