summaryrefslogtreecommitdiffstats
path: root/llvm/tools/dsymutil/DwarfLinker.cpp
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2018-04-14 21:36:42 +0000
committerJonas Devlieghere <jonas@devlieghere.com>2018-04-14 21:36:42 +0000
commit3072b130b2e2bd471d66933ac3eb0b497a0867d7 (patch)
tree1305fbb7e5bb7b3498830d0161a21eb219f7f279 /llvm/tools/dsymutil/DwarfLinker.cpp
parentf08da81de0fabf510dbcaa1aba781deda56548a4 (diff)
downloadbcm5719-llvm-3072b130b2e2bd471d66933ac3eb0b497a0867d7.tar.gz
bcm5719-llvm-3072b130b2e2bd471d66933ac3eb0b497a0867d7.zip
[Support] Add convenience functions to WithColor. NFC.
Create convenience functions for printing error, warning and note to stdout. Previously we had similar functions being used in dsymutil, but given that this pattern is so common it makes sense to make it available globally. llvm-svn: 330091
Diffstat (limited to 'llvm/tools/dsymutil/DwarfLinker.cpp')
-rw-r--r--llvm/tools/dsymutil/DwarfLinker.cpp39
1 files changed, 20 insertions, 19 deletions
diff --git a/llvm/tools/dsymutil/DwarfLinker.cpp b/llvm/tools/dsymutil/DwarfLinker.cpp
index 16318e204f9..732fb919b7a 100644
--- a/llvm/tools/dsymutil/DwarfLinker.cpp
+++ b/llvm/tools/dsymutil/DwarfLinker.cpp
@@ -9,7 +9,6 @@
#include "BinaryHolder.h"
#include "DebugMap.h"
-#include "ErrorReporting.h"
#include "MachOUtils.h"
#include "NonRelocatableStringpool.h"
#include "dsymutil.h"
@@ -79,6 +78,7 @@
#include "llvm/Support/TargetRegistry.h"
#include "llvm/Support/ThreadPool.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"
@@ -587,15 +587,15 @@ static bool inFunctionScope(CompileUnit &U, unsigned Idx) {
} // namespace
void warn(Twine Warning, Twine Context) {
- warn_ostream() << Warning + "\n";
+ WithColor::warning() << Warning + "\n";
if (!Context.isTriviallyEmpty())
- note_ostream() << Twine("while processing ") + Context + "\n";
+ WithColor::note() << Twine("while processing ") + Context + "\n";
}
bool error(Twine Error, Twine Context) {
- error_ostream() << Error + "\n";
+ WithColor::error() << Error + "\n";
if (!Context.isTriviallyEmpty())
- note_ostream() << Twine("while processing ") + Context + "\n";
+ WithColor::note() << Twine("while processing ") + Context + "\n";
return false;
}
@@ -2178,7 +2178,7 @@ void DwarfLinker::reportWarning(const Twine &Warning, const DebugMapObject &DMO,
DumpOpts.RecurseDepth = 0;
DumpOpts.Verbose = Options.Verbose;
- note_ostream() << " in DIE:\n";
+ WithColor::note() << " in DIE:\n";
DIE->dump(errs(), 6 /* Indent */, DumpOpts);
}
@@ -3999,9 +3999,9 @@ Error DwarfLinker::loadClangModule(StringRef Filename, StringRef ModulePath,
// cache has expired and was pruned by clang. A more adventurous
// dsymutil would invoke clang to rebuild the module now.
if (!ModuleCacheHintDisplayed) {
- 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";
+ WithColor::note() << "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) {
@@ -4010,12 +4010,13 @@ Error DwarfLinker::loadClangModule(StringRef Filename, StringRef ModulePath,
// was built on a different machine. We don't want to discourage module
// debugging for convenience libraries within a project though.
if (!ArchiveHintDisplayed) {
- 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";
+ WithColor::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";
ArchiveHintDisplayed = true;
}
}
@@ -4248,10 +4249,10 @@ bool DwarfLinker::link(const DebugMap &Map) {
Stat.getLastModificationTime() !=
sys::TimePoint<>(LinkContext.DMO.getTimestamp())) {
// Not using the helper here as we can easily stream TimePoint<>.
- warn_ostream() << "Timestamp mismatch for " << File << ": "
- << Stat.getLastModificationTime() << " and "
- << sys::TimePoint<>(LinkContext.DMO.getTimestamp())
- << "\n";
+ WithColor::warning()
+ << "Timestamp mismatch for " << File << ": "
+ << Stat.getLastModificationTime() << " and "
+ << sys::TimePoint<>(LinkContext.DMO.getTimestamp()) << "\n";
continue;
}
OpenPOWER on IntegriCloud