diff options
Diffstat (limited to 'include/clang/Frontend/CompilerInstance.h')
-rw-r--r-- | include/clang/Frontend/CompilerInstance.h | 102 |
1 files changed, 59 insertions, 43 deletions
diff --git a/include/clang/Frontend/CompilerInstance.h b/include/clang/Frontend/CompilerInstance.h index 1b3c336fc0eb..7ea79e5599ff 100644 --- a/include/clang/Frontend/CompilerInstance.h +++ b/include/clang/Frontend/CompilerInstance.h @@ -19,7 +19,6 @@ #include <string> namespace llvm { -class LLVMContext; class raw_ostream; class raw_fd_ostream; class Timer; @@ -59,9 +58,6 @@ class TargetInfo; /// come in two forms; a short form that reuses the CompilerInstance objects, /// and a long form that takes explicit instances of any required objects. class CompilerInstance { - /// The LLVM context used for this instance. - llvm::OwningPtr<llvm::LLVMContext> LLVMContext; - /// The options used in this compiler instance. llvm::OwningPtr<CompilerInvocation> Invocation; @@ -95,8 +91,23 @@ class CompilerInstance { /// The frontend timer llvm::OwningPtr<llvm::Timer> FrontendTimer; + /// \brief Holds information about the output file. + /// + /// If TempFilename is not empty we must rename it to Filename at the end. + /// TempFilename may be empty and Filename non empty if creating the temporary + /// failed. + struct OutputFile { + std::string Filename; + std::string TempFilename; + llvm::raw_ostream *OS; + + OutputFile(const std::string &filename, const std::string &tempFilename, + llvm::raw_ostream *os) + : Filename(filename), TempFilename(tempFilename), OS(os) { } + }; + /// The list of active output files. - std::list< std::pair<std::string, llvm::raw_ostream*> > OutputFiles; + std::list<OutputFile> OutputFiles; void operator=(const CompilerInstance &); // DO NOT IMPLEMENT CompilerInstance(const CompilerInstance&); // DO NOT IMPLEMENT @@ -140,23 +151,6 @@ public: bool ExecuteAction(FrontendAction &Act); /// } - /// @name LLVM Context - /// { - - bool hasLLVMContext() const { return LLVMContext != 0; } - - llvm::LLVMContext &getLLVMContext() const { - assert(LLVMContext && "Compiler instance has no LLVM context!"); - return *LLVMContext; - } - - llvm::LLVMContext *takeLLVMContext() { return LLVMContext.take(); } - - /// setLLVMContext - Replace the current LLVM context and take ownership of - /// \arg Value. - void setLLVMContext(llvm::LLVMContext *Value); - - /// } /// @name Compiler Invocation and Options /// { @@ -205,6 +199,10 @@ public: return Invocation->getDiagnosticOpts(); } + const FileSystemOptions &getFileSystemOpts() const { + return Invocation->getFileSystemOpts(); + } + FrontendOptions &getFrontendOpts() { return Invocation->getFrontendOpts(); } @@ -435,16 +433,10 @@ public: /// @name Output Files /// { - /// getOutputFileList - Get the list of (path, output stream) pairs of output - /// files; the path may be empty but the stream will always be non-null. - const std::list< std::pair<std::string, - llvm::raw_ostream*> > &getOutputFileList() const; - /// addOutputFile - Add an output file onto the list of tracked output files. /// - /// \param Path - The path to the output file, or empty. - /// \param OS - The output stream, which should be non-null. - void addOutputFile(llvm::StringRef Path, llvm::raw_ostream *OS); + /// \param OutFile - The output file info. + void addOutputFile(const OutputFile &OutFile); /// clearOutputFiles - Clear the output file list, destroying the contained /// output streams. @@ -459,8 +451,14 @@ public: /// Create the diagnostics engine using the invocation's diagnostic options /// and replace any existing one with it. /// - /// Note that this routine also replaces the diagnostic client. - void createDiagnostics(int Argc, char **Argv); + /// Note that this routine also replaces the diagnostic client, + /// allocating one if one is not provided. + /// + /// \param Client If non-NULL, a diagnostic client that will be + /// attached to (and, then, owned by) the Diagnostic inside this AST + /// unit. + void createDiagnostics(int Argc, const char* const *Argv, + DiagnosticClient *Client = 0); /// Create a Diagnostic object with a the TextDiagnosticPrinter. /// @@ -468,23 +466,30 @@ public: /// when the diagnostic options indicate that the compiler should output /// logging information. /// - /// Note that this creates an unowned DiagnosticClient, if using directly the - /// caller is responsible for releasing the returned Diagnostic's client - /// eventually. + /// If no diagnostic client is provided, this creates a + /// DiagnosticClient that is owned by the returned diagnostic + /// object, if using directly the caller is responsible for + /// releasing the returned Diagnostic's client eventually. /// /// \param Opts - The diagnostic options; note that the created text /// diagnostic object contains a reference to these options and its lifetime /// must extend past that of the diagnostic engine. /// + /// \param Client If non-NULL, a diagnostic client that will be + /// attached to (and, then, owned by) the returned Diagnostic + /// object. + /// /// \return The new object on success, or null on failure. static llvm::IntrusiveRefCntPtr<Diagnostic> - createDiagnostics(const DiagnosticOptions &Opts, int Argc, char **Argv); + createDiagnostics(const DiagnosticOptions &Opts, int Argc, + const char* const *Argv, + DiagnosticClient *Client = 0); /// Create the file manager and replace any existing one with it. void createFileManager(); /// Create the source manager and replace any existing one with it. - void createSourceManager(); + void createSourceManager(FileManager &FileMgr); /// Create the preprocessor, using the invocation, file, and source managers, /// and replace any existing one with it. @@ -511,6 +516,7 @@ public: /// context. void createPCHExternalASTSource(llvm::StringRef Path, bool DisablePCHValidation, + bool DisableStatCache, void *DeserializationListener); /// Create an external AST source to read a PCH file. @@ -519,8 +525,9 @@ public: static ExternalASTSource * createPCHExternalASTSource(llvm::StringRef Path, const std::string &Sysroot, bool DisablePCHValidation, + bool DisableStatCache, Preprocessor &PP, ASTContext &Context, - void *DeserializationListener); + void *DeserializationListener, bool Preamble); /// Create a code completion consumer using the invocation; note that this /// will cause the source manager to truncate the input source file at the @@ -533,7 +540,7 @@ public: static CodeCompleteConsumer * createCodeCompletionConsumer(Preprocessor &PP, const std::string &Filename, unsigned Line, unsigned Column, - bool UseDebugPrinter, bool ShowMacros, + bool ShowMacros, bool ShowCodePatterns, bool ShowGlobals, llvm::raw_ostream &OS); @@ -557,7 +564,8 @@ public: /// /// \return - Null on error. llvm::raw_fd_ostream * - createOutputFile(llvm::StringRef OutputPath, bool Binary = true, + createOutputFile(llvm::StringRef OutputPath, + bool Binary = true, bool RemoveFileOnSignal = true, llvm::StringRef BaseInput = "", llvm::StringRef Extension = ""); @@ -565,7 +573,8 @@ public: /// /// If \arg OutputPath is empty, then createOutputFile will derive an output /// path location as \arg BaseInput, with any suffix removed, and \arg - /// Extension appended. + /// Extension appended. If OutputPath is not stdout createOutputFile will + /// create a new temporary file that must be renamed to OutputPath in the end. /// /// \param OutputPath - If given, the path to the output file. /// \param Error [out] - On failure, the error message. @@ -573,13 +582,20 @@ public: /// for deriving the output path. /// \param Extension - The extension to use for derived output names. /// \param Binary - The mode to open the file in. + /// \param RemoveFileOnSignal - Whether the file should be registered with + /// llvm::sys::RemoveFileOnSignal. Note that this is not safe for + /// multithreaded use, as the underlying signal mechanism is not reentrant /// \param ResultPathName [out] - If given, the result path name will be /// stored here on success. + /// \param TempPathName [out] - If given, the temporary file path name + /// will be stored here on success. static llvm::raw_fd_ostream * createOutputFile(llvm::StringRef OutputPath, std::string &Error, - bool Binary = true, llvm::StringRef BaseInput = "", + bool Binary = true, bool RemoveFileOnSignal = true, + llvm::StringRef BaseInput = "", llvm::StringRef Extension = "", - std::string *ResultPathName = 0); + std::string *ResultPathName = 0, + std::string *TempPathName = 0); /// } /// @name Initialization Utility Methods |