]> granicus.if.org Git - clang/commitdiff
Break Frontend's dependency on Rewrite, Checker and CodeGen in shared library configu...
authorDaniel Dunbar <daniel@zuster.org>
Tue, 15 Jun 2010 17:48:49 +0000 (17:48 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Tue, 15 Jun 2010 17:48:49 +0000 (17:48 +0000)
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

34 files changed:
examples/clang-interpreter/main.cpp
include/clang/Checker/AnalysisConsumer.h [new file with mode: 0644]
include/clang/Checker/FrontendActions.h [new file with mode: 0644]
include/clang/Checker/PathDiagnosticClients.h [moved from include/clang/Frontend/PathDiagnosticClients.h with 89% similarity]
include/clang/CodeGen/BackendUtil.h [moved from include/clang/Frontend/BackendUtil.h with 92% similarity]
include/clang/CodeGen/CodeGenAction.h [moved from include/clang/Frontend/CodeGenAction.h with 94% similarity]
include/clang/Frontend/ASTConsumers.h
include/clang/Frontend/AnalyzerOptions.h [moved from include/clang/Frontend/AnalysisConsumer.h with 80% similarity]
include/clang/Frontend/CompilerInvocation.h
include/clang/Frontend/FrontendActions.h
include/clang/Frontend/Utils.h
include/clang/Rewrite/ASTConsumers.h [new file with mode: 0644]
include/clang/Rewrite/FixItRewriter.h [moved from include/clang/Frontend/FixItRewriter.h with 95% similarity]
include/clang/Rewrite/FrontendActions.h [new file with mode: 0644]
include/clang/Rewrite/Rewriters.h [new file with mode: 0644]
lib/Checker/AnalysisConsumer.cpp [moved from lib/Frontend/AnalysisConsumer.cpp with 99% similarity]
lib/Checker/CMakeLists.txt
lib/Checker/FrontendActions.cpp [new file with mode: 0644]
lib/Checker/HTMLDiagnostics.cpp [moved from lib/Frontend/HTMLDiagnostics.cpp with 99% similarity]
lib/Checker/PlistDiagnostics.cpp [moved from lib/Frontend/PlistDiagnostics.cpp with 99% similarity]
lib/CodeGen/BackendUtil.cpp [moved from lib/Frontend/BackendUtil.cpp with 99% similarity]
lib/CodeGen/CMakeLists.txt
lib/CodeGen/CodeGenAction.cpp [moved from lib/Frontend/CodeGenAction.cpp with 98% similarity]
lib/Frontend/ASTConsumers.cpp
lib/Frontend/CMakeLists.txt
lib/Frontend/FrontendActions.cpp
lib/Rewrite/CMakeLists.txt
lib/Rewrite/FixItRewriter.cpp [moved from lib/Frontend/FixItRewriter.cpp with 99% similarity]
lib/Rewrite/FrontendActions.cpp [new file with mode: 0644]
lib/Rewrite/HTMLPrint.cpp [moved from lib/Frontend/HTMLPrint.cpp with 98% similarity]
lib/Rewrite/RewriteMacros.cpp [moved from lib/Frontend/RewriteMacros.cpp with 99% similarity]
lib/Rewrite/RewriteObjC.cpp [moved from lib/Frontend/RewriteObjC.cpp with 99% similarity]
lib/Rewrite/RewriteTest.cpp [moved from lib/Frontend/RewriteTest.cpp with 97% similarity]
tools/driver/cc1_main.cpp

index 86239548d3403e543c72e98e9c35f69f7c3c3f1e..ec4e8619829fc11edb2070855dc55e293c2fb7cd 100644 (file)
@@ -7,10 +7,10 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "clang/CodeGen/CodeGenAction.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Driver.h"
 #include "clang/Driver/Tool.h"
-#include "clang/Frontend/CodeGenAction.h"
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/DiagnosticOptions.h"
diff --git a/include/clang/Checker/AnalysisConsumer.h b/include/clang/Checker/AnalysisConsumer.h
new file mode 100644 (file)
index 0000000..c236766
--- /dev/null
@@ -0,0 +1,35 @@
+//===--- AnalysisConsumer.h - Front-end Analysis Engine Hooks ---*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This header contains the functions necessary for a front-end to run various
+// analyses.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_CHECKER_ANALYSISCONSUMER_H
+#define LLVM_CLANG_CHECKER_ANALYSISCONSUMER_H
+
+#include <string>
+
+namespace clang {
+
+class AnalyzerOptions;
+class ASTConsumer;
+class Preprocessor;
+
+/// 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/Checker/FrontendActions.h b/include/clang/Checker/FrontendActions.h
new file mode 100644 (file)
index 0000000..1c0bbb7
--- /dev/null
@@ -0,0 +1,29 @@
+//===-- FrontendActions.h - Useful Frontend Actions -------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_CHECKER_FRONTENDACTIONS_H
+#define LLVM_CLANG_CHECKER_FRONTENDACTIONS_H
+
+#include "clang/Frontend/FrontendAction.h"
+
+namespace clang {
+
+//===----------------------------------------------------------------------===//
+// AST Consumer Actions
+//===----------------------------------------------------------------------===//
+
+class AnalysisAction : public ASTFrontendAction {
+protected:
+  virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
+                                         llvm::StringRef InFile);
+};
+
+}  // end namespace clang
+
+#endif
similarity index 89%
rename from include/clang/Frontend/PathDiagnosticClients.h
rename to include/clang/Checker/PathDiagnosticClients.h
index f8d2eebeb6873c8db3166368d8983896cc056a22..d3aa3b2114334a0340d412871258538f307c17bb 100644 (file)
@@ -11,8 +11,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_CLANG_FRONTEND_PATH_DIAGNOSTIC_CLIENTS_H
-#define LLVM_CLANG_FRONTEND_PATH_DIAGNOSTIC_CLiENTS_H
+#ifndef LLVM_CLANG_CHECKER_PATH_DIAGNOSTIC_CLIENTS_H
+#define LLVM_CLANG_CHECKER_PATH_DIAGNOSTIC_CLiENTS_H
 
 #include <string>
 
similarity index 92%
rename from include/clang/Frontend/BackendUtil.h
rename to include/clang/CodeGen/BackendUtil.h
index 39c743c634446d3727a05b8f13afd1e350dc48df..abcef8130dbc0a99a5028aed76430219ecb34f26 100644 (file)
@@ -7,6 +7,9 @@
 //
 //===----------------------------------------------------------------------===//
 
+#ifndef LLVM_CLANG_CODEGEN_BACKEND_UTIL_H
+#define LLVM_CLANG_CODEGEN_BACKEND_UTIL_H
+
 namespace llvm {
   class Module;
   class raw_ostream;
@@ -30,3 +33,5 @@ namespace clang {
                          const TargetOptions &TOpts, llvm::Module *M,
                          BackendAction Action, llvm::raw_ostream *OS);
 }
+
+#endif
similarity index 94%
rename from include/clang/Frontend/CodeGenAction.h
rename to include/clang/CodeGen/CodeGenAction.h
index e05176a6892678c49c7c26993ce5c53093e87f83..cecfcda461bb973d67cec9f49e97c85c3a05167d 100644 (file)
@@ -7,6 +7,9 @@
 //
 //===----------------------------------------------------------------------===//
 
+#ifndef LLVM_CLANG_CODEGEN_CODE_GEN_ACTION_H
+#define LLVM_CLANG_CODEGEN_CODE_GEN_ACTION_H
+
 #include "clang/Frontend/FrontendAction.h"
 #include "llvm/ADT/OwningPtr.h"
 
@@ -72,3 +75,5 @@ public:
 };
 
 }
