Revert "Revert "New implementation of llvm-rs-cc (replacement of slang_driver).""

This reverts commit a6d60672695f1438a63acdbf85eae7f97ce2b50d.
diff --git a/slang.cpp b/slang.cpp
index 0181c7b..ba4c861 100644
--- a/slang.cpp
+++ b/slang.cpp
@@ -44,6 +44,9 @@
 #include "llvm/Linker.h"
 #include "llvm/Bitcode/ReaderWriter.h"
 
+#include "clang/Frontend/DiagnosticOptions.h"
+#include "clang/Frontend/TextDiagnosticPrinter.h"
+
 namespace {
   struct ForceSlangLinking {
     ForceSlangLinking() {
@@ -57,6 +60,10 @@
       // llvm-rs-link needs following functions existing in libslang.
       llvm::ParseBitcodeFile(NULL, llvm::getGlobalContext(), NULL);
       llvm::Linker::LinkModules(NULL, NULL, NULL);
+
+      // llvm-rs-cc need this.
+      new clang::TextDiagnosticPrinter(llvm::errs(),
+                                       clang::DiagnosticOptions());
     }
   } ForceSlangLinking;
 }
@@ -142,24 +149,23 @@
   return;
 }
 
-void Slang::createTarget(const char* Triple, const char* CPU,
-                         const char** Features) {
-  if (Triple != NULL)
+void Slang::createTarget(const std::string &Triple, const std::string &CPU,
+                         const std::vector<std::string> &Features) {
+  if (!Triple.empty())
     mTargetOpts.Triple = Triple;
   else
     mTargetOpts.Triple = DEFAULT_TARGET_TRIPLE_STRING;
 
-  if (CPU != NULL)
+  if (!CPU.empty())
     mTargetOpts.CPU = CPU;
 
+  if (!Features.empty())
+    mTargetOpts.Features = Features;
+
   mTarget.reset(clang::TargetInfo::CreateTargetInfo(*mDiagnostics,
                                                     mTargetOpts));
 
-  if (Features != NULL)
-    for (int i = 0; Features[i] != NULL; i++)
-      mTargetOpts.Features.push_back(Features[i]);
-
-    return;
+  return;
 }
 
 void Slang::createFileManager() {
@@ -227,7 +233,8 @@
                      OT);
 }
 
-Slang::Slang(const char *Triple, const char *CPU, const char **Features)
+Slang::Slang(const std::string &Triple, const std::string &CPU,
+             const std::vector<std::string> &Features)
     : mDiagClient(NULL),
       mOT(OT_Default) {
   GlobalInitialization();
@@ -348,16 +355,6 @@
   return true;
 }
 
-bool Slang::setDepTargetBC(const char *TargetBCFile) {
-  mDepTargetBCFileName = TargetBCFile;
-
-  return true;
-}
-
-bool Slang::setAdditionalDepTarget(const char* AdditionalDepTargetFileName) {
-  mAdditionalDepTargetFileName = AdditionalDepTargetFileName;
-}
-
 int Slang::generateDepFile() {
   if (mDiagnostics->getNumErrors() > 0)
     return mDiagnostics->getNumErrors();
@@ -368,9 +365,7 @@
   clang::DependencyOutputOptions DepOpts;
   DepOpts.IncludeSystemHeaders = 1;
   DepOpts.OutputFile = mDepOutputFileName;
-  if (!mAdditionalDepTargetFileName.empty()) {
-    DepOpts.Targets.push_back(mAdditionalDepTargetFileName);
-  }
+  DepOpts.Targets = mAdditionalDepTargets;
   DepOpts.Targets.push_back(mDepTargetBCFileName);
 
   /* Per-compilation needed initialization */