Merge remote-tracking branch 'origin/swift-4.2-branch' into stable
diff --git a/include/llvm/Support/WithColor.h b/include/llvm/Support/WithColor.h
new file mode 100644
index 0000000..39c9953
--- /dev/null
+++ b/include/llvm/Support/WithColor.h
@@ -0,0 +1,48 @@
+//===- WithColor.h ----------------------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_SUPPORT_WITHCOLOR_H
+#define LLVM_SUPPORT_WITHCOLOR_H
+
+namespace llvm {
+
+class raw_ostream;
+
+// Symbolic names for various syntax elements.
+enum class HighlightColor {
+  Address,
+  String,
+  Tag,
+  Attribute,
+  Enumerator,
+  Macro,
+  Error,
+  Warning,
+  Note
+};
+
+/// An RAII object that temporarily switches an output stream to a specific
+/// color.
+class WithColor {
+  raw_ostream &OS;
+  /// Determine whether colors should be displayed.
+  bool colorsEnabled(raw_ostream &OS);
+
+public:
+  /// To be used like this: WithColor(OS, HighlightColor::String) << "text";
+  WithColor(raw_ostream &OS, HighlightColor S);
+  ~WithColor();
+
+  raw_ostream &get() { return OS; }
+  operator raw_ostream &() { return OS; }
+};
+
+} // end namespace llvm
+
+#endif // LLVM_LIB_DEBUGINFO_WITHCOLOR_H
diff --git a/lib/DebugInfo/DWARF/CMakeLists.txt b/lib/DebugInfo/DWARF/CMakeLists.txt
index 620016d..df14fba 100644
--- a/lib/DebugInfo/DWARF/CMakeLists.txt
+++ b/lib/DebugInfo/DWARF/CMakeLists.txt
@@ -22,7 +22,6 @@
   DWARFUnitIndex.cpp
   DWARFUnit.cpp
   DWARFVerifier.cpp
-  SyntaxHighlighting.cpp
 
   ADDITIONAL_HEADER_DIRS
   ${LLVM_MAIN_INCLUDE_DIR}/llvm/DebugInfo/DWARF
diff --git a/lib/DebugInfo/DWARF/DWARFDebugMacro.cpp b/lib/DebugInfo/DWARF/DWARFDebugMacro.cpp
index 1b77be6..6d789c3 100644
--- a/lib/DebugInfo/DWARF/DWARFDebugMacro.cpp
+++ b/lib/DebugInfo/DWARF/DWARFDebugMacro.cpp
@@ -8,14 +8,13 @@
 //===----------------------------------------------------------------------===//
 
 #include "llvm/DebugInfo/DWARF/DWARFDebugMacro.h"
-#include "SyntaxHighlighting.h"
 #include "llvm/BinaryFormat/Dwarf.h"
+#include "llvm/Support/WithColor.h"
 #include "llvm/Support/raw_ostream.h"
 #include <cstdint>
 
 using namespace llvm;
 using namespace dwarf;
