add a libDriver, for now only move the text diangostics stuff from Driver to there

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54383 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Driver/DiagChecker.cpp b/Driver/DiagChecker.cpp
index 643c17e..e11d2f0 100644
--- a/Driver/DiagChecker.cpp
+++ b/Driver/DiagChecker.cpp
@@ -13,7 +13,7 @@
 
 #include "clang.h"
 #include "ASTConsumers.h"
-#include "TextDiagnosticBuffer.h"
+#include "clang/Driver/TextDiagnosticBuffer.h"
 #include "clang/Sema/ParseAST.h"
 #include "clang/AST/ASTConsumer.h"
 #include "clang/Basic/SourceManager.h"
diff --git a/Driver/Makefile b/Driver/Makefile
index 1e6d80b..16a8c63 100644
--- a/Driver/Makefile
+++ b/Driver/Makefile
@@ -4,7 +4,7 @@
 
 TOOLNAME = clang
 USEDLIBS = clangCodeGen.a clangAnalysis.a clangRewrite.a clangSEMA.a \
-           clangAST.a clangParse.a clangLex.a clangBasic.a \
+           clangDriver.a clangAST.a clangParse.a clangLex.a clangBasic.a \
            LLVMCore.a LLVMSupport.a LLVMSystem.a \
            LLVMBitWriter.a LLVMBitReader.a LLVMCodeGen.a LLVMAnalysis.a \
            LLVMTarget.a
diff --git a/Driver/clang.cpp b/Driver/clang.cpp
index 56389df..1aa7651 100644
--- a/Driver/clang.cpp
+++ b/Driver/clang.cpp
@@ -24,9 +24,9 @@
 
 #include "clang.h"
 #include "ASTConsumers.h"
-#include "TextDiagnosticBuffer.h"
-#include "TextDiagnosticPrinter.h"
 #include "HTMLDiagnostics.h"
+#include "clang/Driver/TextDiagnosticBuffer.h"
+#include "clang/Driver/TextDiagnosticPrinter.h"
 #include "clang/Analysis/PathDiagnostic.h"
 #include "clang/AST/TranslationUnit.h"
 #include "clang/CodeGen/ModuleBuilder.h"
@@ -143,6 +143,16 @@
          llvm::cl::desc("Generate HTML to report diagnostics"),
          llvm::cl::value_desc("HTML directory"));
 
+static llvm::cl::opt<bool>
+NoShowColumn("fno-show-column",
+             llvm::cl::desc("Do not include column number on diagnostics"));
+
+static llvm::cl::opt<bool>
+NoCaretDiagnostics("fno-caret-diagnostics",
+                   llvm::cl::desc("Do not include source line and caret with"
+                                  " diagnostics"));
+
+
 //===----------------------------------------------------------------------===//
 // Analyzer Options
 //===----------------------------------------------------------------------===//