+
+#endif
index 9163a208de2eddbc94b026874798bc7b548f754c..e42b1f2cd9cd1387c3a080d5303f750506bda2d4 100644 (file)
@@ -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.
similarity index 80%
rename from include/clang/Frontend/AnalysisConsumer.h
rename to include/clang/Frontend/AnalyzerOptions.h
index 2cbdf368a893861f68cc1fcf8f5185e75f360dac..d8fcdeb9b048a4405166749856545c54d730ac8e 100644 (file)
@@ -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
index f5a9053ceb6494f727dc594d00d89877d16e1b5e..05e1aa09cfeece8ae3ad583361be5e4ea2a2131e 100644 (file)
@@ -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"
index 2e224354225326740d896752619e0fa9cc6703d4..26262cfa95222ac799f63fbcf48fb414a4e4f62c 100644 (file)
@@ -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
index c1d483164a21bb731fd675be74bbe0e2de02dfbd..f37cc01a2753cad89ae29dc7bea69f797446cf32 100644 (file)
@@ -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,
diff --git a/include/clang/Rewrite/ASTConsumers.h b/include/clang/Rewrite/ASTConsumers.h
new file mode 100644 (file)
index 0000000..5fb107c
--- /dev/null
@@ -0,0 +1,45 @@
+//===--- ASTConsumers.h - ASTConsumer implementations -----------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// AST Consumers.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef REWRITE_ASTCONSUMERS_H
+#define REWRITE_ASTCONSUMERS_H
+
+#include <string>
+
+namespace llvm {
+  class raw_ostream;
+}
+namespace clang {
+
+class ASTConsumer;
+class Diagnostic;
+class LangOptions;
+class Preprocessor;
+
+// 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);
+
+} // end clang namespace
+
+#endif
similarity index 95%
rename from include/clang/Frontend/FixItRewriter.h
rename to include/clang/Rewrite/FixItRewriter.h
index b432d747de978084038538ebbbd2207f1f0ed54b..4ebcef0fff61291fdf1621c1219163327e18ca4c 100644 (file)
@@ -12,8 +12,8 @@
 // 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
