ModuleLoader.h revision 6aa52ec6b969faabf3764baf79d89810b8249a7e
1//===--- ModuleLoader.h - Module Loader 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 ModuleLoader interface, which is responsible for
11//  loading named modules.
12//
13//===----------------------------------------------------------------------===//
14#ifndef LLVM_CLANG_LEX_MODULE_LOADER_H
15#define LLVM_CLANG_LEX_MODULE_LOADER_H
16
17#include "clang/Basic/SourceLocation.h"
18
19namespace clang {
20
21class IdentifierInfo;
22
23/// \brief An opaque key that is used to describe the module and can be
24/// interpreted by the module loader itself.
25typedef void *ModuleKey;
26
27/// \brief Abstract interface for a module loader.
28///
29/// This abstract interface describes a module loader, which is responsible
30/// for resolving a module name (e.g., "std") to an actual module file, and
31/// then loading that module.
32class ModuleLoader {
33public:
34  virtual ~ModuleLoader();
35
36  /// \brief Attempt to load the given module.
37  ///
38  /// This routine attempts to load the module described by the given
39  /// parameters.
40  ///
41  /// \param ImportLoc The location of the 'import' keyword.
42  /// \param ModuleName The name of the module to be loaded.
43  /// \param ModuleNameLoc The location of the module name.
44  ///
45  /// \returns If successful, a non-NULL module key describing this module.
46  /// Otherwise, returns NULL to indicate that the module could not be
47  /// loaded.
48  virtual ModuleKey loadModule(SourceLocation ImportLoc,
49                               IdentifierInfo &ModuleName,
50                               SourceLocation ModuleNameLoc) = 0;
51};
52
53}
54
55#endif
56