CompilerInstance.h revision 1824d54df85a462ada812dadda18130f951d40f3
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"
14a1f1fad8b60e1cb9d21a40a37f2e03150bcbeb6fDouglas Gregor#include "clang/Basic/SourceManager.h"
156aa52ec6b969faabf3764baf79d89810b8249a7eDouglas Gregor#include "clang/Lex/ModuleLoader.h"
163d3589db579f7695667b913c5043dd264ebe546fDouglas Gregor#include "llvm/ADT/ArrayRef.h"
1749009ec701feb3009450e57e40c656e2ad7c1f41Douglas Gregor#include "llvm/ADT/DenseMap.h"
1828019772db70d4547be05a042eb950bc910f134fDouglas Gregor#include "llvm/ADT/IntrusiveRefCntPtr.h"
190f800391ffbfe3820e1c60246a09a97e5f065179Daniel Dunbar#include "llvm/ADT/StringRef.h"
202a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar#include "llvm/ADT/OwningPtr.h"
2122dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar#include <cassert>
22a9204831639e31474b927681b97c46781b758a1aDaniel Dunbar#include <list>
23a9204831639e31474b927681b97c46781b758a1aDaniel Dunbar#include <string>
243d3589db579f7695667b913c5043dd264ebe546fDouglas Gregor#include <utility>
252a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
262a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbarnamespace llvm {
27f482d59386dbc70716f7a5f65adb37ff86b501e6Daniel Dunbarclass raw_fd_ostream;
28f79bafa608a5d7c49ec40ad199af5e32f3038b47Kovarththanan Rajaratnamclass Timer;
292a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar}
302a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
312a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbarnamespace clang {
325eb810024dc8a1d12d5f066c02c978f07c4fcb00Daniel Dunbarclass ASTContext;
3312ce6943aae499225708ecf364c5a8b0a3269c87Daniel Dunbarclass ASTConsumer;
34f62d43d2afe1960755a1b5813cae1e5983bcac1bDouglas Gregorclass ASTReader;
35c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbarclass CodeCompleteConsumer;
36d6471f7c1921c7802804ce3ff6fe9768310f72b9David Blaikieclass DiagnosticsEngine;
3778ad0b98848c17a0a11847fa1d456e2dfec8aa2fDavid Blaikieclass DiagnosticConsumer;
380f800391ffbfe3820e1c60246a09a97e5f065179Daniel Dunbarclass ExternalASTSource;
3949009ec701feb3009450e57e40c656e2ad7c1f41Douglas Gregorclass FileEntry;
4016b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbarclass FileManager;
410397af277e3bba16da1fd125ddba07415686b429Daniel Dunbarclass FrontendAction;
421a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregorclass Module;
430f800391ffbfe3820e1c60246a09a97e5f065179Daniel Dunbarclass Preprocessor;
44f18d0d8b39e891460d50f8a8b85029885b264986Douglas Gregorclass Sema;
4516b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbarclass SourceManager;
462a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbarclass TargetInfo;
472a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
482a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar/// CompilerInstance - Helper class for managing a single instance of the Clang
492a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar/// compiler.
502a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar///
512a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar/// The CompilerInstance serves two purposes:
522a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar///  (1) It manages the various objects which are necessary to run the compiler,
532a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar///      for example the preprocessor, the target information, and the AST
542a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar///      context.
552a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar///  (2) It provides utility routines for constructing and manipulating the
562a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar///      common Clang objects.
572a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar///
582a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar/// The compiler instance generally owns the instance of all the objects that it
592a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar/// manages. However, clients can still share objects by manually setting the
602a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar/// object and retaking ownership prior to destroying the CompilerInstance.
612a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar///
622a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar/// The compiler instance is intended to simplify clients, but not to lock them
632a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar/// in to the compiler instance for everything. When possible, utility functions
642a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar/// come in two forms; a short form that reuses the CompilerInstance objects,
652a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar/// and a long form that takes explicit instances of any required objects.
666aa52ec6b969faabf3764baf79d89810b8249a7eDouglas Gregorclass CompilerInstance : public ModuleLoader {
672a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  /// The options used in this compiler instance.
68c93dc7889644293e318e19d82830ea2acc45b678Dylan Noblesmith  IntrusiveRefCntPtr<CompilerInvocation> Invocation;
692a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
702a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  /// The diagnostics engine instance.
71c93dc7889644293e318e19d82830ea2acc45b678Dylan Noblesmith  IntrusiveRefCntPtr<DiagnosticsEngine> Diagnostics;
722a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
732a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  /// The target being compiled for.
74c93dc7889644293e318e19d82830ea2acc45b678Dylan Noblesmith  IntrusiveRefCntPtr<TargetInfo> Target;
752a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
7616b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar  /// The file manager.
77c93dc7889644293e318e19d82830ea2acc45b678Dylan Noblesmith  IntrusiveRefCntPtr<FileManager> FileMgr;
7816b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar
7916b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar  /// The source manager.
80c93dc7889644293e318e19d82830ea2acc45b678Dylan Noblesmith  IntrusiveRefCntPtr<SourceManager> SourceMgr;
8116b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar
8222dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar  /// The preprocessor.
83c93dc7889644293e318e19d82830ea2acc45b678Dylan Noblesmith  IntrusiveRefCntPtr<Preprocessor> PP;
8422dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar
855eb810024dc8a1d12d5f066c02c978f07c4fcb00Daniel Dunbar  /// The AST context.
86c93dc7889644293e318e19d82830ea2acc45b678Dylan Noblesmith  IntrusiveRefCntPtr<ASTContext> Context;
875eb810024dc8a1d12d5f066c02c978f07c4fcb00Daniel Dunbar
8812ce6943aae499225708ecf364c5a8b0a3269c87Daniel Dunbar  /// The AST consumer.
896f42b62b6194f53bcbc349f5d17388e1936535d7Dylan Noblesmith  OwningPtr<ASTConsumer> Consumer;
9012ce6943aae499225708ecf364c5a8b0a3269c87Daniel Dunbar
91c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar  /// The code completion consumer.
926f42b62b6194f53bcbc349f5d17388e1936535d7Dylan Noblesmith  OwningPtr<CodeCompleteConsumer> CompletionConsumer;
93c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar
94f18d0d8b39e891460d50f8a8b85029885b264986Douglas Gregor  /// \brief The semantic analysis object.
956f42b62b6194f53bcbc349f5d17388e1936535d7Dylan Noblesmith  OwningPtr<Sema> TheSema;
96f18d0d8b39e891460d50f8a8b85029885b264986Douglas Gregor
97f62d43d2afe1960755a1b5813cae1e5983bcac1bDouglas Gregor  /// \brief The frontend timer
986f42b62b6194f53bcbc349f5d17388e1936535d7Dylan Noblesmith  OwningPtr<llvm::Timer> FrontendTimer;
99f79bafa608a5d7c49ec40ad199af5e32f3038b47Kovarththanan Rajaratnam
100f62d43d2afe1960755a1b5813cae1e5983bcac1bDouglas Gregor  /// \brief Non-owning reference to the ASTReader, if one exists.
101f62d43d2afe1960755a1b5813cae1e5983bcac1bDouglas Gregor  ASTReader *ModuleManager;
102f62d43d2afe1960755a1b5813cae1e5983bcac1bDouglas Gregor
10349009ec701feb3009450e57e40c656e2ad7c1f41Douglas Gregor  /// \brief The set of top-level modules that has already been loaded,
10449009ec701feb3009450e57e40c656e2ad7c1f41Douglas Gregor  /// along with the module map
1051a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor  llvm::DenseMap<const IdentifierInfo *, Module *> KnownModules;
10649009ec701feb3009450e57e40c656e2ad7c1f41Douglas Gregor
107b514c792821a8f053027d88444e13bfaa8efef76Douglas Gregor  /// \brief The location of the module-import keyword for the last module
108b514c792821a8f053027d88444e13bfaa8efef76Douglas Gregor  /// import.
109b514c792821a8f053027d88444e13bfaa8efef76Douglas Gregor  SourceLocation LastModuleImportLoc;
110b514c792821a8f053027d88444e13bfaa8efef76Douglas Gregor
111b514c792821a8f053027d88444e13bfaa8efef76Douglas Gregor  /// \brief The result of the last module import.
112b514c792821a8f053027d88444e13bfaa8efef76Douglas Gregor  ///
1131a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor  Module *LastModuleImportResult;
114b514c792821a8f053027d88444e13bfaa8efef76Douglas Gregor
115dc24572a44575e07a5d8bb6de52641a69f1bab27Argyrios Kyrtzidis  /// \brief Holds information about the output file.
116dc24572a44575e07a5d8bb6de52641a69f1bab27Argyrios Kyrtzidis  ///
117dc24572a44575e07a5d8bb6de52641a69f1bab27Argyrios Kyrtzidis  /// If TempFilename is not empty we must rename it to Filename at the end.
118dc24572a44575e07a5d8bb6de52641a69f1bab27Argyrios Kyrtzidis  /// TempFilename may be empty and Filename non empty if creating the temporary
119dc24572a44575e07a5d8bb6de52641a69f1bab27Argyrios Kyrtzidis  /// failed.
120dc24572a44575e07a5d8bb6de52641a69f1bab27Argyrios Kyrtzidis  struct OutputFile {
121dc24572a44575e07a5d8bb6de52641a69f1bab27Argyrios Kyrtzidis    std::string Filename;
122dc24572a44575e07a5d8bb6de52641a69f1bab27Argyrios Kyrtzidis    std::string TempFilename;
1238cc488fefb2fb04bc8d5398da29f0182f97934cfChris Lattner    raw_ostream *OS;
124dc24572a44575e07a5d8bb6de52641a69f1bab27Argyrios Kyrtzidis
125dc24572a44575e07a5d8bb6de52641a69f1bab27Argyrios Kyrtzidis    OutputFile(const std::string &filename, const std::string &tempFilename,
1268cc488fefb2fb04bc8d5398da29f0182f97934cfChris Lattner               raw_ostream *os)
127dc24572a44575e07a5d8bb6de52641a69f1bab27Argyrios Kyrtzidis      : Filename(filename), TempFilename(tempFilename), OS(os) { }
128dc24572a44575e07a5d8bb6de52641a69f1bab27Argyrios Kyrtzidis  };
129dc24572a44575e07a5d8bb6de52641a69f1bab27Argyrios Kyrtzidis
130a9204831639e31474b927681b97c46781b758a1aDaniel Dunbar  /// The list of active output files.
131dc24572a44575e07a5d8bb6de52641a69f1bab27Argyrios Kyrtzidis  std::list<OutputFile> OutputFiles;
132a9204831639e31474b927681b97c46781b758a1aDaniel Dunbar
13342e9f8e4983d50f896ec716207817b9d96e7e79cDaniel Dunbar  void operator=(const CompilerInstance &);  // DO NOT IMPLEMENT
13442e9f8e4983d50f896ec716207817b9d96e7e79cDaniel Dunbar  CompilerInstance(const CompilerInstance&); // DO NOT IMPLEMENT
1352a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbarpublic:
13642e9f8e4983d50f896ec716207817b9d96e7e79cDaniel Dunbar  CompilerInstance();
1372a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  ~CompilerInstance();
1382a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
1390397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar  /// @name High-Level Operations
1400397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar  /// {
1410397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar
1420397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar  /// ExecuteAction - Execute the provided action against the compiler's
1430397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar  /// CompilerInvocation object.
1440397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar  ///
1450397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar  /// This function makes the following assumptions:
1460397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar  ///
1470397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar  ///  - The invocation options should be initialized. This function does not
1480397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar  ///    handle the '-help' or '-version' options, clients should handle those
1490397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar  ///    directly.
1500397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar  ///
1510397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar  ///  - The diagnostics engine should have already been created by the client.
1520397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar  ///
1530397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar  ///  - No other CompilerInstance state should have been initialized (this is
1540397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar  ///    an unchecked error).
1550397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar  ///
1560397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar  ///  - Clients should have initialized any LLVM target features that may be
1570397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar  ///    required.
1580397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar  ///
1590397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar  ///  - Clients should eventually call llvm_shutdown() upon the completion of
1600397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar  ///    this routine to ensure that any managed objects are properly destroyed.
1610397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar  ///
1620397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar  /// Note that this routine may write output to 'stderr'.
1630397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar  ///
1640397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar  /// \param Act - The action to execute.
1650397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar  /// \return - True on success.
1660397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar  //
1670397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar  // FIXME: This function should take the stream to write any debugging /
1680397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar  // verbose output to as an argument.
1690397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar  //
1700397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar  // FIXME: Eliminate the llvm_shutdown requirement, that should either be part
1710397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar  // of the context or else not CompilerInstance specific.
1720397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar  bool ExecuteAction(FrontendAction &Act);
1730397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar
1740397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar  /// }
1752a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  /// @name Compiler Invocation and Options
1762a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  /// {
1772a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
1786228ca00121669ec06a19df4fad87d5049c097cfDaniel Dunbar  bool hasInvocation() const { return Invocation != 0; }
1796228ca00121669ec06a19df4fad87d5049c097cfDaniel Dunbar
1806228ca00121669ec06a19df4fad87d5049c097cfDaniel Dunbar  CompilerInvocation &getInvocation() {
1816228ca00121669ec06a19df4fad87d5049c097cfDaniel Dunbar    assert(Invocation && "Compiler instance has no invocation!");
1826228ca00121669ec06a19df4fad87d5049c097cfDaniel Dunbar    return *Invocation;
1836228ca00121669ec06a19df4fad87d5049c097cfDaniel Dunbar  }
1846228ca00121669ec06a19df4fad87d5049c097cfDaniel Dunbar
1854f32786ac45210143654390177105eb749b614e9Ted Kremenek  /// setInvocation - Replace the current invocation.
1866228ca00121669ec06a19df4fad87d5049c097cfDaniel Dunbar  void setInvocation(CompilerInvocation *Value);
1872a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
1882a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  /// }
1892a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  /// @name Forwarding Methods
1902a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  /// {
1912a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
19245796b10d11869e86c6b85e24df165410536b313Ted Kremenek  AnalyzerOptionsRef getAnalyzerOpts() {
1936228ca00121669ec06a19df4fad87d5049c097cfDaniel Dunbar    return Invocation->getAnalyzerOpts();
1942a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  }
1952a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
1962a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  CodeGenOptions &getCodeGenOpts() {
1976228ca00121669ec06a19df4fad87d5049c097cfDaniel Dunbar    return Invocation->getCodeGenOpts();
1982a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  }
1992a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  const CodeGenOptions &getCodeGenOpts() const {
2006228ca00121669ec06a19df4fad87d5049c097cfDaniel Dunbar    return Invocation->getCodeGenOpts();
2012a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  }
2022a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
2032a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  DependencyOutputOptions &getDependencyOutputOpts() {
2046228ca00121669ec06a19df4fad87d5049c097cfDaniel Dunbar    return Invocation->getDependencyOutputOpts();
2052a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  }
2062a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  const DependencyOutputOptions &getDependencyOutputOpts() const {
2076228ca00121669ec06a19df4fad87d5049c097cfDaniel Dunbar    return Invocation->getDependencyOutputOpts();
2082a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  }
2092a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
2102a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  DiagnosticOptions &getDiagnosticOpts() {
2116228ca00121669ec06a19df4fad87d5049c097cfDaniel Dunbar    return Invocation->getDiagnosticOpts();
2122a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  }
2132a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  const DiagnosticOptions &getDiagnosticOpts() const {
2146228ca00121669ec06a19df4fad87d5049c097cfDaniel Dunbar    return Invocation->getDiagnosticOpts();
2152a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  }
2162a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
217389db16c63eec6ecfa9b235155252d8da766e94eArgyrios Kyrtzidis  const FileSystemOptions &getFileSystemOpts() const {
218389db16c63eec6ecfa9b235155252d8da766e94eArgyrios Kyrtzidis    return Invocation->getFileSystemOpts();
219389db16c63eec6ecfa9b235155252d8da766e94eArgyrios Kyrtzidis  }
220389db16c63eec6ecfa9b235155252d8da766e94eArgyrios Kyrtzidis
2212a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  FrontendOptions &getFrontendOpts() {
2226228ca00121669ec06a19df4fad87d5049c097cfDaniel Dunbar    return Invocation->getFrontendOpts();
2232a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  }
2242a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  const FrontendOptions &getFrontendOpts() const {
2256228ca00121669ec06a19df4fad87d5049c097cfDaniel Dunbar    return Invocation->getFrontendOpts();
2262a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  }
2272a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
2282a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  HeaderSearchOptions &getHeaderSearchOpts() {
2296228ca00121669ec06a19df4fad87d5049c097cfDaniel Dunbar    return Invocation->getHeaderSearchOpts();
2302a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  }
2312a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  const HeaderSearchOptions &getHeaderSearchOpts() const {
2326228ca00121669ec06a19df4fad87d5049c097cfDaniel Dunbar    return Invocation->getHeaderSearchOpts();
2332a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  }
2342a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
2352a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  LangOptions &getLangOpts() {
236d3b74d9ca4f239a7a90ad193378c494306c57352Ted Kremenek    return *Invocation->getLangOpts();
2372a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  }
2382a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  const LangOptions &getLangOpts() const {
239d3b74d9ca4f239a7a90ad193378c494306c57352Ted Kremenek    return *Invocation->getLangOpts();
2402a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  }
2412a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
2422a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  PreprocessorOptions &getPreprocessorOpts() {
2436228ca00121669ec06a19df4fad87d5049c097cfDaniel Dunbar    return Invocation->getPreprocessorOpts();
2442a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  }
2452a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  const PreprocessorOptions &getPreprocessorOpts() const {
2466228ca00121669ec06a19df4fad87d5049c097cfDaniel Dunbar    return Invocation->getPreprocessorOpts();
2472a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  }
2482a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
2492a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  PreprocessorOutputOptions &getPreprocessorOutputOpts() {
2506228ca00121669ec06a19df4fad87d5049c097cfDaniel Dunbar    return Invocation->getPreprocessorOutputOpts();
2512a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  }
2522a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  const PreprocessorOutputOptions &getPreprocessorOutputOpts() const {
2536228ca00121669ec06a19df4fad87d5049c097cfDaniel Dunbar    return Invocation->getPreprocessorOutputOpts();
2542a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  }
2552a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
256d58c03f42ebb4e548c2b53fa25b1cfe02ebb9ac0Daniel Dunbar  TargetOptions &getTargetOpts() {
2576228ca00121669ec06a19df4fad87d5049c097cfDaniel Dunbar    return Invocation->getTargetOpts();
258d58c03f42ebb4e548c2b53fa25b1cfe02ebb9ac0Daniel Dunbar  }
259d58c03f42ebb4e548c2b53fa25b1cfe02ebb9ac0Daniel Dunbar  const TargetOptions &getTargetOpts() const {
2606228ca00121669ec06a19df4fad87d5049c097cfDaniel Dunbar    return Invocation->getTargetOpts();
261d58c03f42ebb4e548c2b53fa25b1cfe02ebb9ac0Daniel Dunbar  }
262d58c03f42ebb4e548c2b53fa25b1cfe02ebb9ac0Daniel Dunbar
2632a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  /// }
2642a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  /// @name Diagnostics Engine
2652a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  /// {
2662a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
267704e48ae75111072eecaa20a365dff46fb49d2beDaniel Dunbar  bool hasDiagnostics() const { return Diagnostics != 0; }
268704e48ae75111072eecaa20a365dff46fb49d2beDaniel Dunbar
2694f32786ac45210143654390177105eb749b614e9Ted Kremenek  /// Get the current diagnostics engine.
270d6471f7c1921c7802804ce3ff6fe9768310f72b9David Blaikie  DiagnosticsEngine &getDiagnostics() const {
27122dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar    assert(Diagnostics && "Compiler instance has no diagnostics!");
27222dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar    return *Diagnostics;
27322dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar  }
2742a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
2754f32786ac45210143654390177105eb749b614e9Ted Kremenek  /// setDiagnostics - Replace the current diagnostics engine.
276d6471f7c1921c7802804ce3ff6fe9768310f72b9David Blaikie  void setDiagnostics(DiagnosticsEngine *Value);
2772a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
27878ad0b98848c17a0a11847fa1d456e2dfec8aa2fDavid Blaikie  DiagnosticConsumer &getDiagnosticClient() const {
279bdbb004f38978da0c4a75af3294d1c7b5ff84af1Douglas Gregor    assert(Diagnostics && Diagnostics->getClient() &&
280bdbb004f38978da0c4a75af3294d1c7b5ff84af1Douglas Gregor           "Compiler instance has no diagnostic client!");
281bdbb004f38978da0c4a75af3294d1c7b5ff84af1Douglas Gregor    return *Diagnostics->getClient();
28281f5a1e699b2eefa4a5e50b5dfc06df600748f59Daniel Dunbar  }
2832a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
2842a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  /// }
2852a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  /// @name Target Info
2862a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  /// {
2872a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
288704e48ae75111072eecaa20a365dff46fb49d2beDaniel Dunbar  bool hasTarget() const { return Target != 0; }
289704e48ae75111072eecaa20a365dff46fb49d2beDaniel Dunbar
29022dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar  TargetInfo &getTarget() const {
29122dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar    assert(Target && "Compiler instance has no target!");
29222dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar    return *Target;
29322dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar  }
2942a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
2954f32786ac45210143654390177105eb749b614e9Ted Kremenek  /// Replace the current diagnostics engine.
2968a9f569262860b8d03203327afd6047be2a9b5a6Daniel Dunbar  void setTarget(TargetInfo *Value);
2972a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
2982a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar  /// }
29916b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar  /// @name File Manager
30016b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar  /// {
30116b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar
302704e48ae75111072eecaa20a365dff46fb49d2beDaniel Dunbar  bool hasFileManager() const { return FileMgr != 0; }
303704e48ae75111072eecaa20a365dff46fb49d2beDaniel Dunbar
3044f32786ac45210143654390177105eb749b614e9Ted Kremenek  /// Return the current file manager to the caller.
30522dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar  FileManager &getFileManager() const {
30622dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar    assert(FileMgr && "Compiler instance has no file manager!");
30722dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar    return *FileMgr;
30822dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar  }
3094f32786ac45210143654390177105eb749b614e9Ted Kremenek
3104f32786ac45210143654390177105eb749b614e9Ted Kremenek  void resetAndLeakFileManager() {
3114f32786ac45210143654390177105eb749b614e9Ted Kremenek    FileMgr.resetWithoutRelease();
3124f32786ac45210143654390177105eb749b614e9Ted Kremenek  }
31316b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar
3144f32786ac45210143654390177105eb749b614e9Ted Kremenek  /// setFileManager - Replace the current file manager.
3158a9f569262860b8d03203327afd6047be2a9b5a6Daniel Dunbar  void setFileManager(FileManager *Value);
31616b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar
31716b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar  /// }
31816b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar  /// @name Source Manager
31916b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar  /// {
32016b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar
321704e48ae75111072eecaa20a365dff46fb49d2beDaniel Dunbar  bool hasSourceManager() const { return SourceMgr != 0; }
322704e48ae75111072eecaa20a365dff46fb49d2beDaniel Dunbar
3234f32786ac45210143654390177105eb749b614e9Ted Kremenek  /// Return the current source manager.
32422dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar  SourceManager &getSourceManager() const {
32522dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar    assert(SourceMgr && "Compiler instance has no source manager!");
32622dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar    return *SourceMgr;
32722dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar  }
3284f32786ac45210143654390177105eb749b614e9Ted Kremenek
3294f32786ac45210143654390177105eb749b614e9Ted Kremenek  void resetAndLeakSourceManager() {
3304f32786ac45210143654390177105eb749b614e9Ted Kremenek    SourceMgr.resetWithoutRelease();
3314f32786ac45210143654390177105eb749b614e9Ted Kremenek  }
33216b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar
3334f32786ac45210143654390177105eb749b614e9Ted Kremenek  /// setSourceManager - Replace the current source manager.
3348a9f569262860b8d03203327afd6047be2a9b5a6Daniel Dunbar  void setSourceManager(SourceManager *Value);
33516b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar
33616b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar  /// }
33722dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar  /// @name Preprocessor
33822dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar  /// {
33922dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar
340704e48ae75111072eecaa20a365dff46fb49d2beDaniel Dunbar  bool hasPreprocessor() const { return PP != 0; }
341704e48ae75111072eecaa20a365dff46fb49d2beDaniel Dunbar
3424f32786ac45210143654390177105eb749b614e9Ted Kremenek  /// Return the current preprocessor.
34322dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar  Preprocessor &getPreprocessor() const {
34422dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar    assert(PP && "Compiler instance has no preprocessor!");
34522dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar    return *PP;
34622dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar  }
34722dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar
3484f32786ac45210143654390177105eb749b614e9Ted Kremenek  void resetAndLeakPreprocessor() {
3494f32786ac45210143654390177105eb749b614e9Ted Kremenek    PP.resetWithoutRelease();
3504f32786ac45210143654390177105eb749b614e9Ted Kremenek  }
35122dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar
3524f32786ac45210143654390177105eb749b614e9Ted Kremenek  /// Replace the current preprocessor.
3538a9f569262860b8d03203327afd6047be2a9b5a6Daniel Dunbar  void setPreprocessor(Preprocessor *Value);
35422dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar
35522dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar  /// }
3565eb810024dc8a1d12d5f066c02c978f07c4fcb00Daniel Dunbar  /// @name ASTContext
3575eb810024dc8a1d12d5f066c02c978f07c4fcb00Daniel Dunbar  /// {
3585eb810024dc8a1d12d5f066c02c978f07c4fcb00Daniel Dunbar
359704e48ae75111072eecaa20a365dff46fb49d2beDaniel Dunbar  bool hasASTContext() const { return Context != 0; }
360704e48ae75111072eecaa20a365dff46fb49d2beDaniel Dunbar
3615eb810024dc8a1d12d5f066c02c978f07c4fcb00Daniel Dunbar  ASTContext &getASTContext() const {
3625eb810024dc8a1d12d5f066c02c978f07c4fcb00Daniel Dunbar    assert(Context && "Compiler instance has no AST context!");
3635eb810024dc8a1d12d5f066c02c978f07c4fcb00Daniel Dunbar    return *Context;
3645eb810024dc8a1d12d5f066c02c978f07c4fcb00Daniel Dunbar  }
3654f32786ac45210143654390177105eb749b614e9Ted Kremenek
3664f32786ac45210143654390177105eb749b614e9Ted Kremenek  void resetAndLeakASTContext() {
3674f32786ac45210143654390177105eb749b614e9Ted Kremenek    Context.resetWithoutRelease();
3684f32786ac45210143654390177105eb749b614e9Ted Kremenek  }
3695eb810024dc8a1d12d5f066c02c978f07c4fcb00Daniel Dunbar
3704f32786ac45210143654390177105eb749b614e9Ted Kremenek  /// setASTContext - Replace the current AST context.
3718a9f569262860b8d03203327afd6047be2a9b5a6Daniel Dunbar  void setASTContext(ASTContext *Value);
3725eb810024dc8a1d12d5f066c02c978f07c4fcb00Daniel Dunbar
373f18d0d8b39e891460d50f8a8b85029885b264986Douglas Gregor  /// \brief Replace the current Sema; the compiler instance takes ownership
374f18d0d8b39e891460d50f8a8b85029885b264986Douglas Gregor  /// of S.
375f18d0d8b39e891460d50f8a8b85029885b264986Douglas Gregor  void setSema(Sema *S);
376f18d0d8b39e891460d50f8a8b85029885b264986Douglas Gregor
3775eb810024dc8a1d12d5f066c02c978f07c4fcb00Daniel Dunbar  /// }
37812ce6943aae499225708ecf364c5a8b0a3269c87Daniel Dunbar  /// @name ASTConsumer
37912ce6943aae499225708ecf364c5a8b0a3269c87Daniel Dunbar  /// {
38012ce6943aae499225708ecf364c5a8b0a3269c87Daniel Dunbar
38112ce6943aae499225708ecf364c5a8b0a3269c87Daniel Dunbar  bool hasASTConsumer() const { return Consumer != 0; }
38212ce6943aae499225708ecf364c5a8b0a3269c87Daniel Dunbar
38312ce6943aae499225708ecf364c5a8b0a3269c87Daniel Dunbar  ASTConsumer &getASTConsumer() const {
38412ce6943aae499225708ecf364c5a8b0a3269c87Daniel Dunbar    assert(Consumer && "Compiler instance has no AST consumer!");
38512ce6943aae499225708ecf364c5a8b0a3269c87Daniel Dunbar    return *Consumer;
38612ce6943aae499225708ecf364c5a8b0a3269c87Daniel Dunbar  }
38712ce6943aae499225708ecf364c5a8b0a3269c87Daniel Dunbar
38812ce6943aae499225708ecf364c5a8b0a3269c87Daniel Dunbar  /// takeASTConsumer - Remove the current AST consumer and give ownership to
38912ce6943aae499225708ecf364c5a8b0a3269c87Daniel Dunbar  /// the caller.
39012ce6943aae499225708ecf364c5a8b0a3269c87Daniel Dunbar  ASTConsumer *takeASTConsumer() { return Consumer.take(); }
39112ce6943aae499225708ecf364c5a8b0a3269c87Daniel Dunbar
39212ce6943aae499225708ecf364c5a8b0a3269c87Daniel Dunbar  /// setASTConsumer - Replace the current AST consumer; the compiler instance
3931824d54df85a462ada812dadda18130f951d40f3Dmitri Gribenko  /// takes ownership of \p Value.
39412ce6943aae499225708ecf364c5a8b0a3269c87Daniel Dunbar  void setASTConsumer(ASTConsumer *Value);
39512ce6943aae499225708ecf364c5a8b0a3269c87Daniel Dunbar
39612ce6943aae499225708ecf364c5a8b0a3269c87Daniel Dunbar  /// }
397f18d0d8b39e891460d50f8a8b85029885b264986Douglas Gregor  /// @name Semantic analysis
398f18d0d8b39e891460d50f8a8b85029885b264986Douglas Gregor  /// {
399f18d0d8b39e891460d50f8a8b85029885b264986Douglas Gregor  bool hasSema() const { return TheSema != 0; }
400f18d0d8b39e891460d50f8a8b85029885b264986Douglas Gregor
401f18d0d8b39e891460d50f8a8b85029885b264986Douglas Gregor  Sema &getSema() const {
402f18d0d8b39e891460d50f8a8b85029885b264986Douglas Gregor    assert(TheSema && "Compiler instance has no Sema object!");
403f18d0d8b39e891460d50f8a8b85029885b264986Douglas Gregor    return *TheSema;
404f18d0d8b39e891460d50f8a8b85029885b264986Douglas Gregor  }
405f18d0d8b39e891460d50f8a8b85029885b264986Douglas Gregor
406f18d0d8b39e891460d50f8a8b85029885b264986Douglas Gregor  Sema *takeSema() { return TheSema.take(); }
407f18d0d8b39e891460d50f8a8b85029885b264986Douglas Gregor
408f18d0d8b39e891460d50f8a8b85029885b264986Douglas Gregor  /// }
409f62d43d2afe1960755a1b5813cae1e5983bcac1bDouglas Gregor  /// @name Module Management
410f62d43d2afe1960755a1b5813cae1e5983bcac1bDouglas Gregor  /// {
411f62d43d2afe1960755a1b5813cae1e5983bcac1bDouglas Gregor
412f62d43d2afe1960755a1b5813cae1e5983bcac1bDouglas Gregor  ASTReader *getModuleManager() const { return ModuleManager; }
413f62d43d2afe1960755a1b5813cae1e5983bcac1bDouglas Gregor
414f62d43d2afe1960755a1b5813cae1e5983bcac1bDouglas Gregor  /// }
415c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar  /// @name Code Completion
416c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar  /// {
417c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar
418c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar  bool hasCodeCompletionConsumer() const { return CompletionConsumer != 0; }
419c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar
420c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar  CodeCompleteConsumer &getCodeCompletionConsumer() const {
421c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar    assert(CompletionConsumer &&
422c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar           "Compiler instance has no code completion consumer!");
423c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar    return *CompletionConsumer;
424c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar  }
425c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar
426c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar  /// takeCodeCompletionConsumer - Remove the current code completion consumer
427c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar  /// and give ownership to the caller.
428c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar  CodeCompleteConsumer *takeCodeCompletionConsumer() {
429c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar    return CompletionConsumer.take();
430c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar  }
431c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar
432c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar  /// setCodeCompletionConsumer - Replace the current code completion consumer;
4331824d54df85a462ada812dadda18130f951d40f3Dmitri Gribenko  /// the compiler instance takes ownership of \p Value.
4348a9f569262860b8d03203327afd6047be2a9b5a6Daniel Dunbar  void setCodeCompletionConsumer(CodeCompleteConsumer *Value);
435c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar
436c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar  /// }
437f79bafa608a5d7c49ec40ad199af5e32f3038b47Kovarththanan Rajaratnam  /// @name Frontend timer
438f79bafa608a5d7c49ec40ad199af5e32f3038b47Kovarththanan Rajaratnam  /// {
439f79bafa608a5d7c49ec40ad199af5e32f3038b47Kovarththanan Rajaratnam
440f79bafa608a5d7c49ec40ad199af5e32f3038b47Kovarththanan Rajaratnam  bool hasFrontendTimer() const { return FrontendTimer != 0; }
441f79bafa608a5d7c49ec40ad199af5e32f3038b47Kovarththanan Rajaratnam
442f79bafa608a5d7c49ec40ad199af5e32f3038b47Kovarththanan Rajaratnam  llvm::Timer &getFrontendTimer() const {
443f79bafa608a5d7c49ec40ad199af5e32f3038b47Kovarththanan Rajaratnam    assert(FrontendTimer && "Compiler instance has no frontend timer!");
444f79bafa608a5d7c49ec40ad199af5e32f3038b47Kovarththanan Rajaratnam    return *FrontendTimer;
445f79bafa608a5d7c49ec40ad199af5e32f3038b47Kovarththanan Rajaratnam  }
446f79bafa608a5d7c49ec40ad199af5e32f3038b47Kovarththanan Rajaratnam
447f79bafa608a5d7c49ec40ad199af5e32f3038b47Kovarththanan Rajaratnam  /// }
448a9204831639e31474b927681b97c46781b758a1aDaniel Dunbar  /// @name Output Files
449a9204831639e31474b927681b97c46781b758a1aDaniel Dunbar  /// {
450a9204831639e31474b927681b97c46781b758a1aDaniel Dunbar
451a9204831639e31474b927681b97c46781b758a1aDaniel Dunbar  /// addOutputFile - Add an output file onto the list of tracked output files.
452a9204831639e31474b927681b97c46781b758a1aDaniel Dunbar  ///
453dc24572a44575e07a5d8bb6de52641a69f1bab27Argyrios Kyrtzidis  /// \param OutFile - The output file info.
454dc24572a44575e07a5d8bb6de52641a69f1bab27Argyrios Kyrtzidis  void addOutputFile(const OutputFile &OutFile);
455a9204831639e31474b927681b97c46781b758a1aDaniel Dunbar
456e51dd7be67808d52c80c09b832d875e9655ce6e0Kovarththanan Rajaratnam  /// clearOutputFiles - Clear the output file list, destroying the contained
457a9204831639e31474b927681b97c46781b758a1aDaniel Dunbar  /// output streams.
458a9204831639e31474b927681b97c46781b758a1aDaniel Dunbar  ///
459a9204831639e31474b927681b97c46781b758a1aDaniel Dunbar  /// \param EraseFiles - If true, attempt to erase the files from disk.
460e51dd7be67808d52c80c09b832d875e9655ce6e0Kovarththanan Rajaratnam  void clearOutputFiles(bool EraseFiles);
461a9204831639e31474b927681b97c46781b758a1aDaniel Dunbar
462a9204831639e31474b927681b97c46781b758a1aDaniel Dunbar  /// }
46316b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar  /// @name Construction Utility Methods
46416b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar  /// {
46516b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar
4660fbb3d9a9cdd2201848be9eb017c54cd78538122Daniel Dunbar  /// Create the diagnostics engine using the invocation's diagnostic options
4670fbb3d9a9cdd2201848be9eb017c54cd78538122Daniel Dunbar  /// and replace any existing one with it.
4680fbb3d9a9cdd2201848be9eb017c54cd78538122Daniel Dunbar  ///
469e47be3e9682e82da15059006f43c7f3c021e4fffDouglas Gregor  /// Note that this routine also replaces the diagnostic client,
470e47be3e9682e82da15059006f43c7f3c021e4fffDouglas Gregor  /// allocating one if one is not provided.
471e47be3e9682e82da15059006f43c7f3c021e4fffDouglas Gregor  ///
472e47be3e9682e82da15059006f43c7f3c021e4fffDouglas Gregor  /// \param Client If non-NULL, a diagnostic client that will be
473d6471f7c1921c7802804ce3ff6fe9768310f72b9David Blaikie  /// attached to (and, then, owned by) the DiagnosticsEngine inside this AST
474e47be3e9682e82da15059006f43c7f3c021e4fffDouglas Gregor  /// unit.
47578243658c533168d51fd076fba328437932ba6f1Douglas Gregor  ///
47678243658c533168d51fd076fba328437932ba6f1Douglas Gregor  /// \param ShouldOwnClient If Client is non-NULL, specifies whether
47778243658c533168d51fd076fba328437932ba6f1Douglas Gregor  /// the diagnostic object should take ownership of the client.
478aee526e77657afd1600276450e9c346953ad51d7Douglas Gregor  ///
479aee526e77657afd1600276450e9c346953ad51d7Douglas Gregor  /// \param ShouldCloneClient If Client is non-NULL, specifies whether that
480aee526e77657afd1600276450e9c346953ad51d7Douglas Gregor  /// client should be cloned.
481e47be3e9682e82da15059006f43c7f3c021e4fffDouglas Gregor  void createDiagnostics(int Argc, const char* const *Argv,
48278ad0b98848c17a0a11847fa1d456e2dfec8aa2fDavid Blaikie                         DiagnosticConsumer *Client = 0,
483aee526e77657afd1600276450e9c346953ad51d7Douglas Gregor                         bool ShouldOwnClient = true,
484aee526e77657afd1600276450e9c346953ad51d7Douglas Gregor                         bool ShouldCloneClient = true);
4850fbb3d9a9cdd2201848be9eb017c54cd78538122Daniel Dunbar
486d6471f7c1921c7802804ce3ff6fe9768310f72b9David Blaikie  /// Create a DiagnosticsEngine object with a the TextDiagnosticPrinter.
4870fbb3d9a9cdd2201848be9eb017c54cd78538122Daniel Dunbar  ///
4881824d54df85a462ada812dadda18130f951d40f3Dmitri Gribenko  /// The \p Argc and \p Argv arguments are used only for logging purposes,
4890fbb3d9a9cdd2201848be9eb017c54cd78538122Daniel Dunbar  /// when the diagnostic options indicate that the compiler should output
4900fbb3d9a9cdd2201848be9eb017c54cd78538122Daniel Dunbar  /// logging information.
4910fbb3d9a9cdd2201848be9eb017c54cd78538122Daniel Dunbar  ///
492e47be3e9682e82da15059006f43c7f3c021e4fffDouglas Gregor  /// If no diagnostic client is provided, this creates a
49378ad0b98848c17a0a11847fa1d456e2dfec8aa2fDavid Blaikie  /// DiagnosticConsumer that is owned by the returned diagnostic
494e47be3e9682e82da15059006f43c7f3c021e4fffDouglas Gregor  /// object, if using directly the caller is responsible for
495d6471f7c1921c7802804ce3ff6fe9768310f72b9David Blaikie  /// releasing the returned DiagnosticsEngine's client eventually.
4965eb810024dc8a1d12d5f066c02c978f07c4fcb00Daniel Dunbar  ///
497bb3503a146f5eee6393a8b7542f38d9f5fce6583Daniel Dunbar  /// \param Opts - The diagnostic options; note that the created text
498bb3503a146f5eee6393a8b7542f38d9f5fce6583Daniel Dunbar  /// diagnostic object contains a reference to these options and its lifetime
499bb3503a146f5eee6393a8b7542f38d9f5fce6583Daniel Dunbar  /// must extend past that of the diagnostic engine.
500bb3503a146f5eee6393a8b7542f38d9f5fce6583Daniel Dunbar  ///
501e47be3e9682e82da15059006f43c7f3c021e4fffDouglas Gregor  /// \param Client If non-NULL, a diagnostic client that will be
502d6471f7c1921c7802804ce3ff6fe9768310f72b9David Blaikie  /// attached to (and, then, owned by) the returned DiagnosticsEngine
503e47be3e9682e82da15059006f43c7f3c021e4fffDouglas Gregor  /// object.
504e47be3e9682e82da15059006f43c7f3c021e4fffDouglas Gregor  ///
505b6534bbee90bf73f364072051d10b60352d43c3eDaniel Dunbar  /// \param CodeGenOpts If non-NULL, the code gen options in use, which may be
506b6534bbee90bf73f364072051d10b60352d43c3eDaniel Dunbar  /// used by some diagnostics printers (for logging purposes only).
507b6534bbee90bf73f364072051d10b60352d43c3eDaniel Dunbar  ///
5080fbb3d9a9cdd2201848be9eb017c54cd78538122Daniel Dunbar  /// \return The new object on success, or null on failure.
509c93dc7889644293e318e19d82830ea2acc45b678Dylan Noblesmith  static IntrusiveRefCntPtr<DiagnosticsEngine>
5107d0c4ccd65b4549283c55e4923602e234f3811c5Axel Naumann  createDiagnostics(const DiagnosticOptions &Opts, int Argc,
511e47be3e9682e82da15059006f43c7f3c021e4fffDouglas Gregor                    const char* const *Argv,
51278ad0b98848c17a0a11847fa1d456e2dfec8aa2fDavid Blaikie                    DiagnosticConsumer *Client = 0,
51378243658c533168d51fd076fba328437932ba6f1Douglas Gregor                    bool ShouldOwnClient = true,
514aee526e77657afd1600276450e9c346953ad51d7Douglas Gregor                    bool ShouldCloneClient = true,
515b6534bbee90bf73f364072051d10b60352d43c3eDaniel Dunbar                    const CodeGenOptions *CodeGenOpts = 0);
5160fbb3d9a9cdd2201848be9eb017c54cd78538122Daniel Dunbar
51716b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar  /// Create the file manager and replace any existing one with it.
51816b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar  void createFileManager();
51916b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar
52016b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar  /// Create the source manager and replace any existing one with it.
52139b49bcaaddb1049234fca9500c0ac02c088e23dChris Lattner  void createSourceManager(FileManager &FileMgr);
52216b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar
52322dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar  /// Create the preprocessor, using the invocation, file, and source managers,
52422dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar  /// and replace any existing one with it.
52522dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar  void createPreprocessor();
52622dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar
5275eb810024dc8a1d12d5f066c02c978f07c4fcb00Daniel Dunbar  /// Create the AST context.
5285eb810024dc8a1d12d5f066c02c978f07c4fcb00Daniel Dunbar  void createASTContext();
5295eb810024dc8a1d12d5f066c02c978f07c4fcb00Daniel Dunbar
5300f800391ffbfe3820e1c60246a09a97e5f065179Daniel Dunbar  /// Create an external AST source to read a PCH file and attach it to the AST
5310f800391ffbfe3820e1c60246a09a97e5f065179Daniel Dunbar  /// context.
532686775deca8b8685eb90801495880e3abdd844c2Chris Lattner  void createPCHExternalASTSource(StringRef Path,
533ffaab3e2bb13991bb3357e80f14bcae3745b2347Sebastian Redl                                  bool DisablePCHValidation,
5348ef6c8cb6c5627240e2339fd7062c9873f821d7eDouglas Gregor                                  bool DisableStatCache,
535bef35c91b594f66216f4aab303b71a6c5ab7abcfArgyrios Kyrtzidis                                  bool AllowPCHWithCompilerErrors,
536ffaab3e2bb13991bb3357e80f14bcae3745b2347Sebastian Redl                                  void *DeserializationListener);
5370f800391ffbfe3820e1c60246a09a97e5f065179Daniel Dunbar
5380f800391ffbfe3820e1c60246a09a97e5f065179Daniel Dunbar  /// Create an external AST source to read a PCH file.
5390f800391ffbfe3820e1c60246a09a97e5f065179Daniel Dunbar  ///
5400f800391ffbfe3820e1c60246a09a97e5f065179Daniel Dunbar  /// \return - The new object on success, or null on failure.
5410f800391ffbfe3820e1c60246a09a97e5f065179Daniel Dunbar  static ExternalASTSource *
542686775deca8b8685eb90801495880e3abdd844c2Chris Lattner  createPCHExternalASTSource(StringRef Path, const std::string &Sysroot,
543fae3b2f4743dad616623c4df2fdb0f5128bd36d9Douglas Gregor                             bool DisablePCHValidation,
5448ef6c8cb6c5627240e2339fd7062c9873f821d7eDouglas Gregor                             bool DisableStatCache,
545bef35c91b594f66216f4aab303b71a6c5ab7abcfArgyrios Kyrtzidis                             bool AllowPCHWithCompilerErrors,
546ffaab3e2bb13991bb3357e80f14bcae3745b2347Sebastian Redl                             Preprocessor &PP, ASTContext &Context,
5471d9f1fe7173e3084325f43c78af812a36d8a2a7cSebastian Redl                             void *DeserializationListener, bool Preamble);
548a93e3b5bde9f0a7b59215f19f176f7d69881b81cSebastian Redl
549c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar  /// Create a code completion consumer using the invocation; note that this
550c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar  /// will cause the source manager to truncate the input source file at the
551c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar  /// completion point.
552c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar  void createCodeCompletionConsumer();
553c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar
554c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar  /// Create a code completion consumer to print code completion results, at
5551824d54df85a462ada812dadda18130f951d40f3Dmitri Gribenko  /// \p Filename, \p Line, and \p Column, to the given output stream \p OS.
556c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar  static CodeCompleteConsumer *
557c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar  createCodeCompletionConsumer(Preprocessor &PP, const std::string &Filename,
558c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar                               unsigned Line, unsigned Column,
559d99ef536b241071b6f4c01db6525dc03242ac30bDmitri Gribenko                               const CodeCompleteOptions &Opts,
5608cc488fefb2fb04bc8d5398da29f0182f97934cfChris Lattner                               raw_ostream &OS);
561c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar
562f18d0d8b39e891460d50f8a8b85029885b264986Douglas Gregor  /// \brief Create the Sema object to be used for parsing.
563467dc88512b4ba4bb16e274ea3771dc1415d31daDouglas Gregor  void createSema(TranslationUnitKind TUKind,
564f18d0d8b39e891460d50f8a8b85029885b264986Douglas Gregor                  CodeCompleteConsumer *CompletionConsumer);
565f18d0d8b39e891460d50f8a8b85029885b264986Douglas Gregor
566f79bafa608a5d7c49ec40ad199af5e32f3038b47Kovarththanan Rajaratnam  /// Create the frontend timer and replace any existing one with it.
567f79bafa608a5d7c49ec40ad199af5e32f3038b47Kovarththanan Rajaratnam  void createFrontendTimer();
568f79bafa608a5d7c49ec40ad199af5e32f3038b47Kovarththanan Rajaratnam
569f482d59386dbc70716f7a5f65adb37ff86b501e6Daniel Dunbar  /// Create the default output file (from the invocation's options) and add it
570f482d59386dbc70716f7a5f65adb37ff86b501e6Daniel Dunbar  /// to the list of tracked output files.
571360435908c9b90429cfe192fab22854af1d4497cDaniel Dunbar  ///
572e21dd284d8209a89137a03a0d63f2bd57be9e660Daniel Dunbar  /// The files created by this function always use temporary files to write to
573e21dd284d8209a89137a03a0d63f2bd57be9e660Daniel Dunbar  /// their result (that is, the data is written to a temporary file which will
574e21dd284d8209a89137a03a0d63f2bd57be9e660Daniel Dunbar  /// atomically replace the target output on success).
575e21dd284d8209a89137a03a0d63f2bd57be9e660Daniel Dunbar  ///
576360435908c9b90429cfe192fab22854af1d4497cDaniel Dunbar  /// \return - Null on error.
577f482d59386dbc70716f7a5f65adb37ff86b501e6Daniel Dunbar  llvm::raw_fd_ostream *
578686775deca8b8685eb90801495880e3abdd844c2Chris Lattner  createDefaultOutputFile(bool Binary = true, StringRef BaseInput = "",
579686775deca8b8685eb90801495880e3abdd844c2Chris Lattner                          StringRef Extension = "");
580f482d59386dbc70716f7a5f65adb37ff86b501e6Daniel Dunbar
581f482d59386dbc70716f7a5f65adb37ff86b501e6Daniel Dunbar  /// Create a new output file and add it to the list of tracked output files,
582f482d59386dbc70716f7a5f65adb37ff86b501e6Daniel Dunbar  /// optionally deriving the output path name.
583360435908c9b90429cfe192fab22854af1d4497cDaniel Dunbar  ///
584360435908c9b90429cfe192fab22854af1d4497cDaniel Dunbar  /// \return - Null on error.
585f482d59386dbc70716f7a5f65adb37ff86b501e6Daniel Dunbar  llvm::raw_fd_ostream *
586686775deca8b8685eb90801495880e3abdd844c2Chris Lattner  createOutputFile(StringRef OutputPath,
587ff9cd968cd5b623e3ec7e5f862b598cd22f7ec79Daniel Dunbar                   bool Binary = true, bool RemoveFileOnSignal = true,
588686775deca8b8685eb90801495880e3abdd844c2Chris Lattner                   StringRef BaseInput = "",
5897e90985df09855dc309ed888a5b16a0ae684f8e3Argyrios Kyrtzidis                   StringRef Extension = "",
59012f28ab8a53d7743081d607617309891fa8156f3Daniel Dunbar                   bool UseTemporary = false,
59112f28ab8a53d7743081d607617309891fa8156f3Daniel Dunbar                   bool CreateMissingDirectories = false);
592f482d59386dbc70716f7a5f65adb37ff86b501e6Daniel Dunbar
593f482d59386dbc70716f7a5f65adb37ff86b501e6Daniel Dunbar  /// Create a new output file, optionally deriving the output path name.
594f482d59386dbc70716f7a5f65adb37ff86b501e6Daniel Dunbar  ///
5951824d54df85a462ada812dadda18130f951d40f3Dmitri Gribenko  /// If \p OutputPath is empty, then createOutputFile will derive an output
5961824d54df85a462ada812dadda18130f951d40f3Dmitri Gribenko  /// path location as \p BaseInput, with any suffix removed, and \p Extension
5971824d54df85a462ada812dadda18130f951d40f3Dmitri Gribenko  /// appended. If \p OutputPath is not stdout and \p UseTemporary
5987e90985df09855dc309ed888a5b16a0ae684f8e3Argyrios Kyrtzidis  /// is true, createOutputFile will create a new temporary file that must be
5991824d54df85a462ada812dadda18130f951d40f3Dmitri Gribenko  /// renamed to \p OutputPath in the end.
600f482d59386dbc70716f7a5f65adb37ff86b501e6Daniel Dunbar  ///
601f482d59386dbc70716f7a5f65adb37ff86b501e6Daniel Dunbar  /// \param OutputPath - If given, the path to the output file.
602f482d59386dbc70716f7a5f65adb37ff86b501e6Daniel Dunbar  /// \param Error [out] - On failure, the error message.
6031824d54df85a462ada812dadda18130f951d40f3Dmitri Gribenko  /// \param BaseInput - If \p OutputPath is empty, the input path name to use
604f482d59386dbc70716f7a5f65adb37ff86b501e6Daniel Dunbar  /// for deriving the output path.
605f482d59386dbc70716f7a5f65adb37ff86b501e6Daniel Dunbar  /// \param Extension - The extension to use for derived output names.
606f482d59386dbc70716f7a5f65adb37ff86b501e6Daniel Dunbar  /// \param Binary - The mode to open the file in.
607ff9cd968cd5b623e3ec7e5f862b598cd22f7ec79Daniel Dunbar  /// \param RemoveFileOnSignal - Whether the file should be registered with
608ff9cd968cd5b623e3ec7e5f862b598cd22f7ec79Daniel Dunbar  /// llvm::sys::RemoveFileOnSignal. Note that this is not safe for
609ff9cd968cd5b623e3ec7e5f862b598cd22f7ec79Daniel Dunbar  /// multithreaded use, as the underlying signal mechanism is not reentrant
6107e90985df09855dc309ed888a5b16a0ae684f8e3Argyrios Kyrtzidis  /// \param UseTemporary - Create a new temporary file that must be renamed to
61112f28ab8a53d7743081d607617309891fa8156f3Daniel Dunbar  /// OutputPath in the end.
6121824d54df85a462ada812dadda18130f951d40f3Dmitri Gribenko  /// \param CreateMissingDirectories - When \p UseTemporary is true, create
61312f28ab8a53d7743081d607617309891fa8156f3Daniel Dunbar  /// missing directories in the output path.
614f482d59386dbc70716f7a5f65adb37ff86b501e6Daniel Dunbar  /// \param ResultPathName [out] - If given, the result path name will be
615f482d59386dbc70716f7a5f65adb37ff86b501e6Daniel Dunbar  /// stored here on success.
616dc24572a44575e07a5d8bb6de52641a69f1bab27Argyrios Kyrtzidis  /// \param TempPathName [out] - If given, the temporary file path name
617dc24572a44575e07a5d8bb6de52641a69f1bab27Argyrios Kyrtzidis  /// will be stored here on success.
618f482d59386dbc70716f7a5f65adb37ff86b501e6Daniel Dunbar  static llvm::raw_fd_ostream *
619686775deca8b8685eb90801495880e3abdd844c2Chris Lattner  createOutputFile(StringRef OutputPath, std::string &Error,
620ff9cd968cd5b623e3ec7e5f862b598cd22f7ec79Daniel Dunbar                   bool Binary = true, bool RemoveFileOnSignal = true,
621686775deca8b8685eb90801495880e3abdd844c2Chris Lattner                   StringRef BaseInput = "",
622686775deca8b8685eb90801495880e3abdd844c2Chris Lattner                   StringRef Extension = "",
6237e90985df09855dc309ed888a5b16a0ae684f8e3Argyrios Kyrtzidis                   bool UseTemporary = false,
62412f28ab8a53d7743081d607617309891fa8156f3Daniel Dunbar                   bool CreateMissingDirectories = false,
625dc24572a44575e07a5d8bb6de52641a69f1bab27Argyrios Kyrtzidis                   std::string *ResultPathName = 0,
626dc24572a44575e07a5d8bb6de52641a69f1bab27Argyrios Kyrtzidis                   std::string *TempPathName = 0);
627f482d59386dbc70716f7a5f65adb37ff86b501e6Daniel Dunbar
62816b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar  /// }
629ccb6cb6fd9e48697564d536b07397b95dfc28d5bDaniel Dunbar  /// @name Initialization Utility Methods
630ccb6cb6fd9e48697564d536b07397b95dfc28d5bDaniel Dunbar  /// {
631ccb6cb6fd9e48697564d536b07397b95dfc28d5bDaniel Dunbar
632ccb6cb6fd9e48697564d536b07397b95dfc28d5bDaniel Dunbar  /// InitializeSourceManager - Initialize the source manager to set InputFile
633ccb6cb6fd9e48697564d536b07397b95dfc28d5bDaniel Dunbar  /// as the main file.
634ccb6cb6fd9e48697564d536b07397b95dfc28d5bDaniel Dunbar  ///
635ccb6cb6fd9e48697564d536b07397b95dfc28d5bDaniel Dunbar  /// \return True on success.
636a1f1fad8b60e1cb9d21a40a37f2e03150bcbeb6fDouglas Gregor  bool InitializeSourceManager(StringRef InputFile,
637a1f1fad8b60e1cb9d21a40a37f2e03150bcbeb6fDouglas Gregor         SrcMgr::CharacteristicKind Kind = SrcMgr::C_User);
638ccb6cb6fd9e48697564d536b07397b95dfc28d5bDaniel Dunbar
639ccb6cb6fd9e48697564d536b07397b95dfc28d5bDaniel Dunbar  /// InitializeSourceManager - Initialize the source manager to set InputFile
640ccb6cb6fd9e48697564d536b07397b95dfc28d5bDaniel Dunbar  /// as the main file.
641ccb6cb6fd9e48697564d536b07397b95dfc28d5bDaniel Dunbar  ///
642ccb6cb6fd9e48697564d536b07397b95dfc28d5bDaniel Dunbar  /// \return True on success.
643686775deca8b8685eb90801495880e3abdd844c2Chris Lattner  static bool InitializeSourceManager(StringRef InputFile,
644a1f1fad8b60e1cb9d21a40a37f2e03150bcbeb6fDouglas Gregor                SrcMgr::CharacteristicKind Kind,
645a1f1fad8b60e1cb9d21a40a37f2e03150bcbeb6fDouglas Gregor                DiagnosticsEngine &Diags,
646a1f1fad8b60e1cb9d21a40a37f2e03150bcbeb6fDouglas Gregor                FileManager &FileMgr,
647a1f1fad8b60e1cb9d21a40a37f2e03150bcbeb6fDouglas Gregor                SourceManager &SourceMgr,
648a1f1fad8b60e1cb9d21a40a37f2e03150bcbeb6fDouglas Gregor                const FrontendOptions &Opts);
649ccb6cb6fd9e48697564d536b07397b95dfc28d5bDaniel Dunbar
650ccb6cb6fd9e48697564d536b07397b95dfc28d5bDaniel Dunbar  /// }
6516aa52ec6b969faabf3764baf79d89810b8249a7eDouglas Gregor
6525e35693721364673f8196e4f5a370f56b92e6053Douglas Gregor  virtual Module *loadModule(SourceLocation ImportLoc, ModuleIdPath Path,
65393ebfa6139bbca4d446c7343e3afc8e5ec777484Douglas Gregor                             Module::NameVisibilityKind Visibility,
65493ebfa6139bbca4d446c7343e3afc8e5ec777484Douglas Gregor                             bool IsInclusionDirective);
6552a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar};
6562a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
6572a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar} // end namespace clang
6582a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar
6592a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar#endif
660