+#ifndef LLVM_CLANG_REWRITE_FIX_IT_REWRITER_H
+#define LLVM_CLANG_REWRITE_FIX_IT_REWRITER_H
 
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/SourceLocation.h"
@@ -101,4 +101,4 @@ public:
 
 }
 
-#endif // LLVM_CLANG_FRONTEND_FIX_IT_REWRITER_H
+#endif // LLVM_CLANG_REWRITE_FIX_IT_REWRITER_H
diff --git a/include/clang/Rewrite/FrontendActions.h b/include/clang/Rewrite/FrontendActions.h
new file mode 100644 (file)
index 0000000..2ff8d0a
--- /dev/null
@@ -0,0 +1,69 @@
+//===-- FrontendActions.h - Useful Frontend Actions -------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_REWRITE_FRONTENDACTIONS_H
+#define LLVM_CLANG_REWRITE_FRONTENDACTIONS_H
+
+#include "clang/Frontend/FrontendAction.h"
+#include <string>
+#include <vector>
+
+namespace clang {
+class FixItRewriter;
+class FixItPathRewriter;
+
+//===----------------------------------------------------------------------===//
+// AST Consumer Actions
+//===----------------------------------------------------------------------===//
+
+class HTMLPrintAction : public ASTFrontendAction {
+protected:
+  virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
+                                         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 RewriteObjCAction : public ASTFrontendAction {
+protected:
+  virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
+                                         llvm::StringRef InFile);
+};
+
+class RewriteMacrosAction : public PreprocessorFrontendAction {
+protected:
+  void ExecuteAction();
+};
+
+class RewriteTestAction : public PreprocessorFrontendAction {
+protected:
+  void ExecuteAction();
+};
+
+}  // end namespace clang
+
+#endif
diff --git a/include/clang/Rewrite/Rewriters.h b/include/clang/Rewrite/Rewriters.h
new file mode 100644 (file)
index 0000000..669cf8c
--- /dev/null
@@ -0,0 +1,31 @@
+//===--- Rewriters.h - Rewriter implementations     -------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+//  This header contains miscellaneous utilities for various front-end actions.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_REWRITE_REWRITERS_H
+#define LLVM_CLANG_REWRITE_REWRITERS_H
+
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/raw_ostream.h"
+
+namespace clang {
+class Preprocessor;
+
+/// RewriteMacrosInInput - Implement -rewrite-macros mode.
+void RewriteMacrosInInput(Preprocessor &PP, llvm::raw_ostream* OS);
+
+/// DoRewriteTest - A simple test for the TokenRewriter class.
+void DoRewriteTest(Preprocessor &PP, llvm::raw_ostream* OS);
+
+}  // end namespace clang
+
+#endif
similarity index 99%
rename from lib/Frontend/AnalysisConsumer.cpp
rename to lib/Checker/AnalysisConsumer.cpp
index 05890080339791983b51c0e8b23f0978e116e134..4cdfd311261b33d49089e027f0076ad3d23d28e8 100644 (file)
@@ -11,7 +11,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "clang/Frontend/AnalysisConsumer.h"
+#include "clang/Checker/AnalysisConsumer.h"
 #include "clang/AST/ASTConsumer.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/Checker/BugReporter/BugReporter.h"
 #include "clang/Checker/PathSensitive/GRExprEngine.h"
 #include "clang/Checker/PathSensitive/GRTransferFuncs.h"
