]> CyberLeo.Net >> Repos - FreeBSD/releng/9.0.git/blob - contrib/llvm/tools/clang/include/clang/Sema/ExternalSemaSource.h
Copy stable/9 to releng/9.0 as part of the FreeBSD 9.0-RELEASE release
[FreeBSD/releng/9.0.git] / contrib / 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   ///
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);
66
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);
71   
72   /// \brief Do last resort, unqualified lookup on a LookupResult that
73   /// Sema cannot find.
74   ///
75   /// \param R a LookupResult that is being recovered.
76   ///
77   /// \param S the Scope of the identifier occurrence.
78   ///
79   /// \return true to tell Sema to recover using the LookupResult.
80   virtual bool LookupUnqualified(LookupResult &R, Scope *S) { return false; }
81
82   /// \brief Read the set of tentative definitions known to the external Sema
83   /// source.
84   ///
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) {}
91   
92   /// \brief Read the set of unused file-scope declarations known to the
93   /// external Sema source.
94   ///
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) {}
101   
102   /// \brief Read the set of delegating constructors known to the
103   /// external Sema source.
104   ///
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) {}
111
112   /// \brief Read the set of ext_vector type declarations known to the
113   /// external Sema source.
114   ///
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) {}
120
121   /// \brief Read the set of dynamic classes known to the external Sema source.
122   ///
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) {}
128
129   /// \brief Read the set of locally-scoped external declarations known to the
130   /// external Sema source.
131   ///
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) {}
138
139   /// \brief Read the set of referenced selectors known to the
140   /// external Sema source.
141   ///
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) {}
148
149   /// \brief Read the set of weak, undeclared identifiers known to the
150   /// external Sema source.
151   ///
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
155   /// repeatedly.
156   virtual void ReadWeakUndeclaredIdentifiers(
157                  SmallVectorImpl<std::pair<IdentifierInfo *, WeakInfo> > &WI) {}
158
159   /// \brief Read the set of used vtables known to the external Sema source.
160   ///
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) {}
165
166   /// \brief Read the set of pending instantiations known to the external
167   /// Sema source.
168   ///
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
172   /// repeatedly.
173   virtual void ReadPendingInstantiations(
174                  SmallVectorImpl<std::pair<ValueDecl *, 
175                                            SourceLocation> > &Pending) {}
176
177   // isa/cast/dyn_cast support
178   static bool classof(const ExternalASTSource *Source) {
179     return Source->SemaSource;
180   }
181   static bool classof(const ExternalSemaSource *) { return true; }
182 }; 
183
184 } // end namespace clang
185
186 #endif