diff options
author | rdivacky <rdivacky@FreeBSD.org> | 2010-03-03 17:28:16 +0000 |
---|---|---|
committer | rdivacky <rdivacky@FreeBSD.org> | 2010-03-03 17:28:16 +0000 |
commit | df90325d4c0a65ee64d2dae3ed9b5b34f7418533 (patch) | |
tree | e1a885aadfd80632f5bd70d4bd2d37e715e35a79 /include/clang/Frontend | |
parent | fd035e6496665b1f1197868e21cb0a4594e8db6e (diff) | |
download | FreeBSD-src-df90325d4c0a65ee64d2dae3ed9b5b34f7418533.zip FreeBSD-src-df90325d4c0a65ee64d2dae3ed9b5b34f7418533.tar.gz |
Update clang to 97654.
Diffstat (limited to 'include/clang/Frontend')
-rw-r--r-- | include/clang/Frontend/ASTConsumers.h | 20 | ||||
-rw-r--r-- | include/clang/Frontend/ASTUnit.h | 38 | ||||
-rw-r--r-- | include/clang/Frontend/CodeGenAction.h | 65 | ||||
-rw-r--r-- | include/clang/Frontend/FrontendActions.h | 40 | ||||
-rw-r--r-- | include/clang/Frontend/PCHBitCodes.h | 4 | ||||
-rw-r--r-- | include/clang/Frontend/TextDiagnosticPrinter.h | 8 |
6 files changed, 108 insertions, 67 deletions
diff --git a/include/clang/Frontend/ASTConsumers.h b/include/clang/Frontend/ASTConsumers.h index 7ec5063..b5b09f5 100644 --- a/include/clang/Frontend/ASTConsumers.h +++ b/include/clang/Frontend/ASTConsumers.h @@ -69,26 +69,6 @@ ASTConsumer *CreateObjCRewriter(const std::string &InFile, const LangOptions &LOpts, bool SilenceRewriteMacroWarning); -// LLVM code generator: uses the code generation backend to generate LLVM -// assembly. This runs optimizations depending on the CodeGenOptions -// parameter. The output depends on the Action parameter. -enum BackendAction { - Backend_EmitAssembly, // Emit native assembly files - Backend_EmitBC, // Emit LLVM bitcode files - Backend_EmitLL, // Emit human-readable LLVM assembly - Backend_EmitNothing, // Don't emit anything (benchmarking mode) - Backend_EmitObj // Emit native object files -}; -ASTConsumer *CreateBackendConsumer(BackendAction Action, - Diagnostic &Diags, - const LangOptions &Features, - const CodeGenOptions &CodeGenOpts, - const TargetOptions &TargetOpts, - bool TimePasses, - const std::string &ModuleID, - llvm::raw_ostream *OS, - llvm::LLVMContext& C); - /// CreateHTMLPrinter - Create an AST consumer which rewrites source code to /// HTML with syntax highlighting suitable for viewing in a web-browser. ASTConsumer *CreateHTMLPrinter(llvm::raw_ostream *OS, Preprocessor &PP, diff --git a/include/clang/Frontend/ASTUnit.h b/include/clang/Frontend/ASTUnit.h index f122dd9..626a162 100644 --- a/include/clang/Frontend/ASTUnit.h +++ b/include/clang/Frontend/ASTUnit.h @@ -18,6 +18,8 @@ #include "llvm/ADT/OwningPtr.h" #include "clang/Basic/FileManager.h" #include "clang/Index/ASTLocation.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/System/Path.h" #include <string> #include <vector> #include <cassert> @@ -51,7 +53,6 @@ class ASTUnit { llvm::OwningPtr<TargetInfo> Target; llvm::OwningPtr<Preprocessor> PP; llvm::OwningPtr<ASTContext> Ctx; - bool tempFile; /// Optional owned invocation, just used to make the invocation used in /// LoadFromCommandLine available. @@ -80,6 +81,14 @@ class ASTUnit { // Critical optimization when using clang_getCursor(). ASTLocation LastLoc; + /// \brief The set of diagnostics produced when creating this + /// translation unit. + llvm::SmallVector<StoredDiagnostic, 4> Diagnostics; + + /// \brief Temporary files that should be removed when the ASTUnit is + /// destroyed. + llvm::SmallVector<llvm::sys::Path, 4> TemporaryFiles; + ASTUnit(const ASTUnit&); // DO NOT IMPLEMENT ASTUnit &operator=(const ASTUnit &); // DO NOT IMPLEMENT @@ -104,8 +113,13 @@ public: const std::string &getOriginalSourceFileName(); const std::string &getPCHFileName(); - void unlinkTemporaryFile() { tempFile = true; } - + /// \brief Add a temporary file that the ASTUnit depends on. + /// + /// This file will be erased when the ASTUnit is destroyed. + void addTemporaryFile(const llvm::sys::Path &TempFile) { + TemporaryFiles.push_back(TempFile); + } + bool getOnlyLocalDecls() const { return OnlyLocalDecls; } void setLastASTLocation(ASTLocation ALoc) { LastLoc = ALoc; } @@ -120,6 +134,15 @@ public: return TopLevelDecls; } + // Retrieve the diagnostics associated with this AST + typedef const StoredDiagnostic * diag_iterator; + diag_iterator diag_begin() const { return Diagnostics.begin(); } + diag_iterator diag_end() const { return Diagnostics.end(); } + unsigned diag_size() const { return Diagnostics.size(); } + llvm::SmallVector<StoredDiagnostic, 4> &getDiagnostics() { + return Diagnostics; + } + /// \brief A mapping from a file name to the memory buffer that stores the /// remapped contents of that file. typedef std::pair<std::string, const llvm::MemoryBuffer *> RemappedFile; @@ -136,7 +159,8 @@ public: Diagnostic &Diags, bool OnlyLocalDecls = false, RemappedFile *RemappedFiles = 0, - unsigned NumRemappedFiles = 0); + unsigned NumRemappedFiles = 0, + bool CaptureDiagnostics = false); /// LoadFromCompilerInvocation - Create an ASTUnit from a source file, via a /// CompilerInvocation object. @@ -151,7 +175,8 @@ public: // shouldn't need to specify them at construction time. static ASTUnit *LoadFromCompilerInvocation(CompilerInvocation *CI, Diagnostic &Diags, - bool OnlyLocalDecls = false); + bool OnlyLocalDecls = false, + bool CaptureDiagnostics = false); /// LoadFromCommandLine - Create an ASTUnit from a vector of command line /// arguments, which must specify exactly one source file. @@ -173,7 +198,8 @@ public: llvm::StringRef ResourceFilesPath, bool OnlyLocalDecls = false, RemappedFile *RemappedFiles = 0, - unsigned NumRemappedFiles = 0); + unsigned NumRemappedFiles = 0, + bool CaptureDiagnostics = false); }; } // namespace clang diff --git a/include/clang/Frontend/CodeGenAction.h b/include/clang/Frontend/CodeGenAction.h new file mode 100644 index 0000000..a1e3c42 --- /dev/null +++ b/include/clang/Frontend/CodeGenAction.h @@ -0,0 +1,65 @@ +//===--- CodeGenAction.h - LLVM Code Generation Frontend Action -*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "clang/Frontend/FrontendAction.h" +#include "llvm/ADT/OwningPtr.h" + +namespace llvm { + class Module; +} + +namespace clang { + +class CodeGenAction : public ASTFrontendAction { +private: + unsigned Act; + llvm::OwningPtr<llvm::Module> TheModule; + +protected: + CodeGenAction(unsigned _Act); + + virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, + llvm::StringRef InFile); + + virtual void EndSourceFileAction(); + +public: + ~CodeGenAction(); + + /// takeModule - Take the generated LLVM module, for use after the action has + /// been run. The result may be null on failure. + llvm::Module *takeModule(); +}; + +class EmitAssemblyAction : public CodeGenAction { +public: + EmitAssemblyAction(); +}; + +class EmitBCAction : public CodeGenAction { +public: + EmitBCAction(); +}; + +class EmitLLVMAction : public CodeGenAction { +public: + EmitLLVMAction(); +}; + +class EmitLLVMOnlyAction : public CodeGenAction { +public: + EmitLLVMOnlyAction(); +}; + +class EmitObjAction : public CodeGenAction { +public: + EmitObjAction(); +}; + +} diff --git a/include/clang/Frontend/FrontendActions.h b/include/clang/Frontend/FrontendActions.h index cbb3508..5348e6b 100644 --- a/include/clang/Frontend/FrontendActions.h +++ b/include/clang/Frontend/FrontendActions.h @@ -159,46 +159,6 @@ public: }; //===----------------------------------------------------------------------===// -// Code Gen AST Actions -//===----------------------------------------------------------------------===// - -class CodeGenAction : public ASTFrontendAction { -private: - unsigned Act; - -protected: - CodeGenAction(unsigned _Act); - - virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, - llvm::StringRef InFile); -}; - -class EmitAssemblyAction : public CodeGenAction { -public: - EmitAssemblyAction(); -}; - -class EmitBCAction : public CodeGenAction { -public: - EmitBCAction(); -}; - -class EmitLLVMAction : public CodeGenAction { -public: - EmitLLVMAction(); -}; - -class EmitLLVMOnlyAction : public CodeGenAction { -public: - EmitLLVMOnlyAction(); -}; - -class EmitObjAction : public CodeGenAction { -public: - EmitObjAction(); -}; - -//===----------------------------------------------------------------------===// // Preprocessor Actions //===----------------------------------------------------------------------===// diff --git a/include/clang/Frontend/PCHBitCodes.h b/include/clang/Frontend/PCHBitCodes.h index e22d37b..d4014b3 100644 --- a/include/clang/Frontend/PCHBitCodes.h +++ b/include/clang/Frontend/PCHBitCodes.h @@ -524,7 +524,9 @@ namespace clang { /// associates a declaration name with one or more declaration /// IDs. This data is used when performing qualified name lookup /// into a DeclContext via DeclContext::lookup. - DECL_CONTEXT_VISIBLE + DECL_CONTEXT_VISIBLE, + /// \brief A NamespaceDecl record. + DECL_NAMESPACE }; /// \brief Record codes for each kind of statement or expression. diff --git a/include/clang/Frontend/TextDiagnosticPrinter.h b/include/clang/Frontend/TextDiagnosticPrinter.h index d727e48..d09e51f 100644 --- a/include/clang/Frontend/TextDiagnosticPrinter.h +++ b/include/clang/Frontend/TextDiagnosticPrinter.h @@ -37,11 +37,19 @@ class TextDiagnosticPrinter : public DiagnosticClient { unsigned LastCaretDiagnosticWasNote : 1; unsigned OwnsOutputStream : 1; + /// A string to prefix to error messages. + std::string Prefix; + public: TextDiagnosticPrinter(llvm::raw_ostream &os, const DiagnosticOptions &diags, bool OwnsOutputStream = false); virtual ~TextDiagnosticPrinter(); + /// setPrefix - Set the diagnostic printer prefix string, which will be + /// printed at the start of any diagnostics. If empty, no prefix string is + /// used. + void setPrefix(std::string Value) { Prefix = Value; } + void BeginSourceFile(const LangOptions &LO, const Preprocessor *PP) { LangOpts = &LO; } |