From 2e5daac21731eb27ef952efaad31cac2a5d8f254 Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Tue, 5 Oct 2021 18:34:02 +0100 Subject: [llvm] Update report_fatal_error calls from raw_string_ostream to use Twine(OS.str()) As described on D111049, we're trying to remove the dependency from error handling and replace uses of report_fatal_error(const std::string&) with the Twine() variant which can be forward declared. We can use the raw_string_ostream::str() method to perform the implicit flush() and return a reference to the std::string container that we can then wrap inside Twine(). --- llvm/lib/Object/Object.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'llvm/lib/Object/Object.cpp') diff --git a/llvm/lib/Object/Object.cpp b/llvm/lib/Object/Object.cpp index b486e9f..0659cf6 100644 --- a/llvm/lib/Object/Object.cpp +++ b/llvm/lib/Object/Object.cpp @@ -222,8 +222,7 @@ void LLVMMoveToContainingSection(LLVMSectionIteratorRef Sect, std::string Buf; raw_string_ostream OS(Buf); logAllUnhandledErrors(SecOrErr.takeError(), OS); - OS.flush(); - report_fatal_error(Buf); + report_fatal_error(Twine(OS.str())); } *unwrap(Sect) = *SecOrErr; } @@ -304,8 +303,7 @@ const char *LLVMGetSymbolName(LLVMSymbolIteratorRef SI) { std::string Buf; raw_string_ostream OS(Buf); logAllUnhandledErrors(Ret.takeError(), OS); - OS.flush(); - report_fatal_error(Buf); + report_fatal_error(Twine(OS.str())); } return Ret->data(); } @@ -316,8 +314,7 @@ uint64_t LLVMGetSymbolAddress(LLVMSymbolIteratorRef SI) { std::string Buf; raw_string_ostream OS(Buf); logAllUnhandledErrors(Ret.takeError(), OS); - OS.flush(); - report_fatal_error(Buf); + report_fatal_error(Twine(OS.str())); } return *Ret; } -- cgit v1.1