+#include "clang/Checker/PathDiagnosticClients.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/SourceManager.h"
-#include "clang/Frontend/PathDiagnosticClients.h"
+#include "clang/Frontend/AnalyzerOptions.h"
 #include "clang/Lex/Preprocessor.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/System/Path.h"
index e912024967781eb98ad038cea9a2fbda5791b33d..620dab2e55c1e47aab6e6b67573ee6810e8fffa6 100644 (file)
@@ -3,6 +3,7 @@ set(LLVM_NO_RTTI 1)
 add_clang_library(clangChecker
   AdjustedReturnValueChecker.cpp
   AggExprVisitor.cpp
+  AnalysisConsumer.cpp
   ArrayBoundChecker.cpp
   AttrNonNullChecker.cpp
   BasicConstraintManager.cpp
@@ -30,12 +31,14 @@ add_clang_library(clangChecker
   ExplodedGraph.cpp
   FixedAddressChecker.cpp
   FlatStore.cpp
+  FrontendActions.cpp
   GRBlockCounter.cpp
   GRCoreEngine.cpp
   GRCXXExprEngine.cpp
   GRExprEngine.cpp
   GRExprEngineExperimentalChecks.cpp
   GRState.cpp
+  HTMLDiagnostics.cpp
   LLVMConventionsChecker.cpp
   MacOSXAPIChecker.cpp
   MallocChecker.cpp
@@ -47,6 +50,7 @@ add_clang_library(clangChecker
   ObjCUnusedIVarsChecker.cpp
   OSAtomicChecker.cpp
   PathDiagnostic.cpp
+  PlistDiagnostics.cpp
   PointerArithChecker.cpp
   PointerSubChecker.cpp
   PthreadLockChecker.cpp
diff --git a/lib/Checker/FrontendActions.cpp b/lib/Checker/FrontendActions.cpp
new file mode 100644 (file)
index 0000000..d9a54a0
--- /dev/null
@@ -0,0 +1,21 @@
+//===--- FrontendActions.cpp ----------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "clang/Checker/FrontendActions.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Checker/AnalysisConsumer.h"
+using namespace clang;
+
+ASTConsumer *AnalysisAction::CreateASTConsumer(CompilerInstance &CI,
+                                               llvm::StringRef InFile) {
+  return CreateAnalysisConsumer(CI.getPreprocessor(),
+                                CI.getFrontendOpts().OutputFile,
+                                CI.getAnalyzerOpts());
+}
+
similarity index 99%
rename from lib/Frontend/HTMLDiagnostics.cpp
rename to lib/Checker/HTMLDiagnostics.cpp
index 022a34d0bd4f4f2d24a896fcbb2180508c88fcff..401f177ce3e949bcf796337f85a88058091399cc 100644 (file)
@@ -11,7 +11,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "clang/Frontend/PathDiagnosticClients.h"
+#include "clang/Checker/PathDiagnosticClients.h"
 #include "clang/Checker/BugReporter/PathDiagnostic.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Decl.h"
similarity index 99%
rename from lib/Frontend/PlistDiagnostics.cpp
rename to lib/Checker/PlistDiagnostics.cpp
index 5706a07e5a0f2f7765f015f51b7f2a6000b3960f..13accbbff8c7ff24b274e45193d5f4152863800a 100644 (file)
@@ -11,7 +11,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "clang/Frontend/PathDiagnosticClients.h"
+#include "clang/Checker/PathDiagnosticClients.h"
 #include "clang/Checker/BugReporter/PathDiagnostic.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/FileManager.h"
similarity index 99%
rename from lib/Frontend/BackendUtil.cpp
rename to lib/CodeGen/BackendUtil.cpp
index 2ceb831a5ebe6ec77340b7bb87738282e738dbe1..766b239c4c0b30fdd9a31e1740b4d34dc90b816a 100644 (file)
@@ -7,7 +7,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "clang/Frontend/BackendUtil.h"
+#include "clang/CodeGen/BackendUtil.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/TargetOptions.h"
 #include "clang/CodeGen/CodeGenOptions.h"
index bb2160e2c4023581d52ef19460062190df0e53ff..be2f3dc4cc004d73678cd0006e85e40715092501 100644 (file)
@@ -1,6 +1,7 @@
 set(LLVM_NO_RTTI 1)
 
 add_clang_library(clangCodeGen
+  BackendUtil.cpp
   CGBlocks.cpp
   CGBuiltin.cpp
   CGCall.cpp
@@ -25,6 +26,7 @@ add_clang_library(clangCodeGen
   CGTemporaries.cpp
   CGVTables.cpp
   CGVTT.cpp
+  CodeGenAction.cpp
   CodeGenFunction.cpp
   CodeGenModule.cpp
   CodeGenTypes.cpp
similarity index 98%
rename from lib/Frontend/CodeGenAction.cpp
rename to lib/CodeGen/CodeGenAction.cpp
index dce9f3d21686bb7137ecfdc3bcc03aa5b58e576a..51c55a1a8390061efa86e1650046d41871041702 100644 (file)
@@ -7,15 +7,14 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "clang/Frontend/CodeGenAction.h"
+#include "clang/CodeGen/CodeGenAction.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/TargetInfo.h"
 #include "clang/AST/ASTConsumer.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclGroup.h"
+#include "clang/CodeGen/BackendUtil.h"
 #include "clang/CodeGen/ModuleBuilder.h"
-#include "clang/Frontend/ASTConsumers.h"
-#include "clang/Frontend/BackendUtil.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/FrontendDiagnostic.h"
 #include "llvm/LLVMContext.h"
index 7b8ebf92032e10e25c22a093a54fec8bba329e10..bf2b3f2319b8906582a447ae0a5c6384e246a8b3 100644 (file)
@@ -13,7 +13,6 @@
 
 #include "clang/Frontend/ASTConsumers.h"
 #include "clang/Frontend/DocumentXML.h"
-#include "clang/Frontend/PathDiagnosticClients.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/FileManager.h"
@@ -22,7 +21,6 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/RecordLayout.h"
 #include "clang/AST/PrettyPrinter.h"
-#include "clang/CodeGen/ModuleBuilder.h"
 #include "llvm/Module.h"
 #include "llvm/Support/Timer.h"
 #include "llvm/Support/raw_ostream.h"
index e445acd90dd2723f01a26049f561494ee42a8d9c..2ccdc5e17bb06c760a4f6aa3d0cc429ec9e71c7c 100644 (file)
@@ -4,24 +4,18 @@ add_clang_library(clangFrontend
   ASTConsumers.cpp
   ASTMerge.cpp
   ASTUnit.cpp
-  AnalysisConsumer.cpp
-  BackendUtil.cpp
   BoostConAction.cpp
   CacheTokens.cpp
-  CodeGenAction.cpp
   CompilerInstance.cpp
   CompilerInvocation.cpp
   DeclXML.cpp
   DependencyFile.cpp
   DiagChecker.cpp
   DocumentXML.cpp
-  FixItRewriter.cpp
   FrontendAction.cpp
   FrontendActions.cpp
   FrontendOptions.cpp
   GeneratePCH.cpp
-  HTMLDiagnostics.cpp
-  HTMLPrint.cpp
   InitHeaderSearch.cpp
   InitPreprocessor.cpp
   LangStandards.cpp
@@ -31,12 +25,8 @@ add_clang_library(clangFrontend
   PCHWriter.cpp
   PCHWriterDecl.cpp
   PCHWriterStmt.cpp
-  PlistDiagnostics.cpp
   PrintParserCallbacks.cpp
   PrintPreprocessedOutput.cpp
-  RewriteMacros.cpp
-  RewriteObjC.cpp
-  RewriteTest.cpp
   StmtXML.cpp
   TextDiagnosticBuffer.cpp
   TextDiagnosticPrinter.cpp
index 421d69d24308159469e36490a4edd959fd6fa4b9..f0b86a9214af7e209538365d72248a013098dd48 100644 (file)
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Parse/Parser.h"
 #include "clang/Basic/FileManager.h"
-#include "clang/Frontend/AnalysisConsumer.h"
 #include "clang/Frontend/ASTConsumers.h"
 #include "clang/Frontend/ASTUnit.h"
 #include "clang/Frontend/CompilerInstance.h"
-#include "clang/Frontend/FixItRewriter.h"
 #include "clang/Frontend/FrontendDiagnostic.h"
 #include "clang/Frontend/Utils.h"
 #include "llvm/ADT/OwningPtr.h"
@@ -40,13 +38,6 @@ void InitOnlyAction::ExecuteAction() {
 // AST Consumer Actions
 //===----------------------------------------------------------------------===//
 
-ASTConsumer *AnalysisAction::CreateASTConsumer(CompilerInstance &CI,
-                                               llvm::StringRef InFile) {
-  return CreateAnalysisConsumer(CI.getPreprocessor(),
-                                CI.getFrontendOpts().OutputFile,
-                                CI.getAnalyzerOpts());
-}
-
 ASTConsumer *ASTPrintAction::CreateASTConsumer(CompilerInstance &CI,
                                                llvm::StringRef InFile) {
   if (llvm::raw_ostream *OS = CI.createDefaultOutputFile(false, InFile))
@@ -95,69 +86,11 @@ ASTConsumer *GeneratePCHAction::CreateASTConsumer(CompilerInstance &CI,
   return CreatePCHGenerator(CI.getPreprocessor(), OS);
 }
 
-ASTConsumer *HTMLPrintAction::CreateASTConsumer(CompilerInstance &CI,
-                                                llvm::StringRef InFile) {
-  if (llvm::raw_ostream *OS = CI.createDefaultOutputFile(false, InFile))
-    return CreateHTMLPrinter(OS, CI.getPreprocessor());
-  return 0;
-}
-
 ASTConsumer *InheritanceViewAction::CreateASTConsumer(CompilerInstance &CI,
                                                       llvm::StringRef InFile) {
   return CreateInheritanceViewer(CI.getFrontendOpts().ViewClassInheritance);
 }
 
-FixItAction::FixItAction() {}
-FixItAction::~FixItAction() {}
-
-ASTConsumer *FixItAction::CreateASTConsumer(CompilerInstance &CI,
-                                            llvm::StringRef InFile) {
-  return new ASTConsumer();
-}
-
-class FixItActionSuffixInserter : public FixItPathRewriter {
-  std::string NewSuffix;
-
-public:
-  explicit FixItActionSuffixInserter(std::string NewSuffix)
-    : NewSuffix(NewSuffix) {}
-
-  std::string RewriteFilename(const std::string &Filename) {
-    llvm::sys::Path Path(Filename);
-    std::string Suffix = Path.getSuffix();
-    Path.eraseSuffix();
-    Path.appendSuffix(NewSuffix + "." + Suffix);
-    return Path.c_str();
-  }
-};
-
-bool FixItAction::BeginSourceFileAction(CompilerInstance &CI,
-                                        llvm::StringRef Filename) {
-  const FrontendOptions &FEOpts = getCompilerInstance().getFrontendOpts();
-  if (!FEOpts.FixItSuffix.empty()) {
-    PathRewriter.reset(new FixItActionSuffixInserter(FEOpts.FixItSuffix));
-  } else {
-    PathRewriter.reset();
-  }
-  Rewriter.reset(new FixItRewriter(CI.getDiagnostics(), CI.getSourceManager(),
-                                   CI.getLangOpts(), PathRewriter.get()));
-  return true;
-}
-
-void FixItAction::EndSourceFileAction() {
-  // Otherwise rewrite all files.
-  Rewriter->WriteFixedFiles();
-}
-
-ASTConsumer *RewriteObjCAction::CreateASTConsumer(CompilerInstance &CI,
-                                                  llvm::StringRef InFile) {
-  if (llvm::raw_ostream *OS = CI.createDefaultOutputFile(false, InFile, "cpp"))
-    return CreateObjCRewriter(InFile, OS,
-                              CI.getDiagnostics(), CI.getLangOpts(),
-                              CI.getDiagnosticOpts().NoRewriteMacros);
-  return 0;
-}
-
 ASTConsumer *SyntaxOnlyAction::CreateASTConsumer(CompilerInstance &CI,
                                                  llvm::StringRef InFile) {
   return new ASTConsumer();
@@ -258,19 +191,3 @@ void PrintPreprocessedAction::ExecuteAction() {
   DoPrintPreprocessedInput(CI.getPreprocessor(), OS,
                            CI.getPreprocessorOutputOpts());
 }
-
-void RewriteMacrosAction::ExecuteAction() {
-  CompilerInstance &CI = getCompilerInstance();
-  llvm::raw_ostream *OS = CI.createDefaultOutputFile(true, getCurrentFile());
-  if (!OS) return;
-
-  RewriteMacrosInInput(CI.getPreprocessor(), OS);
-}
-
-void RewriteTestAction::ExecuteAction() {
-  CompilerInstance &CI = getCompilerInstance();
-  llvm::raw_ostream *OS = CI.createDefaultOutputFile(false, getCurrentFile());
-  if (!OS) return;
-
-  DoRewriteTest(CI.getPreprocessor(), OS);
-}
index ce9e1ed424d78d993f963c07322e457aa326b831..ce728afea850f8ccb2ef6ae2852eda669248329f 100644 (file)
@@ -2,8 +2,14 @@ set(LLVM_NO_RTTI 1)
 
 add_clang_library(clangRewrite
   DeltaTree.cpp
+  FixItRewriter.cpp
+  FrontendActions.cpp
+  HTMLPrint.cpp
   HTMLRewrite.cpp
+  RewriteMacros.cpp
+  RewriteObjC.cpp
   RewriteRope.cpp
+  RewriteTest.cpp
   Rewriter.cpp
   TokenRewriter.cpp
   )
similarity index 99%
rename from lib/Frontend/FixItRewriter.cpp
rename to lib/Rewrite/FixItRewriter.cpp
index 7c9a566b6f7fe0e3d21b2a931fe3f43bac750258..29ac7e380bfe081d5e05ba77fb5d5caf611bdcf5 100644 (file)
@@ -13,7 +13,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "clang/Frontend/FixItRewriter.h"
+#include "clang/Rewrite/FixItRewriter.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
diff --git a/lib/Rewrite/FrontendActions.cpp b/lib/Rewrite/FrontendActions.cpp
new file mode 100644 (file)
index 0000000..6da3b4b
--- /dev/null
@@ -0,0 +1,106 @@
+//===--- FrontendActions.cpp ----------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "clang/Rewrite/FrontendActions.h"
+#include "clang/AST/ASTConsumer.h"
+#include "clang/Lex/Preprocessor.h"
+#include "clang/Parse/Parser.h"
+#include "clang/Basic/FileManager.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/FrontendDiagnostic.h"
+#include "clang/Frontend/Utils.h"
+#include "clang/Rewrite/ASTConsumers.h"
+#include "clang/Rewrite/FixItRewriter.h"
+#include "clang/Rewrite/Rewriters.h"
+#include "llvm/ADT/OwningPtr.h"
+#include "llvm/Support/raw_ostream.h"
+#include "llvm/System/Path.h"
+using namespace clang;
+
+//===----------------------------------------------------------------------===//
+// AST Consumer Actions
+//===----------------------------------------------------------------------===//
+
+ASTConsumer *HTMLPrintAction::CreateASTConsumer(CompilerInstance &CI,
+                                                llvm::StringRef InFile) {
+  if (llvm::raw_ostream *OS = CI.createDefaultOutputFile(false, InFile))
+    return CreateHTMLPrinter(OS, CI.getPreprocessor());
+  return 0;
+}
+
+FixItAction::FixItAction() {}
+FixItAction::~FixItAction() {}
+
+ASTConsumer *FixItAction::CreateASTConsumer(CompilerInstance &CI,
+                                            llvm::StringRef InFile) {
+  return new ASTConsumer();
+}
+
+class FixItActionSuffixInserter : public FixItPathRewriter {
+  std::string NewSuffix;
+
+public:
+  explicit FixItActionSuffixInserter(std::string NewSuffix)
+    : NewSuffix(NewSuffix) {}
+
+  std::string RewriteFilename(const std::string &Filename) {
+    llvm::sys::Path Path(Filename);
+    std::string Suffix = Path.getSuffix();
+    Path.eraseSuffix();
+    Path.appendSuffix(NewSuffix + "." + Suffix);
+    return Path.c_str();
+  }
+};
+
+bool FixItAction::BeginSourceFileAction(CompilerInstance &CI,
+                                        llvm::StringRef Filename) {
+  const FrontendOptions &FEOpts = getCompilerInstance().getFrontendOpts();
+  if (!FEOpts.FixItSuffix.empty()) {
+    PathRewriter.reset(new FixItActionSuffixInserter(FEOpts.FixItSuffix));
+  } else {
+    PathRewriter.reset();
+  }
+  Rewriter.reset(new FixItRewriter(CI.getDiagnostics(), CI.getSourceManager(),
+                                   CI.getLangOpts(), PathRewriter.get()));
+  return true;
+}
+
+void FixItAction::EndSourceFileAction() {
+  // Otherwise rewrite all files.
+  Rewriter->WriteFixedFiles();
+}
+
+//===----------------------------------------------------------------------===//
+// Preprocessor Actions
+//===----------------------------------------------------------------------===//
+
+ASTConsumer *RewriteObjCAction::CreateASTConsumer(CompilerInstance &CI,
+                                                  llvm::StringRef InFile) {
+  if (llvm::raw_ostream *OS = CI.createDefaultOutputFile(false, InFile, "cpp"))
+    return CreateObjCRewriter(InFile, OS,
+                              CI.getDiagnostics(), CI.getLangOpts(),
+                              CI.getDiagnosticOpts().NoRewriteMacros);
+  return 0;
+}
+
+void RewriteMacrosAction::ExecuteAction() {
+  CompilerInstance &CI = getCompilerInstance();
+  llvm::raw_ostream *OS = CI.createDefaultOutputFile(true, getCurrentFile());
+  if (!OS) return;
+
+  RewriteMacrosInInput(CI.getPreprocessor(), OS);
+}
+
+void RewriteTestAction::ExecuteAction() {
+  CompilerInstance &CI = getCompilerInstance();
+  llvm::raw_ostream *OS = CI.createDefaultOutputFile(false, getCurrentFile());
+  if (!OS) return;
+
+  DoRewriteTest(CI.getPreprocessor(), OS);
+}
similarity index 98%
rename from lib/Frontend/HTMLPrint.cpp
rename to lib/Rewrite/HTMLPrint.cpp
index 9ea8cb3feee6c01a7269658d531803072fbff219..f66bfcb2dfc4e374dc70a031b71848af56afbe58 100644 (file)
@@ -11,7 +11,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "clang/Frontend/ASTConsumers.h"
+#include "clang/Rewrite/ASTConsumers.h"
 #include "clang/AST/ASTConsumer.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Decl.h"
similarity index 99%
rename from lib/Frontend/RewriteMacros.cpp
rename to lib/Rewrite/RewriteMacros.cpp
index 954e8e23cac79728c1a0805767df235e774d75b3..910fa6ba4c2da9a7a5fdaab5fa49bba10d94ddb2 100644 (file)
@@ -12,7 +12,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "clang/Frontend/Utils.h"
+#include "clang/Rewrite/Rewriters.h"
 #include "clang/Rewrite/Rewriter.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Basic/SourceManager.h"
similarity index 99%
rename from lib/Frontend/RewriteObjC.cpp
rename to lib/Rewrite/RewriteObjC.cpp
index 5dd7bdfcbfa109cc35f565dbf2da87788e3f71d1..65ebf227e86a8803dae449c63a5dc8eeb1d2d717 100644 (file)
@@ -11,7 +11,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "clang/Frontend/ASTConsumers.h"
+#include "clang/Rewrite/ASTConsumers.h"
 #include "clang/Rewrite/Rewriter.h"
 #include "clang/AST/AST.h"
 #include "clang/AST/ASTConsumer.h"
similarity index 97%
rename from lib/Frontend/RewriteTest.cpp
rename to lib/Rewrite/RewriteTest.cpp
index 0414678fb6181a0ecf6b3b08d733bc88a3dddb87..36207000c905dda58595e304dc45b61de1b63726 100644 (file)
@@ -11,7 +11,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "clang/Frontend/Utils.h"
+#include "clang/Rewrite/Rewriters.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Rewrite/TokenRewriter.h"
 #include "llvm/Support/raw_ostream.h"
index ac19e9393c5b1c28bb84744fdf02c256da8d2bad..c4c1bd9e8bf624bed4457c5b21bf2b0714d52ebf 100644 (file)
 //===----------------------------------------------------------------------===//
 
 #include "clang/Basic/Diagnostic.h"
+#include "clang/Checker/FrontendActions.h"
+#include "clang/CodeGen/CodeGenAction.h"
 #include "clang/Driver/Arg.h"
 #include "clang/Driver/ArgList.h"
 #include "clang/Driver/CC1Options.h"
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/OptTable.h"
-#include "clang/Frontend/CodeGenAction.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Frontend/FrontendActions.h"
@@ -27,6 +28,7 @@
 #include "clang/Frontend/FrontendPluginRegistry.h"
 #include "clang/Frontend/TextDiagnosticBuffer.h"
 #include "clang/Frontend/TextDiagnosticPrinter.h"
+#include "clang/Rewrite/FrontendActions.h"
 #include "llvm/LLVMContext.h"
 #include "llvm/ADT/OwningPtr.h"
 #include "llvm/ADT/Statistic.h"