[cfe-commits] r97102 - /cfe/trunk/tools/driver/driver.cpp

Daniel Dunbar daniel at zuster.org
Wed Feb 24 19:23:43 PST 2010


Author: ddunbar
Date: Wed Feb 24 21:23:43 2010
New Revision: 97102

URL: http://llvm.org/viewvc/llvm-project?rev=97102&view=rev
Log:
Driver: Use TextDiagnosticPrinter instead of a custom one.

Modified:
    cfe/trunk/tools/driver/driver.cpp

Modified: cfe/trunk/tools/driver/driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/driver.cpp?rev=97102&r1=97101&r2=97102&view=diff
==============================================================================
--- cfe/trunk/tools/driver/driver.cpp (original)
+++ cfe/trunk/tools/driver/driver.cpp Wed Feb 24 21:23:43 2010
@@ -15,6 +15,8 @@
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Driver.h"
 #include "clang/Driver/Option.h"
+#include "clang/Frontend/DiagnosticOptions.h"
+#include "clang/Frontend/TextDiagnosticPrinter.h"
 
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/OwningPtr.h"
@@ -29,38 +31,6 @@
 using namespace clang;
 using namespace clang::driver;
 
-class DriverDiagnosticPrinter : public DiagnosticClient {
-  std::string ProgName;
-  llvm::raw_ostream &OS;
-
-public:
-  DriverDiagnosticPrinter(const std::string _ProgName,
-                          llvm::raw_ostream &_OS)
-    : ProgName(_ProgName),
-      OS(_OS) {}
-
-  virtual void HandleDiagnostic(Diagnostic::Level DiagLevel,
-                                const DiagnosticInfo &Info);
-};
-
-void DriverDiagnosticPrinter::HandleDiagnostic(Diagnostic::Level Level,
-                                               const DiagnosticInfo &Info) {
-  OS << ProgName << ": ";
-
-  switch (Level) {
-  case Diagnostic::Ignored: assert(0 && "Invalid diagnostic type");
-  case Diagnostic::Note:    OS << "note: "; break;
-  case Diagnostic::Warning: OS << "warning: "; break;
-  case Diagnostic::Error:   OS << "error: "; break;
-  case Diagnostic::Fatal:   OS << "fatal error: "; break;
-  }
-
-  llvm::SmallString<100> OutStr;
-  Info.FormatDiagnostic(OutStr);
-  OS.write(OutStr.begin(), OutStr.size());
-  OS << '\n';
-}
-
 llvm::sys::Path GetExecutablePath(const char *Argv0, bool CanonicalPrefixes) {
   if (!CanonicalPrefixes)
     return llvm::sys::Path(Argv0);
@@ -218,7 +188,8 @@
 
   llvm::sys::Path Path = GetExecutablePath(argv[0], CanonicalPrefixes);
 
-  DriverDiagnosticPrinter DiagClient(Path.getBasename(), llvm::errs());
+  TextDiagnosticPrinter DiagClient(llvm::errs(), DiagnosticOptions());
+  DiagClient.setPrefix(Path.getBasename());
 
   Diagnostic Diags(&DiagClient);
 





More information about the cfe-commits mailing list