Fixes to c++ backend for new and delete

Don't include declarations of malloc/free in the generated code (get
the standard ones from system headers instead).

Add a cast to (uint8_t *) before calls to malloc, which C++ requires,
since proper malloc returns a void *.
This commit is contained in:
Matt Pharr
2012-01-27 16:49:09 -08:00
parent 0f01a5dcbe
commit 12dc3f5c28

View File

@@ -2114,7 +2114,8 @@ bool CWriter::doInitialization(Module &M) {
I->getName() == "memset" || I->getName() == "memset_pattern16" ||
I->getName() == "puts" ||
I->getName() == "printf" || I->getName() == "putchar" ||
I->getName() == "fflush")
I->getName() == "fflush" || I->getName() == "malloc" ||
I->getName() == "free")
continue;
// Don't redeclare ispc's own intrinsics
@@ -3437,6 +3438,9 @@ void CWriter::visitCallInst(CallInst &I) {
Callee = RF;
}
if (Callee->getName() == "malloc")
Out << "(uint8_t *)";
if (NeedsCast) {
// Ok, just cast the pointer type.
Out << "((";