diff options
author | Anders Carlsson <andersca@mac.com> | 2009-12-13 20:34:34 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-12-13 20:34:34 +0000 |
commit | 399f499f0c915991e8ea93fc6bded34805f16f7e (patch) | |
tree | 0fd9022d8960c81e8f6c7f3442d97e8866b6761b /clang/lib | |
parent | 8c17e6de2b291b006797f513b848dd7291332207 (diff) | |
download | bcm5719-llvm-399f499f0c915991e8ea93fc6bded34805f16f7e.tar.gz bcm5719-llvm-399f499f0c915991e8ea93fc6bded34805f16f7e.zip |
Don't use a cookie if the global placement new function is used.
llvm-svn: 91251
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/CodeGen/CGExprCXX.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGExprCXX.cpp b/clang/lib/CodeGen/CGExprCXX.cpp index c12ec1437f5..150f11ebf57 100644 --- a/clang/lib/CodeGen/CGExprCXX.cpp +++ b/clang/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) { |