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