summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorAlp Toker <alp@nuanti.com>2014-06-26 00:25:41 +0000
committerAlp Toker <alp@nuanti.com>2014-06-26 00:25:41 +0000
commit2251672878c7212c96f16c6f2d30c142f2aae877 (patch)
tree9509bbc4c6ff7ad89d5232a7ef1491d1c46a8eb1 /llvm/lib
parent0f0cd46201c90c06d3f5e7c93c80cce0565881bc (diff)
downloadbcm5719-llvm-2251672878c7212c96f16c6f2d30c142f2aae877.tar.gz
bcm5719-llvm-2251672878c7212c96f16c6f2d30c142f2aae877.zip
MSVC build fix following r211749
Avoid strndup() llvm-svn: 211752
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Analysis/Analysis.cpp6
-rw-r--r--llvm/lib/IR/Core.cpp14
-rw-r--r--llvm/lib/IRReader/IRReader.cpp3
3 files changed, 13 insertions, 10 deletions
diff --git a/llvm/lib/Analysis/Analysis.cpp b/llvm/lib/Analysis/Analysis.cpp
index 7b6397679d7..907203c571e 100644
--- a/llvm/lib/Analysis/Analysis.cpp
+++ b/llvm/lib/Analysis/Analysis.cpp
@@ -86,8 +86,10 @@ LLVMBool LLVMVerifyModule(LLVMModuleRef M, LLVMVerifierFailureAction Action,
if (Action == LLVMAbortProcessAction && Result)
report_fatal_error("Broken module found, compilation aborted!");
- if (OutMessages)
- *OutMessages = strndup(MsgsOS.str().data(), MsgsOS.str().size());
+ if (OutMessages) {
+ MsgsOS << '\0';
+ *OutMessages = strdup(MsgsOS.str().data());
+ }
return Result;
}
diff --git a/llvm/lib/IR/Core.cpp b/llvm/lib/IR/Core.cpp
index bf936d6dc7e..779d8913045 100644
--- a/llvm/lib/IR/Core.cpp
+++ b/llvm/lib/IR/Core.cpp
@@ -62,9 +62,9 @@ void LLVMShutdown() {
/*===-- Error handling ----------------------------------------------------===*/
-static char *LLVMCreateMessage(StringRef Message) {
- assert(Message.find('\0') == Message.npos);
- return strndup(Message.data(), Message.size());
+static char *LLVMCreateMessage(string_ostream &OS) {
+ OS << '\0';
+ return strdup(OS.str().data());
}
char *LLVMCreateMessage(const char *Message) {
@@ -118,7 +118,7 @@ char *LLVMGetDiagInfoDescription(LLVMDiagnosticInfoRef DI) {
string_ostream Msg;
DiagnosticPrinterRawOStream DP(Msg);
unwrap(DI)->print(DP);
- return LLVMCreateMessage(Msg.str());
+ return LLVMCreateMessage(Msg);
}
LLVMDiagnosticSeverity LLVMGetDiagInfoSeverity(LLVMDiagnosticInfoRef DI){
@@ -204,7 +204,7 @@ LLVMBool LLVMPrintModuleToFile(LLVMModuleRef M, const char *Filename,
char *LLVMPrintModuleToString(LLVMModuleRef M) {
string_ostream os;
unwrap(M)->print(os, nullptr);
- return LLVMCreateMessage(os.str());
+ return LLVMCreateMessage(os);
}
/*--.. Operations on inline assembler ......................................--*/
@@ -282,7 +282,7 @@ char *LLVMPrintTypeToString(LLVMTypeRef Ty) {
else
os << "Printing <null> Type";
- return strndup(os.str().data(), os.str().size());
+ return LLVMCreateMessage(os);
}
/*--.. Operations on integer types .........................................--*/
@@ -533,7 +533,7 @@ char* LLVMPrintValueToString(LLVMValueRef Val) {
else
os << "Printing <null> Value";
- return strndup(os.str().data(), os.str().size());
+ return LLVMCreateMessage(os);
}
void LLVMReplaceAllUsesWith(LLVMValueRef OldVal, LLVMValueRef NewVal) {
diff --git a/llvm/lib/IRReader/IRReader.cpp b/llvm/lib/IRReader/IRReader.cpp
index 6d389d4dc45..e72990751b0 100644
--- a/llvm/lib/IRReader/IRReader.cpp
+++ b/llvm/lib/IRReader/IRReader.cpp
@@ -110,7 +110,8 @@ LLVMBool LLVMParseIRInContext(LLVMContextRef ContextRef,
if (OutMessage) {
string_ostream os;
Diag.print(nullptr, os, false);
- *OutMessage = strndup(os.str().data(), os.str().size());
+ os << '\0';
+ *OutMessage = strdup(os.str().data());
}
return 1;
}
OpenPOWER on IntegriCloud