ExternalSemaSource.h revision 219077
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
21struct ObjCMethodList;
22class Sema;
23class Scope;
24class LookupResult;
25
26/// \brief An abstract interface that should be implemented by
27/// external AST sources that also provide information for semantic
28/// analysis.
29class ExternalSemaSource : public ExternalASTSource {
30public:
31  ExternalSemaSource() {
32    ExternalASTSource::SemaSource = true;
33  }
34
35  ~ExternalSemaSource();
36
37  /// \brief Initialize the semantic source with the Sema instance
38  /// being used to perform semantic analysis on the abstract syntax
39  /// tree.
40  virtual void InitializeSema(Sema &S) {}
41
42  /// \brief Inform the semantic consumer that Sema is no longer available.
43  virtual void ForgetSema() {}
44
45  /// \brief Load the contents of the global method pool for a given
46  /// selector.
47  ///
48  /// \returns a pair of Objective-C methods lists containing the
49  /// instance and factory methods, respectively, with this selector.
50  virtual std::pair<ObjCMethodList,ObjCMethodList> ReadMethodPool(Selector Sel);
51
52  /// \brief Do last resort, unqualified lookup on a LookupResult that
53  /// Sema cannot find.
54  ///
55  /// \param R a LookupResult that is being recovered.
56  ///
57  /// \param S the Scope of the identifier occurrence.
58  ///
59  /// \return true to tell Sema to recover using the LookupResult.
60  virtual bool LookupUnqualified(LookupResult &R, Scope *S) { return false; }
61
62  // isa/cast/dyn_cast support
63  static bool classof(const ExternalASTSource *Source) {
64    return Source->SemaSource;
65  }
66  static bool classof(const ExternalSemaSource *) { return true; }
67};
68
69} // end namespace clang
70
71#endif
72