[cfe-commits] r91251 - /cfe/trunk/lib/CodeGen/CGExprCXX.cpp

Anders Carlsson andersca at mac.com
Sun Dec 13 12:34:34 PST 2009


Author: andersca
Date: Sun Dec 13 14:34:34 2009
New Revision: 91251

URL: http://llvm.org/viewvc/llvm-project?rev=91251&view=rev
Log:
Don't use a cookie if the global placement new function is used.

Modified:
    cfe/trunk/lib/CodeGen/CGExprCXX.cpp

Modified: cfe/trunk/lib/CodeGen/CGExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprCXX.cpp?rev=91251&r1=91250&r2=91251&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprCXX.cpp Sun Dec 13 14:34:34 2009
@@ -64,6 +64,19 @@
   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 @@
   return NewPtr;
 }
 
-
 static std::pair<llvm::Value *, llvm::Value *>
 GetAllocatedObjectPtrAndNumElements(CodeGenFunction &CGF,
                                     llvm::Value *Ptr, QualType DeleteTy) {





More information about the cfe-commits mailing list