diff options
author | dim <dim@FreeBSD.org> | 2011-10-20 21:14:49 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2011-10-20 21:14:49 +0000 |
commit | 3963a48221351c61c17fb3f382341ab04809a3d3 (patch) | |
tree | ee2483e98b09cac943dc93a6969d83ca737ff139 /include/clang/Frontend/CompilerInstance.h | |
parent | 611ba3ea3300b71eb95dc4e45f20eee5dddd32e1 (diff) | |
download | FreeBSD-src-3963a48221351c61c17fb3f382341ab04809a3d3.zip FreeBSD-src-3963a48221351c61c17fb3f382341ab04809a3d3.tar.gz |
Vendor import of clang release_30 branch r142614:
http://llvm.org/svn/llvm-project/cfe/branches/release_30@142614
Diffstat (limited to 'include/clang/Frontend/CompilerInstance.h')
-rw-r--r-- | include/clang/Frontend/CompilerInstance.h | 116 |
1 files changed, 65 insertions, 51 deletions
diff --git a/include/clang/Frontend/CompilerInstance.h b/include/clang/Frontend/CompilerInstance.h index 004c889..8817740 100644 --- a/include/clang/Frontend/CompilerInstance.h +++ b/include/clang/Frontend/CompilerInstance.h @@ -11,6 +11,7 @@ #define LLVM_CLANG_FRONTEND_COMPILERINSTANCE_H_ #include "clang/Frontend/CompilerInvocation.h" +#include "clang/Lex/ModuleLoader.h" #include "llvm/ADT/IntrusiveRefCntPtr.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/OwningPtr.h" @@ -19,7 +20,6 @@ #include <string> namespace llvm { -class raw_ostream; class raw_fd_ostream; class Timer; } @@ -27,13 +27,13 @@ class Timer; namespace clang { class ASTContext; class ASTConsumer; +class ASTReader; class CodeCompleteConsumer; -class Diagnostic; -class DiagnosticClient; +class DiagnosticsEngine; +class DiagnosticConsumer; class ExternalASTSource; class FileManager; class FrontendAction; -class ASTReader; class Preprocessor; class Sema; class SourceManager; @@ -57,12 +57,12 @@ class TargetInfo; /// in to the compiler instance for everything. When possible, utility functions /// 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 { +class CompilerInstance : public ModuleLoader { /// The options used in this compiler instance. llvm::IntrusiveRefCntPtr<CompilerInvocation> Invocation; /// The diagnostics engine instance. - llvm::IntrusiveRefCntPtr<Diagnostic> Diagnostics; + llvm::IntrusiveRefCntPtr<DiagnosticsEngine> Diagnostics; /// The target being compiled for. llvm::IntrusiveRefCntPtr<TargetInfo> Target; @@ -88,9 +88,12 @@ class CompilerInstance { /// \brief The semantic analysis object. llvm::OwningPtr<Sema> TheSema; - /// The frontend timer + /// \brief The frontend timer llvm::OwningPtr<llvm::Timer> FrontendTimer; + /// \brief Non-owning reference to the ASTReader, if one exists. + ASTReader *ModuleManager; + /// \brief Holds information about the output file. /// /// If TempFilename is not empty we must rename it to Filename at the end. @@ -99,10 +102,10 @@ class CompilerInstance { struct OutputFile { std::string Filename; std::string TempFilename; - llvm::raw_ostream *OS; + raw_ostream *OS; OutputFile(const std::string &filename, const std::string &tempFilename, - llvm::raw_ostream *os) + raw_ostream *os) : Filename(filename), TempFilename(tempFilename), OS(os) { } }; @@ -249,15 +252,15 @@ public: bool hasDiagnostics() const { return Diagnostics != 0; } /// Get the current diagnostics engine. - Diagnostic &getDiagnostics() const { + DiagnosticsEngine &getDiagnostics() const { assert(Diagnostics && "Compiler instance has no diagnostics!"); return *Diagnostics; } /// setDiagnostics - Replace the current diagnostics engine. - void setDiagnostics(Diagnostic *Value); + void setDiagnostics(DiagnosticsEngine *Value); - DiagnosticClient &getDiagnosticClient() const { + DiagnosticConsumer &getDiagnosticClient() const { assert(Diagnostics && Diagnostics->getClient() && "Compiler instance has no diagnostic client!"); return *Diagnostics->getClient(); @@ -388,6 +391,12 @@ public: Sema *takeSema() { return TheSema.take(); } /// } + /// @name Module Management + /// { + + ASTReader *getModuleManager() const { return ModuleManager; } + + /// } /// @name Code Completion /// { @@ -446,38 +455,48 @@ public: /// 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 + /// attached to (and, then, owned by) the DiagnosticsEngine inside this AST /// unit. + /// + /// \param ShouldOwnClient If Client is non-NULL, specifies whether + /// the diagnostic object should take ownership of the client. + /// + /// \param ShouldCloneClient If Client is non-NULL, specifies whether that + /// client should be cloned. void createDiagnostics(int Argc, const char* const *Argv, - DiagnosticClient *Client = 0); + DiagnosticConsumer *Client = 0, + bool ShouldOwnClient = true, + bool ShouldCloneClient = true); - /// Create a Diagnostic object with a the TextDiagnosticPrinter. + /// Create a DiagnosticsEngine object with a the TextDiagnosticPrinter. /// /// The \arg Argc and \arg Argv arguments are used only for logging purposes, /// when the diagnostic options indicate that the compiler should output /// logging information. /// /// If no diagnostic client is provided, this creates a - /// DiagnosticClient that is owned by the returned diagnostic + /// DiagnosticConsumer that is owned by the returned diagnostic /// object, if using directly the caller is responsible for - /// releasing the returned Diagnostic's client eventually. + /// releasing the returned DiagnosticsEngine'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 + /// attached to (and, then, owned by) the returned DiagnosticsEngine /// object. /// /// \param CodeGenOpts If non-NULL, the code gen options in use, which may be /// used by some diagnostics printers (for logging purposes only). /// /// \return The new object on success, or null on failure. - static llvm::IntrusiveRefCntPtr<Diagnostic> + static llvm::IntrusiveRefCntPtr<DiagnosticsEngine> createDiagnostics(const DiagnosticOptions &Opts, int Argc, const char* const *Argv, - DiagnosticClient *Client = 0, + DiagnosticConsumer *Client = 0, + bool ShouldOwnClient = true, + bool ShouldCloneClient = true, const CodeGenOptions *CodeGenOpts = 0); /// Create the file manager and replace any existing one with it. @@ -490,26 +509,12 @@ public: /// and replace any existing one with it. void createPreprocessor(); - /// Create a Preprocessor object. - /// - /// Note that this also creates a new HeaderSearch object which will be owned - /// by the resulting Preprocessor. - /// - /// \return The new object on success, or null on failure. - static Preprocessor *createPreprocessor(Diagnostic &, const LangOptions &, - const PreprocessorOptions &, - const HeaderSearchOptions &, - const DependencyOutputOptions &, - const TargetInfo &, - const FrontendOptions &, - SourceManager &, FileManager &); - /// Create the AST context. void createASTContext(); /// Create an external AST source to read a PCH file and attach it to the AST /// context. - void createPCHExternalASTSource(llvm::StringRef Path, + void createPCHExternalASTSource(StringRef Path, bool DisablePCHValidation, bool DisableStatCache, void *DeserializationListener); @@ -518,7 +523,7 @@ public: /// /// \return - The new object on success, or null on failure. static ExternalASTSource * - createPCHExternalASTSource(llvm::StringRef Path, const std::string &Sysroot, + createPCHExternalASTSource(StringRef Path, const std::string &Sysroot, bool DisablePCHValidation, bool DisableStatCache, Preprocessor &PP, ASTContext &Context, @@ -537,10 +542,10 @@ public: unsigned Line, unsigned Column, bool ShowMacros, bool ShowCodePatterns, bool ShowGlobals, - llvm::raw_ostream &OS); + raw_ostream &OS); /// \brief Create the Sema object to be used for parsing. - void createSema(bool CompleteTranslationUnit, + void createSema(TranslationUnitKind TUKind, CodeCompleteConsumer *CompletionConsumer); /// Create the frontend timer and replace any existing one with it. @@ -551,25 +556,27 @@ public: /// /// \return - Null on error. llvm::raw_fd_ostream * - createDefaultOutputFile(bool Binary = true, llvm::StringRef BaseInput = "", - llvm::StringRef Extension = ""); + createDefaultOutputFile(bool Binary = true, StringRef BaseInput = "", + StringRef Extension = ""); /// Create a new output file and add it to the list of tracked output files, /// optionally deriving the output path name. /// /// \return - Null on error. llvm::raw_fd_ostream * - createOutputFile(llvm::StringRef OutputPath, + createOutputFile(StringRef OutputPath, bool Binary = true, bool RemoveFileOnSignal = true, - llvm::StringRef BaseInput = "", - llvm::StringRef Extension = ""); + StringRef BaseInput = "", + StringRef Extension = "", + bool UseTemporary = false); /// Create a new output file, optionally deriving the output path name. /// /// If \arg OutputPath is empty, then createOutputFile will derive an output /// path location as \arg BaseInput, with any suffix removed, and \arg - /// Extension appended. If OutputPath is not stdout createOutputFile will - /// create a new temporary file that must be renamed to OutputPath in the end. + /// Extension appended. If OutputPath is not stdout and \arg UseTemporary + /// is true, 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. @@ -580,15 +587,18 @@ public: /// \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 UseTemporary - Create a new temporary file that must be renamed to + /// OutputPath in the end /// \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, + createOutputFile(StringRef OutputPath, std::string &Error, bool Binary = true, bool RemoveFileOnSignal = true, - llvm::StringRef BaseInput = "", - llvm::StringRef Extension = "", + StringRef BaseInput = "", + StringRef Extension = "", + bool UseTemporary = false, std::string *ResultPathName = 0, std::string *TempPathName = 0); @@ -600,19 +610,23 @@ public: /// as the main file. /// /// \return True on success. - bool InitializeSourceManager(llvm::StringRef InputFile); + bool InitializeSourceManager(StringRef InputFile); /// InitializeSourceManager - Initialize the source manager to set InputFile /// as the main file. /// /// \return True on success. - static bool InitializeSourceManager(llvm::StringRef InputFile, - Diagnostic &Diags, + static bool InitializeSourceManager(StringRef InputFile, + DiagnosticsEngine &Diags, FileManager &FileMgr, SourceManager &SourceMgr, const FrontendOptions &Opts); /// } + + virtual ModuleKey loadModule(SourceLocation ImportLoc, + IdentifierInfo &ModuleName, + SourceLocation ModuleNameLoc); }; } // end namespace clang |