clang  3.8.0
ExternalSemaSource.h
Go to the documentation of this file.
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_EXTERNALSEMASOURCE_H
14 #define LLVM_CLANG_SEMA_EXTERNALSEMASOURCE_H
15 
17 #include "clang/AST/Type.h"
19 #include "clang/Sema/Weak.h"
20 #include "llvm/ADT/MapVector.h"
21 #include <utility>
22 
23 namespace llvm {
24 template <class T, unsigned n> class SmallSetVector;
25 }
26 
27 namespace clang {
28 
29 class CXXConstructorDecl;
30 class CXXDeleteExpr;
31 class CXXRecordDecl;
32 class DeclaratorDecl;
33 class LookupResult;
34 struct ObjCMethodList;
35 class Scope;
36 class Sema;
37 class TypedefNameDecl;
38 class ValueDecl;
39 class VarDecl;
40 struct LateParsedTemplate;
41 
42 /// \brief A simple structure that captures a vtable use for the purposes of
43 /// the \c ExternalSemaSource.
48 };
49 
50 /// \brief An abstract interface that should be implemented by
51 /// external AST sources that also provide information for semantic
52 /// analysis.
54 public:
56  ExternalASTSource::SemaSource = true;
57  }
58 
59  ~ExternalSemaSource() override;
60 
61  /// \brief Initialize the semantic source with the Sema instance
62  /// being used to perform semantic analysis on the abstract syntax
63  /// tree.
64  virtual void InitializeSema(Sema &S) {}
65 
66  /// \brief Inform the semantic consumer that Sema is no longer available.
67  virtual void ForgetSema() {}
68 
69  /// \brief Load the contents of the global method pool for a given
70  /// selector.
71  virtual void ReadMethodPool(Selector Sel);
72 
73  /// \brief Load the set of namespaces that are known to the external source,
74  /// which will be used during typo correction.
75  virtual void ReadKnownNamespaces(
77 
78  /// \brief Load the set of used but not defined functions or variables with
79  /// internal linkage, or used but not defined internal functions.
80  virtual void ReadUndefinedButUsed(
81  llvm::DenseMap<NamedDecl*, SourceLocation> &Undefined);
82 
83  virtual void ReadMismatchingDeleteExpressions(llvm::MapVector<
84  FieldDecl *, llvm::SmallVector<std::pair<SourceLocation, bool>, 4>> &);
85 
86  /// \brief Do last resort, unqualified lookup on a LookupResult that
87  /// Sema cannot find.
88  ///
89  /// \param R a LookupResult that is being recovered.
90  ///
91  /// \param S the Scope of the identifier occurrence.
92  ///
93  /// \return true to tell Sema to recover using the LookupResult.
94  virtual bool LookupUnqualified(LookupResult &R, Scope *S) { return false; }
95 
96  /// \brief Read the set of tentative definitions known to the external Sema
97  /// source.
98  ///
99  /// The external source should append its own tentative definitions to the
100  /// given vector of tentative definitions. Note that this routine may be
101  /// invoked multiple times; the external source should take care not to
102  /// introduce the same declarations repeatedly.
104  SmallVectorImpl<VarDecl *> &TentativeDefs) {}
105 
106  /// \brief Read the set of unused file-scope declarations known to the
107  /// external Sema source.
108  ///
109  /// The external source should append its own unused, filed-scope to the
110  /// given vector of declarations. Note that this routine may be
111  /// invoked multiple times; the external source should take care not to
112  /// introduce the same declarations repeatedly.
115 
116  /// \brief Read the set of delegating constructors known to the
117  /// external Sema source.
118  ///
119  /// The external source should append its own delegating constructors to the
120  /// given vector of declarations. Note that this routine may be
121  /// invoked multiple times; the external source should take care not to
122  /// introduce the same declarations repeatedly.
125 
126  /// \brief Read the set of ext_vector type declarations known to the
127  /// external Sema source.
128  ///
129  /// The external source should append its own ext_vector type declarations to
130  /// the given vector of declarations. Note that this routine may be
131  /// invoked multiple times; the external source should take care not to
132  /// introduce the same declarations repeatedly.
134 
135  /// \brief Read the set of potentially unused typedefs known to the source.
136  ///
137  /// The external source should append its own potentially unused local
138  /// typedefs to the given vector of declarations. Note that this routine may
139  /// be invoked multiple times; the external source should take care not to
140  /// introduce the same declarations repeatedly.
143 
144  /// \brief Read the set of referenced selectors known to the
145  /// external Sema source.
146  ///
147  /// The external source should append its own referenced selectors to the
148  /// given vector of selectors. Note that this routine
149  /// may be invoked multiple times; the external source should take care not
150  /// to introduce the same selectors repeatedly.
152  SmallVectorImpl<std::pair<Selector, SourceLocation> > &Sels) {}
153 
154  /// \brief Read the set of weak, undeclared identifiers known to the
155  /// external Sema source.
156  ///
157  /// The external source should append its own weak, undeclared identifiers to
158  /// the given vector. Note that this routine may be invoked multiple times;
159  /// the external source should take care not to introduce the same identifiers
160  /// repeatedly.
162  SmallVectorImpl<std::pair<IdentifierInfo *, WeakInfo> > &WI) {}
163 
164  /// \brief Read the set of used vtables known to the external Sema source.
165  ///
166  /// The external source should append its own used vtables to the given
167  /// vector. Note that this routine may be invoked multiple times; the external
168  /// source should take care not to introduce the same vtables repeatedly.
170 
171  /// \brief Read the set of pending instantiations known to the external
172  /// Sema source.
173  ///
174  /// The external source should append its own pending instantiations to the
175  /// given vector. Note that this routine may be invoked multiple times; the
176  /// external source should take care not to introduce the same instantiations
177  /// repeatedly.
179  SmallVectorImpl<std::pair<ValueDecl *,
180  SourceLocation> > &Pending) {}
181 
182  /// \brief Read the set of late parsed template functions for this source.
183  ///
184  /// The external source should insert its own late parsed template functions
185  /// into the map. Note that this routine may be invoked multiple times; the
186  /// external source should take care not to introduce the same map entries
187  /// repeatedly.
189  llvm::MapVector<const FunctionDecl *, LateParsedTemplate *> &LPTMap) {}
190 
191  /// \copydoc Sema::CorrectTypo
192  /// \note LookupKind must correspond to a valid Sema::LookupNameKind
193  ///
194  /// ExternalSemaSource::CorrectTypo is always given the first chance to
195  /// correct a typo (really, to offer suggestions to repair a failed lookup).
196  /// It will even be called when SpellChecking is turned off or after a
197  /// fatal error has already been detected.
199  int LookupKind, Scope *S, CXXScopeSpec *SS,
201  DeclContext *MemberContext,
202  bool EnteringContext,
203  const ObjCObjectPointerType *OPT) {
204  return TypoCorrection();
205  }
206 
207  /// \brief Produces a diagnostic note if the external source contains a
208  /// complete definition for \p T.
209  ///
210  /// \param Loc the location at which a complete type was required but not
211  /// provided
212  ///
213  /// \param T the \c QualType that should have been complete at \p Loc
214  ///
215  /// \return true if a diagnostic was produced, false otherwise.
217  QualType T) {
218  return false;
219  }
220 
221  // isa/cast/dyn_cast support
222  static bool classof(const ExternalASTSource *Source) {
223  return Source->SemaSource;
224  }
225 };
226 
227 } // end namespace clang
228 
229 #endif
Smart pointer class that efficiently represents Objective-C method names.
virtual void ReadUnusedFileScopedDecls(SmallVectorImpl< const DeclaratorDecl * > &Decls)
Read the set of unused file-scope declarations known to the external Sema source. ...
A (possibly-)qualified type.
Definition: Type.h:575
Simple class containing the result of Sema::CorrectTypo.
A simple structure that captures a vtable use for the purposes of the ExternalSemaSource.
virtual bool LookupUnqualified(LookupResult &R, Scope *S)
Do last resort, unqualified lookup on a LookupResult that Sema cannot find.
C Language Family Type Representation.
virtual void ForgetSema()
Inform the semantic consumer that Sema is no longer available.
virtual void ReadMethodPool(Selector Sel)
Load the contents of the global method pool for a given selector.
Definition: Sema.cpp:1262
virtual void ReadLateParsedTemplates(llvm::MapVector< const FunctionDecl *, LateParsedTemplate * > &LPTMap)
Read the set of late parsed template functions for this source.
virtual void ReadWeakUndeclaredIdentifiers(SmallVectorImpl< std::pair< IdentifierInfo *, WeakInfo > > &WI)
Read the set of weak, undeclared identifiers known to the external Sema source.
virtual void ReadDelegatingConstructors(SmallVectorImpl< CXXConstructorDecl * > &Decls)
Read the set of delegating constructors known to the external Sema source.
virtual TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo, int LookupKind, Scope *S, CXXScopeSpec *SS, CorrectionCandidateCallback &CCC, DeclContext *MemberContext, bool EnteringContext, const ObjCObjectPointerType *OPT)
Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...
virtual void ReadUnusedLocalTypedefNameCandidates(llvm::SmallSetVector< const TypedefNameDecl *, 4 > &Decls)
Read the set of potentially unused typedefs known to the source.
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
Definition: Decl.h:2209
virtual bool MaybeDiagnoseMissingCompleteType(SourceLocation Loc, QualType T)
Produces a diagnostic note if the external source contains a complete definition for T...
Represents the results of name lookup.
Definition: Sema/Lookup.h:30
virtual void InitializeSema(Sema &S)
Initialize the semantic source with the Sema instance being used to perform semantic analysis on the ...
~ExternalSemaSource() override
Definition: Sema.cpp:1260
Scope - A scope is a transient data structure that is used while parsing the program.
Definition: Scope.h:38
virtual void ReadTentativeDefinitions(SmallVectorImpl< VarDecl * > &TentativeDefs)
Read the set of tentative definitions known to the external Sema source.
Represents a C++ nested-name-specifier or a global scope specifier.
Definition: DeclSpec.h:63
virtual void ReadReferencedSelectors(SmallVectorImpl< std::pair< Selector, SourceLocation > > &Sels)
Read the set of referenced selectors known to the external Sema source.
virtual void ReadExtVectorDecls(SmallVectorImpl< TypedefNameDecl * > &Decls)
Read the set of ext_vector type declarations known to the external Sema source.
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:259
virtual void ReadMismatchingDeleteExpressions(llvm::MapVector< FieldDecl *, llvm::SmallVector< std::pair< SourceLocation, bool >, 4 >> &)
Definition: Sema.cpp:1272
virtual void ReadKnownNamespaces(SmallVectorImpl< NamespaceDecl * > &Namespaces)
Load the set of namespaces that are known to the external source, which will be used during typo corr...
Definition: Sema.cpp:1264
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
Definition: Decl.h:521
An abstract interface that should be implemented by external AST sources that also provide informatio...
Abstract interface for external sources of AST nodes.
Encodes a location in the source.
static bool classof(const ExternalASTSource *Source)
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1121
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
StringRef Typo
Represents a pointer to an Objective C object.
Definition: Type.h:4821
virtual void ReadUndefinedButUsed(llvm::DenseMap< NamedDecl *, SourceLocation > &Undefined)
Load the set of used but not defined functions or variables with internal linkage, or used but not defined internal functions.
Definition: Sema.cpp:1268
Represents a C++ struct/union/class.
Definition: DeclCXX.h:285
virtual void ReadPendingInstantiations(SmallVectorImpl< std::pair< ValueDecl *, SourceLocation > > &Pending)
Read the set of pending instantiations known to the external Sema source.
virtual void ReadUsedVTables(SmallVectorImpl< ExternalVTableUse > &VTables)
Read the set of used vtables known to the external Sema source.