CompilerInstance.h revision 16b7449d86b843d0926b04f87104cf3fff7149fe
12a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar//===-- CompilerInstance.h - Clang Compiler Instance ------------*- C++ -*-===//
22a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar//
32a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar//                     The LLVM Compiler Infrastructure
42a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar//
52a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar// This file is distributed under the University of Illinois Open Source
62a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar// License. See LICENSE.TXT for details.
72a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar//
82a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar//===----------------------------------------------------------------------===//
92a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
102a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar#ifndef LLVM_CLANG_FRONTEND_COMPILERINSTANCE_H_
112a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar#define LLVM_CLANG_FRONTEND_COMPILERINSTANCE_H_
122a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
132a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar#include "clang/Frontend/CompilerInvocation.h"
142a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar#include "llvm/ADT/OwningPtr.h"
152a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
162a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbarnamespace llvm {
172a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbarclass LLVMContext;
182a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar}
192a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
202a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbarnamespace clang {
212a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbarclass Diagnostic;
222a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbarclass DiagnosticClient;
2316b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbarclass FileManager;
2416b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbarclass SourceManager;
252a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbarclass TargetInfo;
262a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
272a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar/// CompilerInstance - Helper class for managing a single instance of the Clang
282a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar/// compiler.
292a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar///
302a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar/// The CompilerInstance serves two purposes:
312a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar///  (1) It manages the various objects which are necessary to run the compiler,
322a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar///      for example the preprocessor, the target information, and the AST
332a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar///      context.
342a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar///  (2) It provides utility routines for constructing and manipulating the
352a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar///      common Clang objects.
362a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar///
372a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar/// The compiler instance generally owns the instance of all the objects that it
382a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar/// manages. However, clients can still share objects by manually setting the
392a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar/// object and retaking ownership prior to destroying the CompilerInstance.
402a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar///
412a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar/// The compiler instance is intended to simplify clients, but not to lock them
422a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar/// in to the compiler instance for everything. When possible, utility functions
432a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar/// come in two forms; a short form that reuses the CompilerInstance objects,
442a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar/// and a long form that takes explicit instances of any required objects.
452a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbarclass CompilerInstance {
462a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  /// The LLVM context used for this instance.
472a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  llvm::LLVMContext *LLVMContext;
482a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  bool OwnsLLVMContext;
492a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
502a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  /// The options used in this compiler instance.
512a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  CompilerInvocation Invocation;
522a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
532a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  /// The diagnostics engine instance.
542a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  llvm::OwningPtr<Diagnostic> Diagnostics;
552a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
562a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  /// The diagnostics client instance.
572a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  llvm::OwningPtr<DiagnosticClient> DiagClient;
582a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
592a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  /// The target being compiled for.
602a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  llvm::OwningPtr<TargetInfo> Target;
612a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
6216b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar  /// The file manager.
6316b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar  llvm::OwningPtr<FileManager> FileMgr;
6416b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar
6516b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar  /// The source manager.
6616b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar  llvm::OwningPtr<SourceManager> SourceMgr;
6716b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar
682a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbarpublic:
692a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  /// Create a new compiler instance with the given LLVM context, optionally
702a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  /// taking ownership of it.
712a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  CompilerInstance(llvm::LLVMContext *_LLVMContext = 0,
722a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar                   bool _OwnsLLVMContext = true);
732a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  ~CompilerInstance();
742a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
752a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  /// @name LLVM Context
762a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  /// {
772a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
782a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  llvm::LLVMContext &getLLVMContext() { return *LLVMContext; }
792a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
802a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  /// setLLVMContext - Replace the current LLVM context and take ownership of
812a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  /// \arg Value.
822a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  void setLLVMContext(llvm::LLVMContext *Value, bool TakeOwnership = true) {
832a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar    LLVMContext = Value;
842a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar    OwnsLLVMContext = TakeOwnership;
852a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  }
862a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
872a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  /// }
882a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  /// @name Compiler Invocation and Options
892a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  /// {
902a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
912a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  CompilerInvocation &getInvocation() { return Invocation; }
922a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  const CompilerInvocation &getInvocation() const { return Invocation; }
932a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  void setInvocation(const CompilerInvocation &Value) { Invocation = Value; }
942a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
952a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  /// }
962a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  /// @name Forwarding Methods
972a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  /// {
982a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
992a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  AnalyzerOptions &getAnalyzerOpts() {
1002a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar    return Invocation.getAnalyzerOpts();
1012a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  }
1022a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  const AnalyzerOptions &getAnalyzerOpts() const {
1032a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar    return Invocation.getAnalyzerOpts();
1042a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  }
1052a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
1062a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  CodeGenOptions &getCodeGenOpts() {
1072a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar    return Invocation.getCodeGenOpts();
1082a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  }
1092a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  const CodeGenOptions &getCodeGenOpts() const {
1102a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar    return Invocation.getCodeGenOpts();
1112a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  }
1122a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
1132a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  DependencyOutputOptions &getDependencyOutputOpts() {
1142a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar    return Invocation.getDependencyOutputOpts();
1152a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  }
1162a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  const DependencyOutputOptions &getDependencyOutputOpts() const {
1172a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar    return Invocation.getDependencyOutputOpts();
1182a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  }
1192a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
1202a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  DiagnosticOptions &getDiagnosticOpts() {
1212a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar    return Invocation.getDiagnosticOpts();
1222a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  }
1232a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  const DiagnosticOptions &getDiagnosticOpts() const {
1242a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar    return Invocation.getDiagnosticOpts();
1252a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  }
1262a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
1272a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  FrontendOptions &getFrontendOpts() {
1282a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar    return Invocation.getFrontendOpts();
1292a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  }
1302a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  const FrontendOptions &getFrontendOpts() const {
1312a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar    return Invocation.getFrontendOpts();
1322a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  }
1332a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
1342a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  HeaderSearchOptions &getHeaderSearchOpts() {
1352a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar    return Invocation.getHeaderSearchOpts();
1362a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  }
1372a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  const HeaderSearchOptions &getHeaderSearchOpts() const {
1382a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar    return Invocation.getHeaderSearchOpts();
1392a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  }
1402a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
1412a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  LangOptions &getLangOpts() {
1422a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar    return Invocation.getLangOpts();
1432a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  }
1442a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  const LangOptions &getLangOpts() const {
1452a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar    return Invocation.getLangOpts();
1462a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  }
1472a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
1482a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  PreprocessorOptions &getPreprocessorOpts() {
1492a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar    return Invocation.getPreprocessorOpts();
1502a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  }
1512a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  const PreprocessorOptions &getPreprocessorOpts() const {
1522a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar    return Invocation.getPreprocessorOpts();
1532a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  }
1542a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
1552a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  PreprocessorOutputOptions &getPreprocessorOutputOpts() {
1562a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar    return Invocation.getPreprocessorOutputOpts();
1572a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  }
1582a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  const PreprocessorOutputOptions &getPreprocessorOutputOpts() const {
1592a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar    return Invocation.getPreprocessorOutputOpts();
1602a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  }
1612a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
1622a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  /// }
1632a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  /// @name Diagnostics Engine
1642a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  /// {
1652a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
1662a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  Diagnostic &getDiagnostics() const { return *Diagnostics; }
1672a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
1682a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  /// takeDiagnostics - Remove the current diagnostics engine and give ownership
1692a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  /// to the caller.
1702a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  Diagnostic *takeDiagnostics() { return Diagnostics.take(); }
1712a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
1722a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  /// setDiagnostics - Replace the current diagnostics engine; the compiler
1732a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  /// instance takes ownership of \arg Value.
1742a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  void setDiagnostics(Diagnostic *Value) { Diagnostics.reset(Value); }
1752a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
1762a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  DiagnosticClient &getDiagnosticClient() const { return *DiagClient; }
1772a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
1782a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  /// takeDiagnosticClient - Remove the current diagnostics client and give
1792a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  /// ownership to the caller.
1802a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  DiagnosticClient *takeDiagnosticClient() { return DiagClient.take(); }
1812a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
1822a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  /// setDiagnosticClient - Replace the current diagnostics client; the compiler
1832a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  /// instance takes ownership of \arg Value.
1842a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  void setDiagnosticClient(DiagnosticClient *Value) {
1852a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar    DiagClient.reset(Value);
1862a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  }
1872a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
1882a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  /// }
1892a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  /// @name Target Info
1902a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  /// {
1912a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
1922a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  TargetInfo &getTarget() const { return *Target; }
1932a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
1942a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  /// takeTarget - Remove the current diagnostics engine and give ownership
1952a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  /// to the caller.
1962a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  TargetInfo *takeTarget() { return Target.take(); }
1972a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
1982a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  /// setTarget - Replace the current diagnostics engine; the compiler
1992a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  /// instance takes ownership of \arg Value.
2002a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  void setTarget(TargetInfo *Value) { Target.reset(Value); }
2012a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
2022a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  /// }
20316b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar  /// @name File Manager
20416b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar  /// {
20516b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar
20616b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar  FileManager &getFileManager() const { return *FileMgr; }
20716b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar
20816b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar  /// takeFileManager - Remove the current file manager and give ownership to
20916b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar  /// the caller.
21016b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar  FileManager *takeFileManager() { return FileMgr.take(); }
21116b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar
21216b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar  /// setFileManager - Replace the current file manager; the compiler instance
21316b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar  /// takes ownership of \arg Value.
21416b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar  void setFileManager(FileManager *Value) { FileMgr.reset(Value); }
21516b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar
21616b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar  /// }
21716b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar  /// @name Source Manager
21816b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar  /// {
21916b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar
22016b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar  SourceManager &getSourceManager() const { return *SourceMgr; }
22116b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar
22216b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar  /// takeSourceManager - Remove the current source manager and give ownership
22316b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar  /// to the caller.
22416b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar  SourceManager *takeSourceManager() { return SourceMgr.take(); }
22516b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar
22616b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar  /// setSourceManager - Replace the current source manager; the compiler
22716b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar  /// instance takes ownership of \arg Value.
22816b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar  void setSourceManager(SourceManager *Value) { SourceMgr.reset(Value); }
22916b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar
23016b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar  /// }
23116b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar  /// @name Construction Utility Methods
23216b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar  /// {
23316b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar
23416b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar  /// Create the file manager and replace any existing one with it.
23516b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar  void createFileManager();
23616b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar
23716b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar  /// Create the source manager and replace any existing one with it.
23816b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar  void createSourceManager();
23916b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar
24016b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar  /// }
2412a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar};
2422a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
2432a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar} // end namespace clang
2442a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
2452a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar#endif
246