-using namespace syntax;
 
 void DWARFDebugMacro::dump(raw_ostream &OS) const {
   unsigned IndLevel = 0;
@@ -29,7 +28,7 @@
       OS << "  ";
     IndLevel += (E.Type == DW_MACINFO_start_file);
 
-    WithColor(OS, syntax::Macro).get() << MacinfoString(E.Type);
+    WithColor(OS, HighlightColor::Macro).get() << MacinfoString(E.Type);
     switch (E.Type) {
     default:
       // Got a corrupted ".debug_macinfo" section (invalid macinfo type).
diff --git a/lib/DebugInfo/DWARF/DWARFDie.cpp b/lib/DebugInfo/DWARF/DWARFDie.cpp
index 17559d2..82f373e 100644
--- a/lib/DebugInfo/DWARF/DWARFDie.cpp
+++ b/lib/DebugInfo/DWARF/DWARFDie.cpp
@@ -8,7 +8,6 @@
 //===----------------------------------------------------------------------===//
 
 #include "llvm/DebugInfo/DWARF/DWARFDie.h"
-#include "SyntaxHighlighting.h"
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringRef.h"
@@ -23,6 +22,7 @@
 #include "llvm/Support/DataExtractor.h"
 #include "llvm/Support/Format.h"
 #include "llvm/Support/MathExtras.h"
+#include "llvm/Support/WithColor.h"
 #include "llvm/Support/raw_ostream.h"
 #include <algorithm>
 #include <cassert>
@@ -34,7 +34,6 @@
 using namespace llvm;
 using namespace dwarf;
 using namespace object;
-using namespace syntax;
 
 static void dumpApplePropertyAttribute(raw_ostream &OS, uint64_t Val) {
   OS << " (";
@@ -191,9 +190,10 @@
   OS.indent(Indent + 2);
   auto attrString = AttributeString(Attr);
   if (!attrString.empty())
-    WithColor(OS, syntax::Attribute) << attrString;
+    WithColor(OS, HighlightColor::Attribute) << attrString;
   else
-    WithColor(OS, syntax::Attribute).get() << format("DW_AT_Unknown_%x", Attr);
+    WithColor(OS, HighlightColor::Attribute).get()
+        << format("DW_AT_Unknown_%x", Attr);
 
   if (DumpOpts.Verbose || DumpOpts.ShowForm) {
     auto formString = FormEncodingString(Form);
@@ -214,9 +214,9 @@
 
   StringRef Name;
   std::string File;
-  auto Color = syntax::Enumerator;
+  auto Color = HighlightColor::Enumerator;
   if (Attr == DW_AT_decl_file || Attr == DW_AT_call_file) {
-    Color = syntax::String;
+    Color = HighlightColor::String;
     if (const auto *LT = U->getContext().getLineTableForUnit(U))
       if (LT->getFileNameByIndex(
               formValue.getAsUnsignedConstant().getValue(),
@@ -459,16 +459,17 @@
   if (debug_info_data.isValidOffset(offset)) {
     uint32_t abbrCode = debug_info_data.getULEB128(&offset);
     if (DumpOpts.ShowAddresses)
-      WithColor(OS, syntax::Address).get() << format("\n0x%8.8x: ", Offset);
+      WithColor(OS, HighlightColor::Address).get()
+          << format("\n0x%8.8x: ", Offset);
 
     if (abbrCode) {
       auto AbbrevDecl = getAbbreviationDeclarationPtr();
       if (AbbrevDecl) {
         auto tagString = TagString(getTag());
         if (!tagString.empty())
-          WithColor(OS, syntax::Tag).get().indent(Indent) << tagString;
+          WithColor(OS, HighlightColor::Tag).get().indent(Indent) << tagString;
         else
-          WithColor(OS, syntax::Tag).get().indent(Indent)
+          WithColor(OS, HighlightColor::Tag).get().indent(Indent)
               << format("DW_TAG_Unknown_%x", getTag());
 
         if (DumpOpts.Verbose)
diff --git a/lib/DebugInfo/DWARF/DWARFFormValue.cpp b/lib/DebugInfo/DWARF/DWARFFormValue.cpp
index a7bde07..60d52d2 100644
--- a/lib/DebugInfo/DWARF/DWARFFormValue.cpp
+++ b/lib/DebugInfo/DWARF/DWARFFormValue.cpp
@@ -8,7 +8,6 @@
 //===----------------------------------------------------------------------===//
 
 #include "llvm/DebugInfo/DWARF/DWARFFormValue.h"
-#include "SyntaxHighlighting.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/Optional.h"
@@ -19,6 +18,7 @@
 #include "llvm/DebugInfo/DWARF/DWARFUnit.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/Format.h"
+#include "llvm/Support/WithColor.h"
 #include "llvm/Support/raw_ostream.h"
 #include <cinttypes>
 #include <cstdint>
@@ -26,7 +26,6 @@
 
 using namespace llvm;
 using namespace dwarf;
-using namespace syntax;
 
 static const DWARFFormValue::FormClass DWARF4FormClasses[] = {
     DWARFFormValue::FC_Unknown,  // 0x0
@@ -402,8 +401,9 @@
 void DWARFFormValue::dump(raw_ostream &OS, DIDumpOptions DumpOpts) const {
   uint64_t UValue = Value.uval;
   bool CURelativeOffset = false;
-  raw_ostream &AddrOS =
-      DumpOpts.ShowAddresses ? WithColor(OS, syntax::Address).get() : nulls();
+  raw_ostream &AddrOS = DumpOpts.ShowAddresses
+                            ? WithColor(OS, HighlightColor::Address).get()
+                            : nulls();
   switch (Form) {
   case DW_FORM_addr:
     AddrOS << format("0x%016" PRIx64, UValue);
@@ -560,7 +560,7 @@
   if (CURelativeOffset) {
     if (DumpOpts.Verbose)
       OS << " => {";
-    WithColor(OS, syntax::Address).get()
+    WithColor(OS, HighlightColor::Address).get()
         << format("0x%8.8" PRIx64, UValue + (U ? U->getOffset() : 0));
     if (DumpOpts.Verbose)
       OS << "}";
@@ -570,10 +570,10 @@
 void DWARFFormValue::dumpString(raw_ostream &OS) const {
   Optional<const char *> DbgStr = getAsCString();
   if (DbgStr.hasValue()) {
-    raw_ostream &COS = WithColor(OS, syntax::String);
-    COS << '"';
-    COS.write_escaped(DbgStr.getValue());
-    COS << '"';
+    auto COS = WithColor(OS, HighlightColor::String);
+    COS.get() << '"';
+    COS.get().write_escaped(DbgStr.getValue());
+    COS.get() << '"';
   }
 }
 
diff --git a/lib/DebugInfo/DWARF/DWARFVerifier.cpp b/lib/DebugInfo/DWARF/DWARFVerifier.cpp
index bfc0675..a2c35c7 100644
--- a/lib/DebugInfo/DWARF/DWARFVerifier.cpp
+++ b/lib/DebugInfo/DWARF/DWARFVerifier.cpp
@@ -7,8 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "SyntaxHighlighting.h"
 #include "llvm/DebugInfo/DWARF/DWARFVerifier.h"
+#include "llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h"
 #include "llvm/DebugInfo/DWARF/DWARFCompileUnit.h"
 #include "llvm/DebugInfo/DWARF/DWARFContext.h"
 #include "llvm/DebugInfo/DWARF/DWARFDebugLine.h"
@@ -16,8 +16,8 @@
 #include "llvm/DebugInfo/DWARF/DWARFExpression.h"
 #include "llvm/DebugInfo/DWARF/DWARFFormValue.h"
 #include "llvm/DebugInfo/DWARF/DWARFSection.h"
-#include "llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h"
 #include "llvm/Support/FormatVariadic.h"
+#include "llvm/Support/WithColor.h"
 #include "llvm/Support/raw_ostream.h"
 #include <map>
 #include <set>
@@ -26,7 +26,6 @@
 using namespace llvm;
 using namespace dwarf;
 using namespace object;
-using namespace syntax;
 
 DWARFVerifier::DieRangeInfo::address_range_iterator
 DWARFVerifier::DieRangeInfo::insert(const DWARFAddressRange &R) {
@@ -798,13 +797,13 @@
 }
 
 raw_ostream &DWARFVerifier::error() const {
-  return WithColor(OS, syntax::Error).get() << "error: ";
+  return WithColor(OS, HighlightColor::Error).get() << "error: ";
 }
 
 raw_ostream &DWARFVerifier::warn() const {
-  return WithColor(OS, syntax::Warning).get() << "warning: ";
+  return WithColor(OS, HighlightColor::Warning).get() << "warning: ";
 }
 
 raw_ostream &DWARFVerifier::note() const {
-  return WithColor(OS, syntax::Note).get() << "note: ";
+  return WithColor(OS, HighlightColor::Note).get() << "note: ";
 }
diff --git a/lib/DebugInfo/DWARF/SyntaxHighlighting.cpp b/lib/DebugInfo/DWARF/SyntaxHighlighting.cpp
deleted file mode 100644
index 65d66fc..0000000
--- a/lib/DebugInfo/DWARF/SyntaxHighlighting.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-//===- SyntaxHighlighting.cpp ---------------------------------------------===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "SyntaxHighlighting.h"
-#include "llvm/Support/CommandLine.h"
-#include "llvm/Support/raw_ostream.h"
-
-using namespace llvm;
-using namespace dwarf;
-using namespace syntax;
-
-static cl::opt<cl::boolOrDefault>
-    UseColor("color",
-             cl::desc("use colored syntax highlighting (default=autodetect)"),
-             cl::init(cl::BOU_UNSET));
-
-WithColor::WithColor(raw_ostream &OS, enum HighlightColor Type) : OS(OS) {
-  // Detect color from terminal type unless the user passed the --color option.
-  if (UseColor == cl::BOU_UNSET ? OS.has_colors() : UseColor == cl::BOU_TRUE) {
-    switch (Type) {
-    case Address:    OS.changeColor(raw_ostream::YELLOW);         break;
-    case String:     OS.changeColor(raw_ostream::GREEN);          break;
-    case Tag:        OS.changeColor(raw_ostream::BLUE);           break;
-    case Attribute:  OS.changeColor(raw_ostream::CYAN);           break;
-    case Enumerator: OS.changeColor(raw_ostream::MAGENTA);        break;
-    case Macro:      OS.changeColor(raw_ostream::RED);            break;
-    case Error:      OS.changeColor(raw_ostream::RED, true);      break;
-    case Warning:    OS.changeColor(raw_ostream::MAGENTA, true);  break;
-    case Note:       OS.changeColor(raw_ostream::BLACK, true);    break;
-    }
-  }
-}
-
-WithColor::~WithColor() {
-  if (UseColor == cl::BOU_UNSET ? OS.has_colors() : UseColor == cl::BOU_TRUE)
-    OS.resetColor();
-}
diff --git a/lib/DebugInfo/DWARF/SyntaxHighlighting.h b/lib/DebugInfo/DWARF/SyntaxHighlighting.h
deleted file mode 100644
index 686cf2c..0000000
--- a/lib/DebugInfo/DWARF/SyntaxHighlighting.h
+++ /dev/null
@@ -1,52 +0,0 @@
-//===- SyntaxHighlighting.h -------------------------------------*- C++ -*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_LIB_DEBUGINFO_SYNTAXHIGHLIGHTING_H
-#define LLVM_LIB_DEBUGINFO_SYNTAXHIGHLIGHTING_H
-
-namespace llvm {
-
-class raw_ostream;
-
-namespace dwarf {
-namespace syntax {
-
-// Symbolic names for various syntax elements.
-enum HighlightColor {
-  Address,
-  String,
-  Tag,
-  Attribute,
-  Enumerator,
-  Macro,
-  Error,
-  Warning,
-  Note
-};
-
-/// An RAII object that temporarily switches an output stream to a
-/// specific color.
-class WithColor {
-  raw_ostream &OS;
-
-public:
-  /// To be used like this: WithColor(OS, syntax::String) << "text";
-  WithColor(raw_ostream &OS, enum HighlightColor Type);
-  ~WithColor();
-
-  raw_ostream &get() { return OS; }
-  operator raw_ostream &() { return OS; }
-};
-
-} // end namespace syntax
-} // end namespace dwarf
-
-} // end namespace llvm
-
-#endif // LLVM_LIB_DEBUGINFO_SYNTAXHIGHLIGHTING_H
diff --git a/lib/Support/CMakeLists.txt b/lib/Support/CMakeLists.txt
index 9d4db16..8489391 100644
--- a/lib/Support/CMakeLists.txt
+++ b/lib/Support/CMakeLists.txt
@@ -115,6 +115,7 @@
   Twine.cpp
   Unicode.cpp
   UnicodeCaseFold.cpp
+  WithColor.cpp
   YAMLParser.cpp
   YAMLTraits.cpp
   raw_os_ostream.cpp
diff --git a/lib/Support/WithColor.cpp b/lib/Support/WithColor.cpp
new file mode 100644
index 0000000..39a582d
--- /dev/null
+++ b/lib/Support/WithColor.cpp
@@ -0,0 +1,65 @@
+//===- WithColor.cpp ------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Support/WithColor.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/raw_ostream.h"
+
+using namespace llvm;
+
+static cl::opt<cl::boolOrDefault>
+    UseColor("color",
+             cl::desc("use colored syntax highlighting (default=autodetect)"),
+             cl::init(cl::BOU_UNSET));
+
+bool WithColor::colorsEnabled(raw_ostream &OS) {
+  if (UseColor == cl::BOU_UNSET)
+    return OS.has_colors();
+  return UseColor == cl::BOU_TRUE;
+}
+
+WithColor::WithColor(raw_ostream &OS, HighlightColor Color) : OS(OS) {
+  // Detect color from terminal type unless the user passed the --color option.
+  if (colorsEnabled(OS)) {
+    switch (Color) {
+    case HighlightColor::Address:
+      OS.changeColor(raw_ostream::YELLOW);
+      break;
+    case HighlightColor::String:
+      OS.changeColor(raw_ostream::GREEN);
+      break;
+    case HighlightColor::Tag:
+      OS.changeColor(raw_ostream::BLUE);
+      break;
+    case HighlightColor::Attribute:
+      OS.changeColor(raw_ostream::CYAN);
+      break;
+    case HighlightColor::Enumerator:
+      OS.changeColor(raw_ostream::MAGENTA);
+      break;
+    case HighlightColor::Macro:
+      OS.changeColor(raw_ostream::RED);
+      break;
+    case HighlightColor::Error:
+      OS.changeColor(raw_ostream::RED, true);
+      break;
+    case HighlightColor::Warning:
+      OS.changeColor(raw_ostream::MAGENTA, true);
+      break;
+    case HighlightColor::Note:
+      OS.changeColor(raw_ostream::BLACK, true);
+      break;
+    }
+  }
+}
+
+WithColor::~WithColor() {
+  if (colorsEnabled(OS))
+    OS.resetColor();
+}
diff --git a/test/tools/dsymutil/X86/module-warnings.test b/test/tools/dsymutil/X86/module-warnings.test
index 3240a26..453e90e 100644
--- a/test/tools/dsymutil/X86/module-warnings.test
+++ b/test/tools/dsymutil/X86/module-warnings.test
@@ -42,7 +42,7 @@
 # STATIC: warning: {{.*}}Bar.pcm:
 # STATIC: note: Linking a static library
 # STATIC: warning: {{.*}}Foo.pcm:
-# STATIC-NOT: note:
+# STATIC-NOT: warning:
 
 ---
 triple:          'x86_64-apple-darwin'
diff --git a/test/tools/dsymutil/X86/swift-ast-x86_64.test b/test/tools/dsymutil/X86/swift-ast-x86_64.test
index 98d3850..daee1cd 100644
--- a/test/tools/dsymutil/X86/swift-ast-x86_64.test
+++ b/test/tools/dsymutil/X86/swift-ast-x86_64.test
@@ -16,4 +16,4 @@
 READOBJ-NEXT: |.|
 
 RUN: llvm-dsymutil -oso-prepend-path %p/.. %p/../Inputs/swift-ast.macho.x86_64 -no-output -verbose 2>&1 | FileCheck %s --check-prefix=TIMESTAMP
-TIMESTAMP: Warning: Timestamp mismatch
+TIMESTAMP: warning: Timestamp mismatch
diff --git a/tools/dsymutil/DwarfLinker.cpp b/tools/dsymutil/DwarfLinker.cpp
index 1cddb61..f1d6536 100644
--- a/tools/dsymutil/DwarfLinker.cpp
+++ b/tools/dsymutil/DwarfLinker.cpp
@@ -76,6 +76,7 @@
 #include "llvm/Support/Path.h"
 #include "llvm/Support/TargetRegistry.h"
 #include "llvm/Support/ToolOutputFile.h"
+#include "llvm/Support/WithColor.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/Target/TargetOptions.h"
@@ -560,8 +561,32 @@
   return false;
 }
 
+static raw_ostream &error_ostream() {
+  return WithColor(errs(), HighlightColor::Error).get() << "error: ";
+}
+
+static raw_ostream &warn_ostream() {
+  return WithColor(errs(), HighlightColor::Warning).get() << "warning: ";
+}
+
+static raw_ostream &note_ostream() {
+  return WithColor(errs(), HighlightColor::Note).get() << "note: ";
+}
 } // end anonymous namespace
 
+void warn(Twine Warning, Twine Context) {
+  warn_ostream() << Warning + "\n";
+  if (!Context.isTriviallyEmpty())
+    note_ostream() << Twine("while processing ") + Context + ":\n";
+}
+
+bool error(Twine Error, Twine Context) {
+  error_ostream() << Error + "\n";
+  if (!Context.isTriviallyEmpty())
+    note_ostream() << Twine("while processing ") + Context + ":\n";
+  return false;
+}
+
 void CompileUnit::markEverythingAsKept() {
   unsigned Idx = 0;
 
@@ -2101,7 +2126,7 @@
   DumpOpts.RecurseDepth = 0;
   DumpOpts.Verbose = Options.Verbose;
 
-  errs() << "    in DIE:\n";
+  note_ostream() << "    in DIE:\n";
   DIE->dump(errs(), 6 /* Indent */, DumpOpts);
 }
 
@@ -3898,9 +3923,9 @@
         // cache has expired and was pruned by clang.  A more adventurous
         // dsymutil would invoke clang to rebuild the module now.
         if (!ModuleCacheHintDisplayed) {
-          errs() << "note: The clang module cache may have expired since this "
-                    "object file was built. Rebuilding the object file will "
-                    "rebuild the module cache.\n";
+          note_ostream() << "The clang module cache may have expired since "
+                            "this object file was built. Rebuilding the "
+                            "object file will rebuild the module cache.\n";
           ModuleCacheHintDisplayed = true;
         }
       } else if (isArchive) {
@@ -3909,11 +3934,12 @@
         // was built on a different machine. We don't want to discourage module
         // debugging for convenience libraries within a project though.
         if (!ArchiveHintDisplayed) {
-          errs() << "note: Linking a static library that was built with "
-                    "-gmodules, but the module cache was not found.  "
-                    "Redistributable static libraries should never be built "
-                    "with module debugging enabled.  The debug experience will "
-                    "be degraded due to incomplete debug information.\n";
+          note_ostream() << "Linking a static library that was built with "
+                            "-gmodules, but the module cache was not found.  "
+                            "Redistributable static libraries should never be "
+                            "built with module debugging enabled.  The debug "
+                            "experience will be degraded due to incomplete "
+                            "debug information.\n";
           ArchiveHintDisplayed = true;
         }
       }
@@ -3937,7 +3963,7 @@
             (Filename +
              ": Clang modules are expected to have exactly 1 compile unit.\n")
                 .str();
-        errs() << Err;
+        error(Err);
         return make_error<StringError>(Err, inconvertibleErrorCode());
       }
       // FIXME: Until PR27449 (https://llvm.org/bugs/show_bug.cgi?id=27449) is
@@ -4049,15 +4075,16 @@
         continue;
       }
       sys::fs::file_status Stat;
-      if (auto errc = sys::fs::status(File, Stat)) {
-        errs() << "Warning: " << errc.message() << "\n";
+      if (auto Err = sys::fs::status(File, Stat)) {
+        warn(Err.message());
         continue;
       }
       if (!Options.NoTimestamp && Stat.getLastModificationTime() !=
                                       sys::TimePoint<>(Obj->getTimestamp())) {
-        errs() << "Warning: Timestamp mismatch for " << File << ": "
-               << Stat.getLastModificationTime() << " and "
-               << sys::TimePoint<>(Obj->getTimestamp()) << "\n";
+        // Not using the helper here as we can easily stream TimePoint<>.
+        warn_ostream() << "Timestamp mismatch for " << File << ": "
+                       << Stat.getLastModificationTime() << " and "
+                       << sys::TimePoint<>(Obj->getTimestamp()) << "\n";
         continue;
       }
 
diff --git a/tools/dsymutil/dsymutil.h b/tools/dsymutil/dsymutil.h
index d056947..c56597a 100644
--- a/tools/dsymutil/dsymutil.h
+++ b/tools/dsymutil/dsymutil.h
@@ -71,8 +71,8 @@
 bool linkDwarf(raw_fd_ostream &OutFile, const DebugMap &DM,
                const LinkOptions &Options);
 
-void warn(const Twine &Warning, const Twine &Context);
-bool error(const Twine &Error, const Twine &Context);
+void warn(Twine Warning, Twine Context = {});
+bool error(Twine Error, Twine Context = {});
 
 } // end namespace dsymutil
 } // end namespace llvm