[dsymutil] Create warn() global helper...
authorFrederic Riss <friss@apple.com>
Sat, 28 Feb 2015 00:29:01 +0000 (00:29 +0000)
committerFrederic Riss <friss@apple.com>
Sat, 28 Feb 2015 00:29:01 +0000 (00:29 +0000)
...and reimplement DwarfLinker::reportWarning in terms of it. Other
compenents than the DwarfLinker will need to report warnings, and I'm
about to add a similar "error()" helper at the same global level so
make that consistent.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230820 91177308-0d34-0410-b5e6-96231b3b80d8

tools/dsymutil/DwarfLinker.cpp

index 3c0bc0b85afac0917b22bbe7baf874ee54df9e74..71af214e434c9d3f92ecdef3e04e1793790e5361 100644 (file)
@@ -23,6 +23,11 @@ namespace dsymutil {
 
 namespace {
 
+void warn(const Twine &Warning, const Twine &Context) {
+  errs() << Twine("while processing ") + Context + ":\n";
+  errs() << Twine("warning: ") + Warning + "\n";
+}
+
 /// \brief Stores all information relating to a compile unit, be it in
 /// its original instance in the object file to its brand new cloned
 /// and linked DIE tree.
@@ -219,10 +224,10 @@ const DWARFDebugInfoEntryMinimal *DwarfLinker::resolveDIEReference(
 /// information about a specific \p DIE related to the warning.
 void DwarfLinker::reportWarning(const Twine &Warning, const DWARFUnit *Unit,
                                 const DWARFDebugInfoEntryMinimal *DIE) {
+  StringRef Context = "<debug map>";
   if (CurrentDebugObject)
-    errs() << Twine("while processing ") +
-                  CurrentDebugObject->getObjectFilename() + ":\n";
-  errs() << Twine("warning: ") + Warning + "\n";
+    Context = CurrentDebugObject->getObjectFilename();
+  warn(Warning, Context);
 
   if (!Verbose || !DIE)
     return;