@@ -426,7 +436,7 @@
 
 static llvm::cl::opt<bool>
 ObjCEnableGC("fobjc-gc",
-             llvm::cl::desc("Enable Objective-C garbage collection"));             
+             llvm::cl::desc("Enable Objective-C garbage collection"));
 
 void InitializeGCMode(LangOptions &Options) {
   if (ObjCExclusiveGC)
@@ -1392,7 +1402,8 @@
   else { // Use Text diagnostics.
     if (!VerifyDiagnostics) {
       // Print diagnostics to stderr by default.
-      TextDiagClient = new TextDiagnosticPrinter();
+      TextDiagClient = new TextDiagnosticPrinter(!NoShowColumn,
+          !NoCaretDiagnostics);
     } else {
       // When checking diagnostics, just buffer them up.
       TextDiagClient = new TextDiagnosticBuffer();
diff --git a/Driver/TextDiagnosticBuffer.h b/include/clang/Driver/TextDiagnosticBuffer.h
similarity index 97%
rename from Driver/TextDiagnosticBuffer.h
rename to include/clang/Driver/TextDiagnosticBuffer.h
index e0230cf..99df075 100644
--- a/Driver/TextDiagnosticBuffer.h
+++ b/include/clang/Driver/TextDiagnosticBuffer.h
@@ -14,7 +14,7 @@
 #ifndef DRIVER_TEXT_DIAGNOSTIC_BUFFER_H_
 #define DRIVER_TEXT_DIAGNOSTIC_BUFFER_H_
 
-#include "TextDiagnostics.h"
+#include "clang/Driver/TextDiagnostics.h"
 #include <vector>
 
 namespace clang {
diff --git a/Driver/TextDiagnosticPrinter.h b/include/clang/Driver/TextDiagnosticPrinter.h
similarity index 84%
rename from Driver/TextDiagnosticPrinter.h
rename to include/clang/Driver/TextDiagnosticPrinter.h
index 633f29e..f96eb21 100644
--- a/Driver/TextDiagnosticPrinter.h
+++ b/include/clang/Driver/TextDiagnosticPrinter.h
@@ -15,7 +15,7 @@
 #ifndef TEXT_DIAGNOSTIC_PRINTER_H_
 #define TEXT_DIAGNOSTIC_PRINTER_H_
 
-#include "TextDiagnostics.h"
+#include "clang/Driver/TextDiagnostics.h"
 #include "clang/Basic/SourceLocation.h"
 #include "llvm/Support/Streams.h"
 
@@ -26,8 +26,12 @@
   FullSourceLoc LastWarningLoc;
   FullSourceLoc LastLoc;
   llvm::OStream OS;
+  bool ShowColumn;
+  bool CaretDiagnostics;
 public:
-  TextDiagnosticPrinter(llvm::OStream &os = llvm::cerr) : OS(os) {}
+  TextDiagnosticPrinter(bool showColumn = true, bool caretDiagnistics = true,
+      llvm::OStream &os = llvm::cerr)
+    : OS(os), ShowColumn(showColumn), CaretDiagnostics(caretDiagnistics) {}
 
   void PrintIncludeStack(FullSourceLoc Pos);
 
diff --git a/Driver/TextDiagnostics.h b/include/clang/Driver/TextDiagnostics.h
similarity index 100%
rename from Driver/TextDiagnostics.h
rename to include/clang/Driver/TextDiagnostics.h
diff --git a/lib/Driver/Makefile b/lib/Driver/Makefile
new file mode 100644
index 0000000..01902fd
--- /dev/null
+++ b/lib/Driver/Makefile
@@ -0,0 +1,22 @@
+##===- clang/lib/Analysis/Makefile -------------------------*- Makefile -*-===##
+# 
+#                     The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+# 
+##===----------------------------------------------------------------------===##
+#
+# This implements analyses built on top of source-level CFGs. 
+#
+##===----------------------------------------------------------------------===##
+
+LEVEL = ../../../..
+LIBRARYNAME := clangDriver
+BUILD_ARCHIVE = 1
+CXXFLAGS = -fno-rtti
+
+CPPFLAGS += -I$(PROJ_SRC_DIR)/../../include
+
+include $(LEVEL)/Makefile.common
+
diff --git a/Driver/TextDiagnosticBuffer.cpp b/lib/Driver/TextDiagnosticBuffer.cpp
similarity index 97%
rename from Driver/TextDiagnosticBuffer.cpp
rename to lib/Driver/TextDiagnosticBuffer.cpp
index aa6fbe9..35aba58 100644
--- a/Driver/TextDiagnosticBuffer.cpp
+++ b/lib/Driver/TextDiagnosticBuffer.cpp
@@ -11,7 +11,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "TextDiagnosticBuffer.h"
+#include "clang/Driver/TextDiagnosticBuffer.h"
 #include "clang/Basic/SourceManager.h"
 using namespace clang;
 
diff --git a/Driver/TextDiagnosticPrinter.cpp b/lib/Driver/TextDiagnosticPrinter.cpp
similarity index 93%
rename from Driver/TextDiagnosticPrinter.cpp
rename to lib/Driver/TextDiagnosticPrinter.cpp
index 16c7645..5188f4d 100644
--- a/Driver/TextDiagnosticPrinter.cpp
+++ b/lib/Driver/TextDiagnosticPrinter.cpp
@@ -11,24 +11,15 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "TextDiagnosticPrinter.h"
+#include "clang/Driver/TextDiagnosticPrinter.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Lex/HeaderSearch.h"
 #include "clang/Lex/Lexer.h"
-#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include <string>
 using namespace clang;
 
-static llvm::cl::opt<bool>
-NoShowColumn("fno-show-column",
-             llvm::cl::desc("Do not include column number on diagnostics"));
-static llvm::cl::opt<bool>
-NoCaretDiagnostics("fno-caret-diagnostics",
-                   llvm::cl::desc("Do not include source line and caret with"
-                                  " diagnostics"));
-
 void TextDiagnosticPrinter::
 PrintIncludeStack(FullSourceLoc Pos) {
   if (Pos.isInvalid()) return;
@@ -144,7 +135,7 @@
       ++LineEnd;
   
     OS << Buffer->getBufferIdentifier() << ":" << LineNo << ":";
-    if (ColNo && !NoShowColumn) 
+    if (ColNo && ShowColumn) 
       OS << ColNo << ":";
     OS << " ";
   }
@@ -160,7 +151,7 @@
   
   OS << FormatDiagnostic(Diags, Level, ID, Strs, NumStrs) << "\n";
   
-  if (!NoCaretDiagnostics && Pos.isValid() && ((LastLoc != Pos) || Ranges)) {
+  if (CaretDiagnostics && Pos.isValid() && ((LastLoc != Pos) || Ranges)) {
     // Cache the LastLoc, it allows us to omit duplicate source/caret spewage.
     LastLoc = Pos;
     
diff --git a/Driver/TextDiagnostics.cpp b/lib/Driver/TextDiagnostics.cpp
similarity index 97%
rename from Driver/TextDiagnostics.cpp
rename to lib/Driver/TextDiagnostics.cpp
index 7a78e94..ae7b57d 100644
--- a/Driver/TextDiagnostics.cpp
+++ b/lib/Driver/TextDiagnostics.cpp
@@ -11,7 +11,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "TextDiagnostics.h"
+#include "clang/Driver/TextDiagnostics.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Lex/HeaderSearch.h"
diff --git a/lib/Makefile b/lib/Makefile
index f6514d5..c72c353 100755
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -8,7 +8,7 @@
 ##===----------------------------------------------------------------------===##
 LEVEL = ../../..
 
-PARALLEL_DIRS = Headers Basic Lex Parse AST Sema CodeGen Analysis Rewrite  
+PARALLEL_DIRS = Headers Basic Lex Parse AST Sema CodeGen Analysis Rewrite Driver
 
 include $(LEVEL)/Makefile.common