ExternalSemaSource.h revision a126f17ca83b985300c1f65cee647bea108db657
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 <utility>
18
19namespace clang {
20
21class CXXConstructorDecl;
22class CXXRecordDecl;
23class DeclaratorDecl;
24class LookupResult;
25struct ObjCMethodList;
26class Scope;
27class Sema;
28class TypedefNameDecl;
29class VarDecl;
30
31/// \brief An abstract interface that should be implemented by
32/// external AST sources that also provide information for semantic
33/// analysis.
34class ExternalSemaSource : public ExternalASTSource {
35public:
36  ExternalSemaSource() {
37    ExternalASTSource::SemaSource = true;
38  }
39
40  ~ExternalSemaSource();
41
42  /// \brief Initialize the semantic source with the Sema instance
43  /// being used to perform semantic analysis on the abstract syntax
44  /// tree.
45  virtual void InitializeSema(Sema &S) {}
46
47  /// \brief Inform the semantic consumer that Sema is no longer available.
48  virtual void ForgetSema() {}
49
50  /// \brief Load the contents of the global method pool for a given
51  /// selector.
52  ///
53  /// \returns a pair of Objective-C methods lists containing the
54  /// instance and factory methods, respectively, with this selector.
55  virtual std::pair<ObjCMethodList,ObjCMethodList> ReadMethodPool(Selector Sel);
56
57  /// \brief Load the set of namespaces that are known to the external source,
58  /// which will be used during typo correction.
59  virtual void ReadKnownNamespaces(
60                           SmallVectorImpl<NamespaceDecl *> &Namespaces);
61
62  /// \brief Do last resort, unqualified lookup on a LookupResult that
63  /// Sema cannot find.
64  ///
65  /// \param R a LookupResult that is being recovered.
66  ///
67  /// \param S the Scope of the identifier occurrence.
68  ///
69  /// \return true to tell Sema to recover using the LookupResult.
70  virtual bool LookupUnqualified(LookupResult &R, Scope *S) { return false; }
71
72  /// \brief Read the set of tentative definitions known to the external Sema
73  /// source.
74  ///
75  /// The external source should append its own tentative definitions to the
76  /// given vector of tentative definitions. Note that this routine may be
77  /// invoked multiple times; the external source should take care not to
78  /// introduce the same declarations repeatedly.
79  virtual void ReadTentativeDefinitions(
80                                  SmallVectorImpl<VarDecl *> &TentativeDefs) {}
81
82  /// \brief Read the set of unused file-scope declarations known to the
83  /// external Sema source.
84  ///
85  /// The external source should append its own unused, filed-scope to the
86  /// given vector of declarations. 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 ReadUnusedFileScopedDecls(
90                 SmallVectorImpl<const DeclaratorDecl *> &Decls) {}
91
92  /// \brief Read the set of delegating constructors known to the
93  /// external Sema source.
94  ///
95  /// The external source should append its own delegating constructors 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 ReadDelegatingConstructors(
100                 SmallVectorImpl<CXXConstructorDecl *> &Decls) {}
101
102  /// \brief Read the set of ext_vector type declarations known to the
103  /// external Sema source.
104  ///
105  /// The external source should append its own ext_vector type declarations to
106  /// the 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 ReadExtVectorDecls(SmallVectorImpl<TypedefNameDecl *> &Decls) {}
110
111  /// \brief Read the set of dynamic classes known to the external Sema source.
112  ///
113  /// The external source should append its own dynamic classes to
114  /// the given vector of declarations. Note that this routine may be
115  /// invoked multiple times; the external source should take care not to
116  /// introduce the same declarations repeatedly.
117  virtual void ReadDynamicClasses(SmallVectorImpl<CXXRecordDecl *> &Decls) {}
118
119  // isa/cast/dyn_cast support
120  static bool classof(const ExternalASTSource *Source) {
121    return Source->SemaSource;
122  }
123  static bool classof(const ExternalSemaSource *) { return true; }
124};
125
126} // end namespace clang
127
128#endif
129