aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-12-13 20:34:34 +0000
committerAnders Carlsson <andersca@mac.com>2009-12-13 20:34:34 +0000
commitdd9375513db874caadaeff62ef10becbe32bd7fb (patch)
tree4c492a4c64c93df1806db515712bfeea2141f10c
parent710f7058400e0e5accae0ce92e9c1fbfd0c15232 (diff)
Don't use a cookie if the global placement new function is used.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91251 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/CGExprCXX.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/CodeGen/CGExprCXX.cpp b/lib/CodeGen/CGExprCXX.cpp
index c12ec1437f..150f11ebf5 100644
--- a/lib/CodeGen/CGExprCXX.cpp
+++ b/lib/CodeGen/CGExprCXX.cpp
@@ -64,6 +64,19 @@ static uint64_t CalculateCookiePadding(ASTContext &Ctx, const CXXNewExpr *E) {
if (!E->isArray())
return 0;
+ // No cookie is required if the new operator being used is
+ // ::operator new[](size_t, void*).
+ const FunctionDecl *OperatorNew = E->getOperatorNew();
+ if (OperatorNew->getDeclContext()->getLookupContext()->isFileContext()) {
+ if (OperatorNew->getNumParams() == 2) {
+ CanQualType ParamType =
+ Ctx.getCanonicalType(OperatorNew->getParamDecl(1)->getType());
+
+ if (ParamType == Ctx.VoidPtrTy)
+ return 0;
+ }
+ }
+
return CalculateCookiePadding(Ctx, E->getAllocatedType());
QualType T = E->getAllocatedType();
}
@@ -265,7 +278,6 @@ llvm::Value *CodeGenFunction::EmitCXXNewExpr(const CXXNewExpr *E) {
return NewPtr;
}
-
static std::pair<llvm::Value *, llvm::Value *>
GetAllocatedObjectPtrAndNumElements(CodeGenFunction &CGF,
llvm::Value *Ptr, QualType DeleteTy) {