[llvm] r211752 - MSVC build fix following r211749
Alp Toker
alp at nuanti.com
Wed Jun 25 17:25:42 PDT 2014
Author: alp
Date: Wed Jun 25 19:25:41 2014
New Revision: 211752
URL: http://llvm.org/viewvc/llvm-project?rev=211752&view=rev
Log:
MSVC build fix following r211749
Avoid strndup()
Modified:
llvm/trunk/lib/Analysis/Analysis.cpp
llvm/trunk/lib/IR/Core.cpp
llvm/trunk/lib/IRReader/IRReader.cpp
Modified: llvm/trunk/lib/Analysis/Analysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/Analysis.cpp?rev=211752&r1=211751&r2=211752&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/Analysis.cpp (original)
+++ llvm/trunk/lib/Analysis/Analysis.cpp Wed Jun 25 19:25:41 2014
@@ -86,8 +86,10 @@ LLVMBool LLVMVerifyModule(LLVMModuleRef
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;
}
Modified: llvm/trunk/lib/IR/Core.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Core.cpp?rev=211752&r1=211751&r2=211752&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Core.cpp (original)
+++ llvm/trunk/lib/IR/Core.cpp Wed Jun 25 19:25:41 2014
@@ -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(LLVMDia
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(LLVMModul
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
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(LLVMValueRe
else
os << "Printing <null> Value";
- return strndup(os.str().data(), os.str().size());
+ return LLVMCreateMessage(os);
}
void LLVMReplaceAllUsesWith(LLVMValueRef OldVal, LLVMValueRef NewVal) {
Modified: llvm/trunk/lib/IRReader/IRReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IRReader/IRReader.cpp?rev=211752&r1=211751&r2=211752&view=diff
==============================================================================
--- llvm/trunk/lib/IRReader/IRReader.cpp (original)
+++ llvm/trunk/lib/IRReader/IRReader.cpp Wed Jun 25 19:25:41 2014
@@ -110,7 +110,8 @@ LLVMBool LLVMParseIRInContext(LLVMContex
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;
}
More information about the llvm-commits
mailing list