summaryrefslogtreecommitdiff
path: root/lib/IR
diff options
context:
space:
mode:
authorAlp Toker <alp@nuanti.com>2014-06-26 22:52:05 +0000
committerAlp Toker <alp@nuanti.com>2014-06-26 22:52:05 +0000
commit8dd8d5c2b2ad0f9dd1ca01c0a7d8ebac57b8537d (patch)
tree7da91c52380a71a92a895b0c172ae28b83fb6011 /lib/IR
parenteca517deaa890b1658ed0452704f398ce80e47b8 (diff)
downloadllvm-8dd8d5c2b2ad0f9dd1ca01c0a7d8ebac57b8537d.tar.gz
llvm-8dd8d5c2b2ad0f9dd1ca01c0a7d8ebac57b8537d.tar.bz2
llvm-8dd8d5c2b2ad0f9dd1ca01c0a7d8ebac57b8537d.tar.xz
Revert "Introduce a string_ostream string builder facilty"
Temporarily back out commits r211749, r211752 and r211754. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211814 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/IR')
-rw-r--r--lib/IR/Core.cpp37
-rw-r--r--lib/IR/DataLayout.cpp3
-rw-r--r--lib/IR/LLVMContext.cpp15
3 files changed, 33 insertions, 22 deletions
diff --git a/lib/IR/Core.cpp b/lib/IR/Core.cpp
index 779d891304..2c49d5b949 100644
--- a/lib/IR/Core.cpp
+++ b/lib/IR/Core.cpp
@@ -62,11 +62,6 @@ void LLVMShutdown() {
/*===-- Error handling ----------------------------------------------------===*/
-static char *LLVMCreateMessage(string_ostream &OS) {
- OS << '\0';
- return strdup(OS.str().data());
-}
-
char *LLVMCreateMessage(const char *Message) {
return strdup(Message);
}
@@ -115,10 +110,14 @@ unsigned LLVMGetMDKindID(const char* Name, unsigned SLen) {
}
char *LLVMGetDiagInfoDescription(LLVMDiagnosticInfoRef DI) {
- string_ostream Msg;
- DiagnosticPrinterRawOStream DP(Msg);
+ std::string MsgStorage;
+ raw_string_ostream Stream(MsgStorage);
+ DiagnosticPrinterRawOStream DP(Stream);
+
unwrap(DI)->print(DP);
- return LLVMCreateMessage(Msg);
+ Stream.flush();
+
+ return LLVMCreateMessage(MsgStorage.c_str());
}
LLVMDiagnosticSeverity LLVMGetDiagInfoSeverity(LLVMDiagnosticInfoRef DI){
@@ -202,9 +201,13 @@ LLVMBool LLVMPrintModuleToFile(LLVMModuleRef M, const char *Filename,
}
char *LLVMPrintModuleToString(LLVMModuleRef M) {
- string_ostream os;
+ std::string buf;
+ raw_string_ostream os(buf);
+
unwrap(M)->print(os, nullptr);
- return LLVMCreateMessage(os);
+ os.flush();
+
+ return strdup(buf.c_str());
}
/*--.. Operations on inline assembler ......................................--*/
@@ -275,14 +278,17 @@ void LLVMDumpType(LLVMTypeRef Ty) {
}
char *LLVMPrintTypeToString(LLVMTypeRef Ty) {
- string_ostream os;
+ std::string buf;
+ raw_string_ostream os(buf);
if (unwrap(Ty))
unwrap(Ty)->print(os);
else
os << "Printing <null> Type";
- return LLVMCreateMessage(os);
+ os.flush();
+
+ return strdup(buf.c_str());
}
/*--.. Operations on integer types .........................................--*/
@@ -526,14 +532,17 @@ void LLVMDumpValue(LLVMValueRef Val) {
}
char* LLVMPrintValueToString(LLVMValueRef Val) {
- string_ostream os;
+ std::string buf;
+ raw_string_ostream os(buf);
if (unwrap(Val))
unwrap(Val)->print(os);
else
os << "Printing <null> Value";
- return LLVMCreateMessage(os);
+ os.flush();
+
+ return strdup(buf.c_str());
}
void LLVMReplaceAllUsesWith(LLVMValueRef OldVal, LLVMValueRef NewVal) {
diff --git a/lib/IR/DataLayout.cpp b/lib/IR/DataLayout.cpp
index 3aa775097d..dea05fbef4 100644
--- a/lib/IR/DataLayout.cpp
+++ b/lib/IR/DataLayout.cpp
@@ -519,7 +519,8 @@ const StructLayout *DataLayout::getStructLayout(StructType *Ty) const {
}
std::string DataLayout::getStringRepresentation() const {
- string_ostream OS;
+ std::string Result;
+ raw_string_ostream OS(Result);
OS << (LittleEndian ? "e" : "E");
diff --git a/lib/IR/LLVMContext.cpp b/lib/IR/LLVMContext.cpp
index 201b278285..de825f00b2 100644
--- a/lib/IR/LLVMContext.cpp
+++ b/lib/IR/LLVMContext.cpp
@@ -164,22 +164,23 @@ void LLVMContext::diagnose(const DiagnosticInfo &DI) {
}
// Otherwise, print the message with a prefix based on the severity.
- string_ostream Msg;
- DiagnosticPrinterRawOStream DP(Msg);
+ std::string MsgStorage;
+ raw_string_ostream Stream(MsgStorage);
+ DiagnosticPrinterRawOStream DP(Stream);
DI.print(DP);
-
+ Stream.flush();
switch (DI.getSeverity()) {
case DS_Error:
- errs() << "error: " << Msg.str() << "\n";
+ errs() << "error: " << MsgStorage << "\n";
exit(1);
case DS_Warning:
- errs() << "warning: " << Msg.str() << "\n";
+ errs() << "warning: " << MsgStorage << "\n";
break;
case DS_Remark:
- errs() << "remark: " << Msg.str() << "\n";
+ errs() << "remark: " << MsgStorage << "\n";
break;
case DS_Note:
- errs() << "note: " << Msg.str() << "\n";
+ errs() << "note: " << MsgStorage << "\n";
break;
}
}