CompilerInstance.h revision 6228ca00121669ec06a19df4fad87d5049c097cf
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" 140f800391ffbfe3820e1c60246a09a97e5f065179Daniel Dunbar#include "llvm/ADT/StringRef.h" 152a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar#include "llvm/ADT/OwningPtr.h" 1622dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar#include <cassert> 17a9204831639e31474b927681b97c46781b758a1aDaniel Dunbar#include <list> 18a9204831639e31474b927681b97c46781b758a1aDaniel Dunbar#include <string> 192a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar 202a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbarnamespace llvm { 212a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbarclass LLVMContext; 22c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbarclass raw_ostream; 23f482d59386dbc70716f7a5f65adb37ff86b501e6Daniel Dunbarclass raw_fd_ostream; 24f79bafa608a5d7c49ec40ad199af5e32f3038b47Kovarththanan Rajaratnamclass Timer; 252a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar} 262a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar 272a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbarnamespace clang { 285eb810024dc8a1d12d5f066c02c978f07c4fcb00Daniel Dunbarclass ASTContext; 2912ce6943aae499225708ecf364c5a8b0a3269c87Daniel Dunbarclass ASTConsumer; 30c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbarclass CodeCompleteConsumer; 312a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbarclass Diagnostic; 322a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbarclass DiagnosticClient; 330f800391ffbfe3820e1c60246a09a97e5f065179Daniel Dunbarclass ExternalASTSource; 3416b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbarclass FileManager; 350397af277e3bba16da1fd125ddba07415686b429Daniel Dunbarclass FrontendAction; 360f800391ffbfe3820e1c60246a09a97e5f065179Daniel Dunbarclass Preprocessor; 370f800391ffbfe3820e1c60246a09a97e5f065179Daniel Dunbarclass Source; 3816b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbarclass SourceManager; 392a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbarclass TargetInfo; 402a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar 412a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar/// CompilerInstance - Helper class for managing a single instance of the Clang 422a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar/// compiler. 432a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar/// 442a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar/// The CompilerInstance serves two purposes: 452a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar/// (1) It manages the various objects which are necessary to run the compiler, 462a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar/// for example the preprocessor, the target information, and the AST 472a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar/// context. 482a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar/// (2) It provides utility routines for constructing and manipulating the 492a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar/// common Clang objects. 502a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar/// 512a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar/// The compiler instance generally owns the instance of all the objects that it 522a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar/// manages. However, clients can still share objects by manually setting the 532a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar/// object and retaking ownership prior to destroying the CompilerInstance. 542a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar/// 552a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar/// The compiler instance is intended to simplify clients, but not to lock them 562a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar/// in to the compiler instance for everything. When possible, utility functions 572a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar/// come in two forms; a short form that reuses the CompilerInstance objects, 582a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar/// and a long form that takes explicit instances of any required objects. 592a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbarclass CompilerInstance { 602a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar /// The LLVM context used for this instance. 612a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar llvm::LLVMContext *LLVMContext; 622a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar bool OwnsLLVMContext; 632a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar 642a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar /// The options used in this compiler instance. 656228ca00121669ec06a19df4fad87d5049c097cfDaniel Dunbar llvm::OwningPtr<CompilerInvocation> Invocation; 662a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar 672a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar /// The diagnostics engine instance. 682a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar llvm::OwningPtr<Diagnostic> Diagnostics; 692a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar 702a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar /// The diagnostics client instance. 712a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar llvm::OwningPtr<DiagnosticClient> DiagClient; 722a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar 732a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar /// The target being compiled for. 742a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar llvm::OwningPtr<TargetInfo> Target; 752a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar 7616b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar /// The file manager. 7716b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar llvm::OwningPtr<FileManager> FileMgr; 7816b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar 7916b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar /// The source manager. 8016b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar llvm::OwningPtr<SourceManager> SourceMgr; 8116b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar 8222dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar /// The preprocessor. 8322dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar llvm::OwningPtr<Preprocessor> PP; 8422dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar 855eb810024dc8a1d12d5f066c02c978f07c4fcb00Daniel Dunbar /// The AST context. 865eb810024dc8a1d12d5f066c02c978f07c4fcb00Daniel Dunbar llvm::OwningPtr<ASTContext> Context; 875eb810024dc8a1d12d5f066c02c978f07c4fcb00Daniel Dunbar 8812ce6943aae499225708ecf364c5a8b0a3269c87Daniel Dunbar /// The AST consumer. 8912ce6943aae499225708ecf364c5a8b0a3269c87Daniel Dunbar llvm::OwningPtr<ASTConsumer> Consumer; 9012ce6943aae499225708ecf364c5a8b0a3269c87Daniel Dunbar 91c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar /// The code completion consumer. 92c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar llvm::OwningPtr<CodeCompleteConsumer> CompletionConsumer; 93c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar 94f79bafa608a5d7c49ec40ad199af5e32f3038b47Kovarththanan Rajaratnam /// The frontend timer 95f79bafa608a5d7c49ec40ad199af5e32f3038b47Kovarththanan Rajaratnam llvm::OwningPtr<llvm::Timer> FrontendTimer; 96f79bafa608a5d7c49ec40ad199af5e32f3038b47Kovarththanan Rajaratnam 97a9204831639e31474b927681b97c46781b758a1aDaniel Dunbar /// The list of active output files. 98a9204831639e31474b927681b97c46781b758a1aDaniel Dunbar std::list< std::pair<std::string, llvm::raw_ostream*> > OutputFiles; 99a9204831639e31474b927681b97c46781b758a1aDaniel Dunbar 1002a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbarpublic: 1012a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar /// Create a new compiler instance with the given LLVM context, optionally 1022a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar /// taking ownership of it. 1032a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar CompilerInstance(llvm::LLVMContext *_LLVMContext = 0, 1042a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar bool _OwnsLLVMContext = true); 1052a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar ~CompilerInstance(); 1062a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar 1070397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar /// @name High-Level Operations 1080397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar /// { 1090397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar 1100397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar /// ExecuteAction - Execute the provided action against the compiler's 1110397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar /// CompilerInvocation object. 1120397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar /// 1130397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar /// This function makes the following assumptions: 1140397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar /// 1150397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar /// - The invocation options should be initialized. This function does not 1160397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar /// handle the '-help' or '-version' options, clients should handle those 1170397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar /// directly. 1180397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar /// 1190397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar /// - The diagnostics engine should have already been created by the client. 1200397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar /// 1210397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar /// - No other CompilerInstance state should have been initialized (this is 1220397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar /// an unchecked error). 1230397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar /// 1240397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar /// - Clients should have initialized any LLVM target features that may be 1250397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar /// required. 1260397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar /// 1270397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar /// - Clients should eventually call llvm_shutdown() upon the completion of 1280397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar /// this routine to ensure that any managed objects are properly destroyed. 1290397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar /// 1300397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar /// Note that this routine may write output to 'stderr'. 1310397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar /// 1320397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar /// \param Act - The action to execute. 1330397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar /// \return - True on success. 1340397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar // 1350397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar // FIXME: This function should take the stream to write any debugging / 1360397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar // verbose output to as an argument. 1370397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar // 1380397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar // FIXME: Eliminate the llvm_shutdown requirement, that should either be part 1390397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar // of the context or else not CompilerInstance specific. 1400397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar bool ExecuteAction(FrontendAction &Act); 1410397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar 1420397af277e3bba16da1fd125ddba07415686b429Daniel Dunbar /// } 1432a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar /// @name LLVM Context 1442a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar /// { 1452a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar 146704e48ae75111072eecaa20a365dff46fb49d2beDaniel Dunbar bool hasLLVMContext() const { return LLVMContext != 0; } 147704e48ae75111072eecaa20a365dff46fb49d2beDaniel Dunbar 148704e48ae75111072eecaa20a365dff46fb49d2beDaniel Dunbar llvm::LLVMContext &getLLVMContext() const { 14922dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar assert(LLVMContext && "Compiler instance has no LLVM context!"); 15022dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar return *LLVMContext; 15122dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar } 1522a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar 1532a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar /// setLLVMContext - Replace the current LLVM context and take ownership of 1542a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar /// \arg Value. 1552a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar void setLLVMContext(llvm::LLVMContext *Value, bool TakeOwnership = true) { 1562a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar LLVMContext = Value; 1572a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar OwnsLLVMContext = TakeOwnership; 1582a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar } 1592a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar 1602a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar /// } 1612a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar /// @name Compiler Invocation and Options 1622a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar /// { 1632a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar 1646228ca00121669ec06a19df4fad87d5049c097cfDaniel Dunbar bool hasInvocation() const { return Invocation != 0; } 1656228ca00121669ec06a19df4fad87d5049c097cfDaniel Dunbar 1666228ca00121669ec06a19df4fad87d5049c097cfDaniel Dunbar CompilerInvocation &getInvocation() { 1676228ca00121669ec06a19df4fad87d5049c097cfDaniel Dunbar assert(Invocation && "Compiler instance has no invocation!"); 1686228ca00121669ec06a19df4fad87d5049c097cfDaniel Dunbar return *Invocation; 1696228ca00121669ec06a19df4fad87d5049c097cfDaniel Dunbar } 1706228ca00121669ec06a19df4fad87d5049c097cfDaniel Dunbar 1716228ca00121669ec06a19df4fad87d5049c097cfDaniel Dunbar CompilerInvocation *takeInvocation() { return Invocation.take(); } 1726228ca00121669ec06a19df4fad87d5049c097cfDaniel Dunbar 1736228ca00121669ec06a19df4fad87d5049c097cfDaniel Dunbar /// setInvocation - Replace the current invocation; the compiler instance 1746228ca00121669ec06a19df4fad87d5049c097cfDaniel Dunbar /// takes ownership of \arg Value. 1756228ca00121669ec06a19df4fad87d5049c097cfDaniel Dunbar void setInvocation(CompilerInvocation *Value); 1762a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar 1772a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar /// } 1782a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar /// @name Forwarding Methods 1792a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar /// { 1802a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar 1812a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar AnalyzerOptions &getAnalyzerOpts() { 1826228ca00121669ec06a19df4fad87d5049c097cfDaniel Dunbar return Invocation->getAnalyzerOpts(); 1832a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar } 1842a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar const AnalyzerOptions &getAnalyzerOpts() const { 1856228ca00121669ec06a19df4fad87d5049c097cfDaniel Dunbar return Invocation->getAnalyzerOpts(); 1862a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar } 1872a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar 1882a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar CodeGenOptions &getCodeGenOpts() { 1896228ca00121669ec06a19df4fad87d5049c097cfDaniel Dunbar return Invocation->getCodeGenOpts(); 1902a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar } 1912a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar const CodeGenOptions &getCodeGenOpts() const { 1926228ca00121669ec06a19df4fad87d5049c097cfDaniel Dunbar return Invocation->getCodeGenOpts(); 1932a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar } 1942a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar 1952a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar DependencyOutputOptions &getDependencyOutputOpts() { 1966228ca00121669ec06a19df4fad87d5049c097cfDaniel Dunbar return Invocation->getDependencyOutputOpts(); 1972a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar } 1982a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar const DependencyOutputOptions &getDependencyOutputOpts() const { 1996228ca00121669ec06a19df4fad87d5049c097cfDaniel Dunbar return Invocation->getDependencyOutputOpts(); 2002a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar } 2012a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar 2022a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar DiagnosticOptions &getDiagnosticOpts() { 2036228ca00121669ec06a19df4fad87d5049c097cfDaniel Dunbar return Invocation->getDiagnosticOpts(); 2042a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar } 2052a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar const DiagnosticOptions &getDiagnosticOpts() const { 2066228ca00121669ec06a19df4fad87d5049c097cfDaniel Dunbar return Invocation->getDiagnosticOpts(); 2072a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar } 2082a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar 2092a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar FrontendOptions &getFrontendOpts() { 2106228ca00121669ec06a19df4fad87d5049c097cfDaniel Dunbar return Invocation->getFrontendOpts(); 2112a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar } 2122a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar const FrontendOptions &getFrontendOpts() const { 2136228ca00121669ec06a19df4fad87d5049c097cfDaniel Dunbar return Invocation->getFrontendOpts(); 2142a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar } 2152a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar 2162a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar HeaderSearchOptions &getHeaderSearchOpts() { 2176228ca00121669ec06a19df4fad87d5049c097cfDaniel Dunbar return Invocation->getHeaderSearchOpts(); 2182a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar } 2192a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar const HeaderSearchOptions &getHeaderSearchOpts() const { 2206228ca00121669ec06a19df4fad87d5049c097cfDaniel Dunbar return Invocation->getHeaderSearchOpts(); 2212a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar } 2222a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar 2232a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar LangOptions &getLangOpts() { 2246228ca00121669ec06a19df4fad87d5049c097cfDaniel Dunbar return Invocation->getLangOpts(); 2252a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar } 2262a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar const LangOptions &getLangOpts() const { 2276228ca00121669ec06a19df4fad87d5049c097cfDaniel Dunbar return Invocation->getLangOpts(); 2282a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar } 2292a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar 2302a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar PreprocessorOptions &getPreprocessorOpts() { 2316228ca00121669ec06a19df4fad87d5049c097cfDaniel Dunbar return Invocation->getPreprocessorOpts(); 2322a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar } 2332a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar const PreprocessorOptions &getPreprocessorOpts() const { 2346228ca00121669ec06a19df4fad87d5049c097cfDaniel Dunbar return Invocation->getPreprocessorOpts(); 2352a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar } 2362a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar 2372a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar PreprocessorOutputOptions &getPreprocessorOutputOpts() { 2386228ca00121669ec06a19df4fad87d5049c097cfDaniel Dunbar return Invocation->getPreprocessorOutputOpts(); 2392a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar } 2402a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar const PreprocessorOutputOptions &getPreprocessorOutputOpts() const { 2416228ca00121669ec06a19df4fad87d5049c097cfDaniel Dunbar return Invocation->getPreprocessorOutputOpts(); 2422a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar } 2432a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar 244d58c03f42ebb4e548c2b53fa25b1cfe02ebb9ac0Daniel Dunbar TargetOptions &getTargetOpts() { 2456228ca00121669ec06a19df4fad87d5049c097cfDaniel Dunbar return Invocation->getTargetOpts(); 246d58c03f42ebb4e548c2b53fa25b1cfe02ebb9ac0Daniel Dunbar } 247d58c03f42ebb4e548c2b53fa25b1cfe02ebb9ac0Daniel Dunbar const TargetOptions &getTargetOpts() const { 2486228ca00121669ec06a19df4fad87d5049c097cfDaniel Dunbar return Invocation->getTargetOpts(); 249d58c03f42ebb4e548c2b53fa25b1cfe02ebb9ac0Daniel Dunbar } 250d58c03f42ebb4e548c2b53fa25b1cfe02ebb9ac0Daniel Dunbar 2512a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar /// } 2522a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar /// @name Diagnostics Engine 2532a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar /// { 2542a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar 255704e48ae75111072eecaa20a365dff46fb49d2beDaniel Dunbar bool hasDiagnostics() const { return Diagnostics != 0; } 256704e48ae75111072eecaa20a365dff46fb49d2beDaniel Dunbar 25722dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar Diagnostic &getDiagnostics() const { 25822dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar assert(Diagnostics && "Compiler instance has no diagnostics!"); 25922dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar return *Diagnostics; 26022dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar } 2612a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar 2622a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar /// takeDiagnostics - Remove the current diagnostics engine and give ownership 2632a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar /// to the caller. 2642a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar Diagnostic *takeDiagnostics() { return Diagnostics.take(); } 2652a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar 2662a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar /// setDiagnostics - Replace the current diagnostics engine; the compiler 2672a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar /// instance takes ownership of \arg Value. 2688a9f569262860b8d03203327afd6047be2a9b5a6Daniel Dunbar void setDiagnostics(Diagnostic *Value); 2692a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar 27081f5a1e699b2eefa4a5e50b5dfc06df600748f59Daniel Dunbar DiagnosticClient &getDiagnosticClient() const { 271c4e265f67e63d870b4a188be5af1bcd848214802Daniel Dunbar assert(DiagClient && "Compiler instance has no diagnostic client!"); 27281f5a1e699b2eefa4a5e50b5dfc06df600748f59Daniel Dunbar return *DiagClient; 27381f5a1e699b2eefa4a5e50b5dfc06df600748f59Daniel Dunbar } 2742a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar 2752a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar /// takeDiagnosticClient - Remove the current diagnostics client and give 2762a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar /// ownership to the caller. 2772a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar DiagnosticClient *takeDiagnosticClient() { return DiagClient.take(); } 2782a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar 2792a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar /// setDiagnosticClient - Replace the current diagnostics client; the compiler 2802a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar /// instance takes ownership of \arg Value. 2818a9f569262860b8d03203327afd6047be2a9b5a6Daniel Dunbar void setDiagnosticClient(DiagnosticClient *Value); 2822a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar 2832a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar /// } 2842a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar /// @name Target Info 2852a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar /// { 2862a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar 287704e48ae75111072eecaa20a365dff46fb49d2beDaniel Dunbar bool hasTarget() const { return Target != 0; } 288704e48ae75111072eecaa20a365dff46fb49d2beDaniel Dunbar 28922dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar TargetInfo &getTarget() const { 29022dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar assert(Target && "Compiler instance has no target!"); 29122dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar return *Target; 29222dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar } 2932a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar 2942a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar /// takeTarget - Remove the current diagnostics engine and give ownership 2952a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar /// to the caller. 2962a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar TargetInfo *takeTarget() { return Target.take(); } 2972a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar 2982a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar /// setTarget - Replace the current diagnostics engine; the compiler 2992a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar /// instance takes ownership of \arg Value. 3008a9f569262860b8d03203327afd6047be2a9b5a6Daniel Dunbar void setTarget(TargetInfo *Value); 3012a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar 3022a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar /// } 30316b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar /// @name File Manager 30416b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar /// { 30516b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar 306704e48ae75111072eecaa20a365dff46fb49d2beDaniel Dunbar bool hasFileManager() const { return FileMgr != 0; } 307704e48ae75111072eecaa20a365dff46fb49d2beDaniel Dunbar 30822dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar FileManager &getFileManager() const { 30922dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar assert(FileMgr && "Compiler instance has no file manager!"); 31022dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar return *FileMgr; 31122dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar } 31216b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar 31316b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar /// takeFileManager - Remove the current file manager and give ownership to 31416b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar /// the caller. 31516b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar FileManager *takeFileManager() { return FileMgr.take(); } 31616b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar 31716b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar /// setFileManager - Replace the current file manager; the compiler instance 31816b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar /// takes ownership of \arg Value. 3198a9f569262860b8d03203327afd6047be2a9b5a6Daniel Dunbar void setFileManager(FileManager *Value); 32016b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar 32116b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar /// } 32216b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar /// @name Source Manager 32316b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar /// { 32416b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar 325704e48ae75111072eecaa20a365dff46fb49d2beDaniel Dunbar bool hasSourceManager() const { return SourceMgr != 0; } 326704e48ae75111072eecaa20a365dff46fb49d2beDaniel Dunbar 32722dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar SourceManager &getSourceManager() const { 32822dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar assert(SourceMgr && "Compiler instance has no source manager!"); 32922dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar return *SourceMgr; 33022dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar } 33116b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar 33216b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar /// takeSourceManager - Remove the current source manager and give ownership 33316b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar /// to the caller. 33416b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar SourceManager *takeSourceManager() { return SourceMgr.take(); } 33516b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar 33616b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar /// setSourceManager - Replace the current source manager; the compiler 33716b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar /// instance takes ownership of \arg Value. 3388a9f569262860b8d03203327afd6047be2a9b5a6Daniel Dunbar void setSourceManager(SourceManager *Value); 33916b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar 34016b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar /// } 34122dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar /// @name Preprocessor 34222dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar /// { 34322dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar 344704e48ae75111072eecaa20a365dff46fb49d2beDaniel Dunbar bool hasPreprocessor() const { return PP != 0; } 345704e48ae75111072eecaa20a365dff46fb49d2beDaniel Dunbar 34622dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar Preprocessor &getPreprocessor() const { 34722dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar assert(PP && "Compiler instance has no preprocessor!"); 34822dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar return *PP; 34922dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar } 35022dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar 35122dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar /// takePreprocessor - Remove the current preprocessor and give ownership to 35222dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar /// the caller. 35322dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar Preprocessor *takePreprocessor() { return PP.take(); } 35422dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar 35522dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar /// setPreprocessor - Replace the current preprocessor; the compiler instance 35622dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar /// takes ownership of \arg Value. 3578a9f569262860b8d03203327afd6047be2a9b5a6Daniel Dunbar void setPreprocessor(Preprocessor *Value); 35822dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar 35922dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar /// } 3605eb810024dc8a1d12d5f066c02c978f07c4fcb00Daniel Dunbar /// @name ASTContext 3615eb810024dc8a1d12d5f066c02c978f07c4fcb00Daniel Dunbar /// { 3625eb810024dc8a1d12d5f066c02c978f07c4fcb00Daniel Dunbar 363704e48ae75111072eecaa20a365dff46fb49d2beDaniel Dunbar bool hasASTContext() const { return Context != 0; } 364704e48ae75111072eecaa20a365dff46fb49d2beDaniel Dunbar 3655eb810024dc8a1d12d5f066c02c978f07c4fcb00Daniel Dunbar ASTContext &getASTContext() const { 3665eb810024dc8a1d12d5f066c02c978f07c4fcb00Daniel Dunbar assert(Context && "Compiler instance has no AST context!"); 3675eb810024dc8a1d12d5f066c02c978f07c4fcb00Daniel Dunbar return *Context; 3685eb810024dc8a1d12d5f066c02c978f07c4fcb00Daniel Dunbar } 3695eb810024dc8a1d12d5f066c02c978f07c4fcb00Daniel Dunbar 3705eb810024dc8a1d12d5f066c02c978f07c4fcb00Daniel Dunbar /// takeASTContext - Remove the current AST context and give ownership to the 3715eb810024dc8a1d12d5f066c02c978f07c4fcb00Daniel Dunbar /// caller. 3725eb810024dc8a1d12d5f066c02c978f07c4fcb00Daniel Dunbar ASTContext *takeASTContext() { return Context.take(); } 3735eb810024dc8a1d12d5f066c02c978f07c4fcb00Daniel Dunbar 3745eb810024dc8a1d12d5f066c02c978f07c4fcb00Daniel Dunbar /// setASTContext - Replace the current AST context; the compiler instance 3755eb810024dc8a1d12d5f066c02c978f07c4fcb00Daniel Dunbar /// takes ownership of \arg Value. 3768a9f569262860b8d03203327afd6047be2a9b5a6Daniel Dunbar void setASTContext(ASTContext *Value); 3775eb810024dc8a1d12d5f066c02c978f07c4fcb00Daniel Dunbar 3785eb810024dc8a1d12d5f066c02c978f07c4fcb00Daniel Dunbar /// } 37912ce6943aae499225708ecf364c5a8b0a3269c87Daniel Dunbar /// @name ASTConsumer 38012ce6943aae499225708ecf364c5a8b0a3269c87Daniel Dunbar /// { 38112ce6943aae499225708ecf364c5a8b0a3269c87Daniel Dunbar 38212ce6943aae499225708ecf364c5a8b0a3269c87Daniel Dunbar bool hasASTConsumer() const { return Consumer != 0; } 38312ce6943aae499225708ecf364c5a8b0a3269c87Daniel Dunbar 38412ce6943aae499225708ecf364c5a8b0a3269c87Daniel Dunbar ASTConsumer &getASTConsumer() const { 38512ce6943aae499225708ecf364c5a8b0a3269c87Daniel Dunbar assert(Consumer && "Compiler instance has no AST consumer!"); 38612ce6943aae499225708ecf364c5a8b0a3269c87Daniel Dunbar return *Consumer; 38712ce6943aae499225708ecf364c5a8b0a3269c87Daniel Dunbar } 38812ce6943aae499225708ecf364c5a8b0a3269c87Daniel Dunbar 38912ce6943aae499225708ecf364c5a8b0a3269c87Daniel Dunbar /// takeASTConsumer - Remove the current AST consumer and give ownership to 39012ce6943aae499225708ecf364c5a8b0a3269c87Daniel Dunbar /// the caller. 39112ce6943aae499225708ecf364c5a8b0a3269c87Daniel Dunbar ASTConsumer *takeASTConsumer() { return Consumer.take(); } 39212ce6943aae499225708ecf364c5a8b0a3269c87Daniel Dunbar 39312ce6943aae499225708ecf364c5a8b0a3269c87Daniel Dunbar /// setASTConsumer - Replace the current AST consumer; the compiler instance 39412ce6943aae499225708ecf364c5a8b0a3269c87Daniel Dunbar /// takes ownership of \arg Value. 39512ce6943aae499225708ecf364c5a8b0a3269c87Daniel Dunbar void setASTConsumer(ASTConsumer *Value); 39612ce6943aae499225708ecf364c5a8b0a3269c87Daniel Dunbar 39712ce6943aae499225708ecf364c5a8b0a3269c87Daniel Dunbar /// } 398c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar /// @name Code Completion 399c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar /// { 400c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar 401c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar bool hasCodeCompletionConsumer() const { return CompletionConsumer != 0; } 402c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar 403c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar CodeCompleteConsumer &getCodeCompletionConsumer() const { 404c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar assert(CompletionConsumer && 405c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar "Compiler instance has no code completion consumer!"); 406c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar return *CompletionConsumer; 407c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar } 408c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar 409c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar /// takeCodeCompletionConsumer - Remove the current code completion consumer 410c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar /// and give ownership to the caller. 411c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar CodeCompleteConsumer *takeCodeCompletionConsumer() { 412c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar return CompletionConsumer.take(); 413c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar } 414c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar 415c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar /// setCodeCompletionConsumer - Replace the current code completion consumer; 416c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar /// the compiler instance takes ownership of \arg Value. 4178a9f569262860b8d03203327afd6047be2a9b5a6Daniel Dunbar void setCodeCompletionConsumer(CodeCompleteConsumer *Value); 418c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar 419c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar /// } 420f79bafa608a5d7c49ec40ad199af5e32f3038b47Kovarththanan Rajaratnam /// @name Frontend timer 421f79bafa608a5d7c49ec40ad199af5e32f3038b47Kovarththanan Rajaratnam /// { 422f79bafa608a5d7c49ec40ad199af5e32f3038b47Kovarththanan Rajaratnam 423f79bafa608a5d7c49ec40ad199af5e32f3038b47Kovarththanan Rajaratnam bool hasFrontendTimer() const { return FrontendTimer != 0; } 424f79bafa608a5d7c49ec40ad199af5e32f3038b47Kovarththanan Rajaratnam 425f79bafa608a5d7c49ec40ad199af5e32f3038b47Kovarththanan Rajaratnam llvm::Timer &getFrontendTimer() const { 426f79bafa608a5d7c49ec40ad199af5e32f3038b47Kovarththanan Rajaratnam assert(FrontendTimer && "Compiler instance has no frontend timer!"); 427f79bafa608a5d7c49ec40ad199af5e32f3038b47Kovarththanan Rajaratnam return *FrontendTimer; 428f79bafa608a5d7c49ec40ad199af5e32f3038b47Kovarththanan Rajaratnam } 429f79bafa608a5d7c49ec40ad199af5e32f3038b47Kovarththanan Rajaratnam 430f79bafa608a5d7c49ec40ad199af5e32f3038b47Kovarththanan Rajaratnam /// } 431a9204831639e31474b927681b97c46781b758a1aDaniel Dunbar /// @name Output Files 432a9204831639e31474b927681b97c46781b758a1aDaniel Dunbar /// { 433a9204831639e31474b927681b97c46781b758a1aDaniel Dunbar 434a9204831639e31474b927681b97c46781b758a1aDaniel Dunbar /// getOutputFileList - Get the list of (path, output stream) pairs of output 435a9204831639e31474b927681b97c46781b758a1aDaniel Dunbar /// files; the path may be empty but the stream will always be non-null. 436a9204831639e31474b927681b97c46781b758a1aDaniel Dunbar const std::list< std::pair<std::string, 437a9204831639e31474b927681b97c46781b758a1aDaniel Dunbar llvm::raw_ostream*> > &getOutputFileList() const; 438a9204831639e31474b927681b97c46781b758a1aDaniel Dunbar 439a9204831639e31474b927681b97c46781b758a1aDaniel Dunbar /// addOutputFile - Add an output file onto the list of tracked output files. 440a9204831639e31474b927681b97c46781b758a1aDaniel Dunbar /// 441a9204831639e31474b927681b97c46781b758a1aDaniel Dunbar /// \param Path - The path to the output file, or empty. 442a9204831639e31474b927681b97c46781b758a1aDaniel Dunbar /// \param OS - The output stream, which should be non-null. 443a9204831639e31474b927681b97c46781b758a1aDaniel Dunbar void addOutputFile(llvm::StringRef Path, llvm::raw_ostream *OS); 444a9204831639e31474b927681b97c46781b758a1aDaniel Dunbar 445a9204831639e31474b927681b97c46781b758a1aDaniel Dunbar /// ClearOutputFiles - Clear the output file list, destroying the contained 446a9204831639e31474b927681b97c46781b758a1aDaniel Dunbar /// output streams. 447a9204831639e31474b927681b97c46781b758a1aDaniel Dunbar /// 448a9204831639e31474b927681b97c46781b758a1aDaniel Dunbar /// \param EraseFiles - If true, attempt to erase the files from disk. 449a9204831639e31474b927681b97c46781b758a1aDaniel Dunbar void ClearOutputFiles(bool EraseFiles); 450a9204831639e31474b927681b97c46781b758a1aDaniel Dunbar 451a9204831639e31474b927681b97c46781b758a1aDaniel Dunbar /// } 45216b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar /// @name Construction Utility Methods 45316b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar /// { 45416b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar 4550fbb3d9a9cdd2201848be9eb017c54cd78538122Daniel Dunbar /// Create the diagnostics engine using the invocation's diagnostic options 4560fbb3d9a9cdd2201848be9eb017c54cd78538122Daniel Dunbar /// and replace any existing one with it. 4570fbb3d9a9cdd2201848be9eb017c54cd78538122Daniel Dunbar /// 4580fbb3d9a9cdd2201848be9eb017c54cd78538122Daniel Dunbar /// Note that this routine also replaces the diagnostic client. 4590fbb3d9a9cdd2201848be9eb017c54cd78538122Daniel Dunbar void createDiagnostics(int Argc, char **Argv); 4600fbb3d9a9cdd2201848be9eb017c54cd78538122Daniel Dunbar 4610fbb3d9a9cdd2201848be9eb017c54cd78538122Daniel Dunbar /// Create a Diagnostic object with a the TextDiagnosticPrinter. 4620fbb3d9a9cdd2201848be9eb017c54cd78538122Daniel Dunbar /// 4630fbb3d9a9cdd2201848be9eb017c54cd78538122Daniel Dunbar /// The \arg Argc and \arg Argv arguments are used only for logging purposes, 4640fbb3d9a9cdd2201848be9eb017c54cd78538122Daniel Dunbar /// when the diagnostic options indicate that the compiler should output 4650fbb3d9a9cdd2201848be9eb017c54cd78538122Daniel Dunbar /// logging information. 4660fbb3d9a9cdd2201848be9eb017c54cd78538122Daniel Dunbar /// 4675eb810024dc8a1d12d5f066c02c978f07c4fcb00Daniel Dunbar /// Note that this creates an unowned DiagnosticClient, if using directly the 468bb3503a146f5eee6393a8b7542f38d9f5fce6583Daniel Dunbar /// caller is responsible for releasing the returned Diagnostic's client 4695eb810024dc8a1d12d5f066c02c978f07c4fcb00Daniel Dunbar /// eventually. 4705eb810024dc8a1d12d5f066c02c978f07c4fcb00Daniel Dunbar /// 471bb3503a146f5eee6393a8b7542f38d9f5fce6583Daniel Dunbar /// \param Opts - The diagnostic options; note that the created text 472bb3503a146f5eee6393a8b7542f38d9f5fce6583Daniel Dunbar /// diagnostic object contains a reference to these options and its lifetime 473bb3503a146f5eee6393a8b7542f38d9f5fce6583Daniel Dunbar /// must extend past that of the diagnostic engine. 474bb3503a146f5eee6393a8b7542f38d9f5fce6583Daniel Dunbar /// 4750fbb3d9a9cdd2201848be9eb017c54cd78538122Daniel Dunbar /// \return The new object on success, or null on failure. 4760fbb3d9a9cdd2201848be9eb017c54cd78538122Daniel Dunbar static Diagnostic *createDiagnostics(const DiagnosticOptions &Opts, 4770fbb3d9a9cdd2201848be9eb017c54cd78538122Daniel Dunbar int Argc, char **Argv); 4780fbb3d9a9cdd2201848be9eb017c54cd78538122Daniel Dunbar 47916b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar /// Create the file manager and replace any existing one with it. 48016b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar void createFileManager(); 48116b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar 48216b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar /// Create the source manager and replace any existing one with it. 48316b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar void createSourceManager(); 48416b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar 48522dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar /// Create the preprocessor, using the invocation, file, and source managers, 48622dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar /// and replace any existing one with it. 48722dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar void createPreprocessor(); 48822dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar 48922dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar /// Create a Preprocessor object. 49022dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar /// 49122dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar /// Note that this also creates a new HeaderSearch object which will be owned 49222dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar /// by the resulting Preprocessor. 49322dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar /// 49422dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar /// \return The new object on success, or null on failure. 49522dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar static Preprocessor *createPreprocessor(Diagnostic &, const LangOptions &, 49622dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar const PreprocessorOptions &, 49722dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar const HeaderSearchOptions &, 49822dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar const DependencyOutputOptions &, 49922dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar const TargetInfo &, 5007d957472ef9a09048c03d8a11028536f908c18b9Fariborz Jahanian const FrontendOptions &, 50122dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar SourceManager &, FileManager &); 50222dacfacacf5559028550ba6ddfbaa4ea6cb3944Daniel Dunbar 5035eb810024dc8a1d12d5f066c02c978f07c4fcb00Daniel Dunbar /// Create the AST context. 5045eb810024dc8a1d12d5f066c02c978f07c4fcb00Daniel Dunbar void createASTContext(); 5055eb810024dc8a1d12d5f066c02c978f07c4fcb00Daniel Dunbar 5060f800391ffbfe3820e1c60246a09a97e5f065179Daniel Dunbar /// Create an external AST source to read a PCH file and attach it to the AST 5070f800391ffbfe3820e1c60246a09a97e5f065179Daniel Dunbar /// context. 5080f800391ffbfe3820e1c60246a09a97e5f065179Daniel Dunbar void createPCHExternalASTSource(llvm::StringRef Path); 5090f800391ffbfe3820e1c60246a09a97e5f065179Daniel Dunbar 5100f800391ffbfe3820e1c60246a09a97e5f065179Daniel Dunbar /// Create an external AST source to read a PCH file. 5110f800391ffbfe3820e1c60246a09a97e5f065179Daniel Dunbar /// 5120f800391ffbfe3820e1c60246a09a97e5f065179Daniel Dunbar /// \return - The new object on success, or null on failure. 5130f800391ffbfe3820e1c60246a09a97e5f065179Daniel Dunbar static ExternalASTSource * 5140f800391ffbfe3820e1c60246a09a97e5f065179Daniel Dunbar createPCHExternalASTSource(llvm::StringRef Path, const std::string &Sysroot, 5150f800391ffbfe3820e1c60246a09a97e5f065179Daniel Dunbar Preprocessor &PP, ASTContext &Context); 5160f800391ffbfe3820e1c60246a09a97e5f065179Daniel Dunbar 517c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar /// Create a code completion consumer using the invocation; note that this 518c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar /// will cause the source manager to truncate the input source file at the 519c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar /// completion point. 520c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar void createCodeCompletionConsumer(); 521c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar 522c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar /// Create a code completion consumer to print code completion results, at 523c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar /// \arg Filename, \arg Line, and \arg Column, to the given output stream \arg 524c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar /// OS. 525c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar static CodeCompleteConsumer * 526c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar createCodeCompletionConsumer(Preprocessor &PP, const std::string &Filename, 527c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar unsigned Line, unsigned Column, 528c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar bool UseDebugPrinter, bool ShowMacros, 529c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar llvm::raw_ostream &OS); 530c2f484f1f05216a9a427ac84b5773789a4661111Daniel Dunbar 531f79bafa608a5d7c49ec40ad199af5e32f3038b47Kovarththanan Rajaratnam /// Create the frontend timer and replace any existing one with it. 532f79bafa608a5d7c49ec40ad199af5e32f3038b47Kovarththanan Rajaratnam void createFrontendTimer(); 533f79bafa608a5d7c49ec40ad199af5e32f3038b47Kovarththanan Rajaratnam 534f482d59386dbc70716f7a5f65adb37ff86b501e6Daniel Dunbar /// Create the default output file (from the invocation's options) and add it 535f482d59386dbc70716f7a5f65adb37ff86b501e6Daniel Dunbar /// to the list of tracked output files. 536360435908c9b90429cfe192fab22854af1d4497cDaniel Dunbar /// 537360435908c9b90429cfe192fab22854af1d4497cDaniel Dunbar /// \return - Null on error. 538f482d59386dbc70716f7a5f65adb37ff86b501e6Daniel Dunbar llvm::raw_fd_ostream * 539f482d59386dbc70716f7a5f65adb37ff86b501e6Daniel Dunbar createDefaultOutputFile(bool Binary = true, llvm::StringRef BaseInput = "", 540f482d59386dbc70716f7a5f65adb37ff86b501e6Daniel Dunbar llvm::StringRef Extension = ""); 541f482d59386dbc70716f7a5f65adb37ff86b501e6Daniel Dunbar 542f482d59386dbc70716f7a5f65adb37ff86b501e6Daniel Dunbar /// Create a new output file and add it to the list of tracked output files, 543f482d59386dbc70716f7a5f65adb37ff86b501e6Daniel Dunbar /// optionally deriving the output path name. 544360435908c9b90429cfe192fab22854af1d4497cDaniel Dunbar /// 545360435908c9b90429cfe192fab22854af1d4497cDaniel Dunbar /// \return - Null on error. 546f482d59386dbc70716f7a5f65adb37ff86b501e6Daniel Dunbar llvm::raw_fd_ostream * 547f482d59386dbc70716f7a5f65adb37ff86b501e6Daniel Dunbar createOutputFile(llvm::StringRef OutputPath, bool Binary = true, 548f482d59386dbc70716f7a5f65adb37ff86b501e6Daniel Dunbar llvm::StringRef BaseInput = "", 549f482d59386dbc70716f7a5f65adb37ff86b501e6Daniel Dunbar llvm::StringRef Extension = ""); 550f482d59386dbc70716f7a5f65adb37ff86b501e6Daniel Dunbar 551f482d59386dbc70716f7a5f65adb37ff86b501e6Daniel Dunbar /// Create a new output file, optionally deriving the output path name. 552f482d59386dbc70716f7a5f65adb37ff86b501e6Daniel Dunbar /// 553f482d59386dbc70716f7a5f65adb37ff86b501e6Daniel Dunbar /// If \arg OutputPath is empty, then createOutputFile will derive an output 554f482d59386dbc70716f7a5f65adb37ff86b501e6Daniel Dunbar /// path location as \arg BaseInput, with any suffix removed, and \arg 555f482d59386dbc70716f7a5f65adb37ff86b501e6Daniel Dunbar /// Extension appended. 556f482d59386dbc70716f7a5f65adb37ff86b501e6Daniel Dunbar /// 557f482d59386dbc70716f7a5f65adb37ff86b501e6Daniel Dunbar /// \param OutputPath - If given, the path to the output file. 558f482d59386dbc70716f7a5f65adb37ff86b501e6Daniel Dunbar /// \param Error [out] - On failure, the error message. 559f482d59386dbc70716f7a5f65adb37ff86b501e6Daniel Dunbar /// \param BaseInput - If \arg OutputPath is empty, the input path name to use 560f482d59386dbc70716f7a5f65adb37ff86b501e6Daniel Dunbar /// for deriving the output path. 561f482d59386dbc70716f7a5f65adb37ff86b501e6Daniel Dunbar /// \param Extension - The extension to use for derived output names. 562f482d59386dbc70716f7a5f65adb37ff86b501e6Daniel Dunbar /// \param Binary - The mode to open the file in. 563f482d59386dbc70716f7a5f65adb37ff86b501e6Daniel Dunbar /// \param ResultPathName [out] - If given, the result path name will be 564f482d59386dbc70716f7a5f65adb37ff86b501e6Daniel Dunbar /// stored here on success. 565f482d59386dbc70716f7a5f65adb37ff86b501e6Daniel Dunbar static llvm::raw_fd_ostream * 566f482d59386dbc70716f7a5f65adb37ff86b501e6Daniel Dunbar createOutputFile(llvm::StringRef OutputPath, std::string &Error, 567f482d59386dbc70716f7a5f65adb37ff86b501e6Daniel Dunbar bool Binary = true, llvm::StringRef BaseInput = "", 568f482d59386dbc70716f7a5f65adb37ff86b501e6Daniel Dunbar llvm::StringRef Extension = "", 569f482d59386dbc70716f7a5f65adb37ff86b501e6Daniel Dunbar std::string *ResultPathName = 0); 570f482d59386dbc70716f7a5f65adb37ff86b501e6Daniel Dunbar 57116b7449d86b843d0926b04f87104cf3fff7149feDaniel Dunbar /// } 572ccb6cb6fd9e48697564d536b07397b95dfc28d5bDaniel Dunbar /// @name Initialization Utility Methods 573ccb6cb6fd9e48697564d536b07397b95dfc28d5bDaniel Dunbar /// { 574ccb6cb6fd9e48697564d536b07397b95dfc28d5bDaniel Dunbar 575ccb6cb6fd9e48697564d536b07397b95dfc28d5bDaniel Dunbar /// InitializeSourceManager - Initialize the source manager to set InputFile 576ccb6cb6fd9e48697564d536b07397b95dfc28d5bDaniel Dunbar /// as the main file. 577ccb6cb6fd9e48697564d536b07397b95dfc28d5bDaniel Dunbar /// 578ccb6cb6fd9e48697564d536b07397b95dfc28d5bDaniel Dunbar /// \return True on success. 579ccb6cb6fd9e48697564d536b07397b95dfc28d5bDaniel Dunbar bool InitializeSourceManager(llvm::StringRef InputFile); 580ccb6cb6fd9e48697564d536b07397b95dfc28d5bDaniel Dunbar 581ccb6cb6fd9e48697564d536b07397b95dfc28d5bDaniel Dunbar /// InitializeSourceManager - Initialize the source manager to set InputFile 582ccb6cb6fd9e48697564d536b07397b95dfc28d5bDaniel Dunbar /// as the main file. 583ccb6cb6fd9e48697564d536b07397b95dfc28d5bDaniel Dunbar /// 584ccb6cb6fd9e48697564d536b07397b95dfc28d5bDaniel Dunbar /// \return True on success. 585ccb6cb6fd9e48697564d536b07397b95dfc28d5bDaniel Dunbar static bool InitializeSourceManager(llvm::StringRef InputFile, 586ccb6cb6fd9e48697564d536b07397b95dfc28d5bDaniel Dunbar Diagnostic &Diags, 587ccb6cb6fd9e48697564d536b07397b95dfc28d5bDaniel Dunbar FileManager &FileMgr, 588ccb6cb6fd9e48697564d536b07397b95dfc28d5bDaniel Dunbar SourceManager &SourceMgr, 589ccb6cb6fd9e48697564d536b07397b95dfc28d5bDaniel Dunbar const FrontendOptions &Opts); 590ccb6cb6fd9e48697564d536b07397b95dfc28d5bDaniel Dunbar 591ccb6cb6fd9e48697564d536b07397b95dfc28d5bDaniel Dunbar /// } 5922a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar}; 5932a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar 5942a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar} // end namespace clang 5952a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar 5962a79e162a3fde25c1941151a67966830d873f2dbDaniel Dunbar#endif 597