diff options
author | Daniel Dunbar <daniel@zuster.org> | 2010-06-15 17:48:49 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2010-06-15 17:48:49 +0000 |
commit | 9b414d3e2d0cb84512b55a3275a98490b090162a (patch) | |
tree | a9e89bf09e843286a73c99a9e18520c48ad725b0 /include/clang/Frontend | |
parent | c722ea4fbf886d6460b256b5e819a4ee751d5fff (diff) |
Break Frontend's dependency on Rewrite, Checker and CodeGen in shared library configuration
Currently, all AST consumers are located in the Frontend library,
meaning that in a shared library configuration, Frontend has a
dependency on Rewrite, Checker and CodeGen. This is suboptimal for
clients which only wish to make use of the frontend. CodeGen in
particular introduces a large number of unwanted dependencies.
This patch breaks the dependency by moving all AST consumers with
dependencies on Rewrite, Checker and/or CodeGen to their respective
libraries. The patch therefore introduces dependencies in the other
direction (i.e. from Rewrite, Checker and CodeGen to Frontend).
After applying this patch, Clang builds correctly using CMake and
shared libraries ("cmake -DBUILD_SHARED_LIBS=ON").
N.B. This patch includes file renames which are indicated in the
patch body.
Changes in this revision of the patch:
- Fixed some copy-paste mistakes in the header files
- Modified certain aspects of the coding to comply with the LLVM
Coding Standards
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106010 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Frontend')
-rw-r--r-- | include/clang/Frontend/ASTConsumers.h | 14 | ||||
-rw-r--r-- | include/clang/Frontend/AnalyzerOptions.h (renamed from include/clang/Frontend/AnalysisConsumer.h) | 17 | ||||
-rw-r--r-- | include/clang/Frontend/BackendUtil.h | 32 | ||||
-rw-r--r-- | include/clang/Frontend/CodeGenAction.h | 74 | ||||
-rw-r--r-- | include/clang/Frontend/CompilerInvocation.h | 2 | ||||
-rw-r--r-- | include/clang/Frontend/FixItRewriter.h | 104 | ||||
-rw-r--r-- | include/clang/Frontend/FrontendActions.h | 50 | ||||
-rw-r--r-- | include/clang/Frontend/PathDiagnosticClients.h | 32 | ||||
-rw-r--r-- | include/clang/Frontend/Utils.h | 6 |
9 files changed, 6 insertions, 325 deletions
diff --git a/include/clang/Frontend/ASTConsumers.h b/include/clang/Frontend/ASTConsumers.h index 9163a208de..e42b1f2cd9 100644 --- a/include/clang/Frontend/ASTConsumers.h +++ b/include/clang/Frontend/ASTConsumers.h @@ -57,20 +57,6 @@ ASTConsumer *CreateASTViewer(); // to stderr; this is intended for debugging. ASTConsumer *CreateDeclContextPrinter(); -// ObjC rewriter: attempts tp rewrite ObjC constructs into pure C code. -// This is considered experimental, and only works with Apple's ObjC runtime. -ASTConsumer *CreateObjCRewriter(const std::string &InFile, - llvm::raw_ostream *OS, - Diagnostic &Diags, - const LangOptions &LOpts, - bool SilenceRewriteMacroWarning); - -/// 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, - bool SyntaxHighlight = true, - bool HighlightMacros = true); - // PCH generator: generates a precompiled header file; this file can be used // later with the PCHReader (clang -cc1 option -include-pch) to speed up compile // times. diff --git a/include/clang/Frontend/AnalysisConsumer.h b/include/clang/Frontend/AnalyzerOptions.h index 2cbdf368a8..d8fcdeb9b0 100644 --- a/include/clang/Frontend/AnalysisConsumer.h +++ b/include/clang/Frontend/AnalyzerOptions.h @@ -1,4 +1,4 @@ -//===--- AnalysisConsumer.h - Front-end Analysis Engine Hooks ---*- C++ -*-===// +//===--- AnalyzerOptions.h - Analysis Engine Options ------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,13 +7,13 @@ // //===----------------------------------------------------------------------===// // -// This header contains the functions necessary for a front-end to run various -// analyses. +// This header contains the structures necessary for a front-end to specify +// various analyses. // //===----------------------------------------------------------------------===// -#ifndef LLVM_CLANG_FRONTEND_ANALYSISCONSUMER_H -#define LLVM_CLANG_FRONTEND_ANALYSISCONSUMER_H +#ifndef LLVM_CLANG_FRONTEND_ANALYZEROPTIONS_H +#define LLVM_CLANG_FRONTEND_ANALYZEROPTIONS_H #include <string> #include <vector> @@ -92,13 +92,6 @@ public: } }; -/// CreateAnalysisConsumer - Creates an ASTConsumer to run various code -/// analysis passes. (The set of analyses run is controlled by command-line -/// options.) -ASTConsumer* CreateAnalysisConsumer(const Preprocessor &pp, - const std::string &output, - const AnalyzerOptions& Opts); - } #endif diff --git a/include/clang/Frontend/BackendUtil.h b/include/clang/Frontend/BackendUtil.h deleted file mode 100644 index 39c743c634..0000000000 --- a/include/clang/Frontend/BackendUtil.h +++ /dev/null @@ -1,32 +0,0 @@ -//===--- BackendUtil.h - LLVM Backend Utilities -----------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace llvm { - class Module; - class raw_ostream; -} - -namespace clang { - class Diagnostic; - class CodeGenOptions; - class TargetOptions; - - 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_EmitMCNull, ///< Run CodeGen, but don't emit anything - Backend_EmitObj ///< Emit native object files - }; - - void EmitBackendOutput(Diagnostic &Diags, const CodeGenOptions &CGOpts, - const TargetOptions &TOpts, llvm::Module *M, - BackendAction Action, llvm::raw_ostream *OS); -} diff --git a/include/clang/Frontend/CodeGenAction.h b/include/clang/Frontend/CodeGenAction.h deleted file mode 100644 index e05176a689..0000000000 --- a/include/clang/Frontend/CodeGenAction.h +++ /dev/null @@ -1,74 +0,0 @@ -//===--- 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 bool hasIRSupport() const; - - virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, - llvm::StringRef InFile); - - virtual void ExecuteAction(); - - 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 EmitCodeGenOnlyAction : public CodeGenAction { -public: - EmitCodeGenOnlyAction(); -}; - -class EmitObjAction : public CodeGenAction { -public: - EmitObjAction(); -}; - -} diff --git a/include/clang/Frontend/CompilerInvocation.h b/include/clang/Frontend/CompilerInvocation.h index f5a9053ceb..05e1aa09cf 100644 --- a/include/clang/Frontend/CompilerInvocation.h +++ b/include/clang/Frontend/CompilerInvocation.h @@ -13,7 +13,7 @@ #include "clang/Basic/LangOptions.h" #include "clang/Basic/TargetOptions.h" #include "clang/CodeGen/CodeGenOptions.h" -#include "clang/Frontend/AnalysisConsumer.h" +#include "clang/Frontend/AnalyzerOptions.h" #include "clang/Frontend/DependencyOutputOptions.h" #include "clang/Frontend/DiagnosticOptions.h" #include "clang/Frontend/FrontendOptions.h" diff --git a/include/clang/Frontend/FixItRewriter.h b/include/clang/Frontend/FixItRewriter.h deleted file mode 100644 index b432d747de..0000000000 --- a/include/clang/Frontend/FixItRewriter.h +++ /dev/null @@ -1,104 +0,0 @@ -//===--- FixItRewriter.h - Fix-It Rewriter Diagnostic Client ----*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This is a diagnostic client adaptor that performs rewrites as -// suggested by code modification hints attached to diagnostics. It -// then forwards any diagnostics to the adapted diagnostic client. -// -//===----------------------------------------------------------------------===// -#ifndef LLVM_CLANG_FRONTEND_FIX_IT_REWRITER_H -#define LLVM_CLANG_FRONTEND_FIX_IT_REWRITER_H - -#include "clang/Basic/Diagnostic.h" -#include "clang/Basic/SourceLocation.h" -#include "clang/Rewrite/Rewriter.h" -#include "llvm/ADT/SmallVector.h" - -namespace llvm { class raw_ostream; } - -namespace clang { - -class SourceManager; -class FileEntry; - -class FixItPathRewriter { -public: - virtual ~FixItPathRewriter(); - - /// \brief This file is about to be rewritten. Return the name of the file - /// that is okay to write to. - virtual std::string RewriteFilename(const std::string &Filename) = 0; -}; - -class FixItRewriter : public DiagnosticClient { - /// \brief The diagnostics machinery. - Diagnostic &Diags; - - /// \brief The rewriter used to perform the various code - /// modifications. - Rewriter Rewrite; - - /// \brief The diagnostic client that performs the actual formatting - /// of error messages. - DiagnosticClient *Client; - - /// \brief Turn an input path into an output path. NULL implies overwriting - /// the original. - FixItPathRewriter *PathRewriter; - - /// \brief The number of rewriter failures. - unsigned NumFailures; - -public: - typedef Rewriter::buffer_iterator iterator; - - /// \brief Initialize a new fix-it rewriter. - FixItRewriter(Diagnostic &Diags, SourceManager &SourceMgr, - const LangOptions &LangOpts, FixItPathRewriter *PathRewriter); - - /// \brief Destroy the fix-it rewriter. - ~FixItRewriter(); - - /// \brief Check whether there are modifications for a given file. - bool IsModified(FileID ID) const { - return Rewrite.getRewriteBufferFor(ID) != NULL; - } - - // Iteration over files with changes. - iterator buffer_begin() { return Rewrite.buffer_begin(); } - iterator buffer_end() { return Rewrite.buffer_end(); } - - /// \brief Write a single modified source file. - /// - /// \returns true if there was an error, false otherwise. - bool WriteFixedFile(FileID ID, llvm::raw_ostream &OS); - - /// \brief Write the modified source files. - /// - /// \returns true if there was an error, false otherwise. - bool WriteFixedFiles(); - - /// IncludeInDiagnosticCounts - This method (whose default implementation - /// returns true) indicates whether the diagnostics handled by this - /// DiagnosticClient should be included in the number of diagnostics - /// reported by Diagnostic. - virtual bool IncludeInDiagnosticCounts() const; - - /// HandleDiagnostic - Handle this diagnostic, reporting it to the user or - /// capturing it to a log as needed. - virtual void HandleDiagnostic(Diagnostic::Level DiagLevel, - const DiagnosticInfo &Info); - - /// \brief Emit a diagnostic via the adapted diagnostic client. - void Diag(FullSourceLoc Loc, unsigned DiagID); -}; - -} - -#endif // LLVM_CLANG_FRONTEND_FIX_IT_REWRITER_H diff --git a/include/clang/Frontend/FrontendActions.h b/include/clang/Frontend/FrontendActions.h index 2e22435422..26262cfa95 100644 --- a/include/clang/Frontend/FrontendActions.h +++ b/include/clang/Frontend/FrontendActions.h @@ -15,8 +15,6 @@ #include <vector> namespace clang { -class FixItRewriter; -class FixItPathRewriter; //===----------------------------------------------------------------------===// // Custom Consumer Actions @@ -38,12 +36,6 @@ public: // AST Consumer Actions //===----------------------------------------------------------------------===// -class AnalysisAction : public ASTFrontendAction { -protected: - virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, - llvm::StringRef InFile); -}; - class ASTPrintAction : public ASTFrontendAction { protected: virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, @@ -74,26 +66,6 @@ protected: llvm::StringRef InFile); }; -class FixItAction : public ASTFrontendAction { -protected: - llvm::OwningPtr<FixItRewriter> Rewriter; - llvm::OwningPtr<FixItPathRewriter> PathRewriter; - - virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, - llvm::StringRef InFile); - - virtual bool BeginSourceFileAction(CompilerInstance &CI, - llvm::StringRef Filename); - - virtual void EndSourceFileAction(); - - virtual bool hasASTFileSupport() const { return false; } - -public: - FixItAction(); - ~FixItAction(); -}; - class GeneratePCHAction : public ASTFrontendAction { protected: virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, @@ -104,24 +76,12 @@ protected: virtual bool hasASTFileSupport() const { return false; } }; -class HTMLPrintAction : public ASTFrontendAction { -protected: - virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, - llvm::StringRef InFile); -}; - class InheritanceViewAction : public ASTFrontendAction { protected: virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, llvm::StringRef InFile); }; -class RewriteObjCAction : public ASTFrontendAction { -protected: - virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, - llvm::StringRef InFile); -}; - class SyntaxOnlyAction : public ASTFrontendAction { protected: virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, @@ -215,16 +175,6 @@ protected: virtual bool hasPCHSupport() const { return true; } }; -class RewriteMacrosAction : public PreprocessorFrontendAction { -protected: - void ExecuteAction(); -}; - -class RewriteTestAction : public PreprocessorFrontendAction { -protected: - void ExecuteAction(); -}; - } // end namespace clang #endif diff --git a/include/clang/Frontend/PathDiagnosticClients.h b/include/clang/Frontend/PathDiagnosticClients.h deleted file mode 100644 index f8d2eebeb6..0000000000 --- a/include/clang/Frontend/PathDiagnosticClients.h +++ /dev/null @@ -1,32 +0,0 @@ -//===--- PathDiagnosticClients.h - Path Diagnostic Clients ------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file defines the interface to create different path diagostic clients. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_CLANG_FRONTEND_PATH_DIAGNOSTIC_CLIENTS_H -#define LLVM_CLANG_FRONTEND_PATH_DIAGNOSTIC_CLiENTS_H - -#include <string> - -namespace clang { - -class PathDiagnosticClient; -class Preprocessor; - -PathDiagnosticClient* -CreateHTMLDiagnosticClient(const std::string& prefix, const Preprocessor &PP); - -PathDiagnosticClient* -CreatePlistDiagnosticClient(const std::string& prefix, const Preprocessor &PP, - PathDiagnosticClient *SubPD = 0); - -} // end clang namespace -#endif diff --git a/include/clang/Frontend/Utils.h b/include/clang/Frontend/Utils.h index c1d483164a..f37cc01a27 100644 --- a/include/clang/Frontend/Utils.h +++ b/include/clang/Frontend/Utils.h @@ -65,12 +65,6 @@ void ProcessWarningOptions(Diagnostic &Diags, const DiagnosticOptions &Opts); void DoPrintPreprocessedInput(Preprocessor &PP, llvm::raw_ostream* OS, const PreprocessorOutputOptions &Opts); -/// RewriteMacrosInInput - Implement -rewrite-macros mode. -void RewriteMacrosInInput(Preprocessor &PP, llvm::raw_ostream* OS); - -/// RewriteMacrosInInput - A simple test for the TokenRewriter class. -void DoRewriteTest(Preprocessor &PP, llvm::raw_ostream* OS); - /// CreatePrintParserActionsAction - Return the actions implementation that /// implements the -parse-print-callbacks option. MinimalAction *CreatePrintParserActionsAction(Preprocessor &PP, |