diff options
author | Jonas Devlieghere <jonas@devlieghere.com> | 2018-04-21 21:11:59 +0000 |
---|---|---|
committer | Jonas Devlieghere <jonas@devlieghere.com> | 2018-04-21 21:11:59 +0000 |
commit | 2cd41eb0581496d79a6f462f3b7d0d5bc6655956 (patch) | |
tree | 31d787a02f5e663428944e5c3788cba55224d1ac /llvm/tools/llvm-opt-report/OptReport.cpp | |
parent | 825ead950ec7b68161bf73b987f1e2f2da05198c (diff) | |
download | bcm5719-llvm-2cd41eb0581496d79a6f462f3b7d0d5bc6655956.tar.gz bcm5719-llvm-2cd41eb0581496d79a6f462f3b7d0d5bc6655956.zip |
[tools] Use WithColor for printing errors.
Use convenience helpers in WithColor to print errors, warnings and notes
in a few more tools.
llvm-svn: 330524
Diffstat (limited to 'llvm/tools/llvm-opt-report/OptReport.cpp')
-rw-r--r-- | llvm/tools/llvm-opt-report/OptReport.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/llvm/tools/llvm-opt-report/OptReport.cpp b/llvm/tools/llvm-opt-report/OptReport.cpp index c247da4f55c..c90fdb0ad01 100644 --- a/llvm/tools/llvm-opt-report/OptReport.cpp +++ b/llvm/tools/llvm-opt-report/OptReport.cpp @@ -25,6 +25,7 @@ #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Path.h" #include "llvm/Support/Program.h" +#include "llvm/Support/WithColor.h" #include "llvm/Support/YAMLTraits.h" #include "llvm/Support/raw_ostream.h" #include <cstdlib> @@ -273,8 +274,8 @@ static bool readLocationInfo(LocationInfoTy &LocationInfo) { ErrorOr<std::unique_ptr<MemoryBuffer>> Buf = MemoryBuffer::getFileOrSTDIN(InputFileName); if (std::error_code EC = Buf.getError()) { - errs() << "error: Can't open file " << InputFileName << ": " << - EC.message() << "\n"; + WithColor::error() << "Can't open file " << InputFileName << ": " + << EC.message() << "\n"; return false; } @@ -282,7 +283,7 @@ static bool readLocationInfo(LocationInfoTy &LocationInfo) { yaml::Stream Stream(Buf.get()->getBuffer(), SM); collectLocationInfo(Stream, LocationInfo); - return true; + return true; } static bool writeReport(LocationInfoTy &LocationInfo) { @@ -290,8 +291,8 @@ static bool writeReport(LocationInfoTy &LocationInfo) { llvm::raw_fd_ostream OS(OutputFileName, EC, llvm::sys::fs::F_Text); if (EC) { - errs() << "error: Can't open file " << OutputFileName << ": " << - EC.message() << "\n"; + WithColor::error() << "Can't open file " << OutputFileName << ": " + << EC.message() << "\n"; return false; } @@ -300,8 +301,8 @@ static bool writeReport(LocationInfoTy &LocationInfo) { SmallString<128> FileName(FI.first); if (!InputRelDir.empty()) { if (std::error_code EC = sys::fs::make_absolute(InputRelDir, FileName)) { - errs() << "error: Can't resolve file path to " << FileName << ": " << - EC.message() << "\n"; + WithColor::error() << "Can't resolve file path to " << FileName << ": " + << EC.message() << "\n"; return false; } } @@ -311,8 +312,8 @@ static bool writeReport(LocationInfoTy &LocationInfo) { ErrorOr<std::unique_ptr<MemoryBuffer>> Buf = MemoryBuffer::getFile(FileName); if (std::error_code EC = Buf.getError()) { - errs() << "error: Can't open file " << FileName << ": " << - EC.message() << "\n"; + WithColor::error() << "Can't open file " << FileName << ": " + << EC.message() << "\n"; return false; } @@ -396,7 +397,7 @@ static bool writeReport(LocationInfoTy &LocationInfo) { if (!Printed) OS << FuncName; - } + } OS << ":\n"; } @@ -522,8 +523,7 @@ int main(int argc, const char **argv) { if (!readLocationInfo(LocationInfo)) return 1; if (!writeReport(LocationInfo)) - return 1; + return 1; return 0; } - |