[cfe-commits] r146291 - in /cfe/trunk: lib/CodeGen/CGExprCXX.cpp test/CodeGenCXX/new.cpp

Eli Friedman eli.friedman at gmail.com
Fri Dec 9 15:05:37 PST 2011


Author: efriedma
Date: Fri Dec  9 17:05:37 2011
New Revision: 146291

URL: http://llvm.org/viewvc/llvm-project?rev=146291&view=rev
Log:
Make array new on a pointer to data member type work correctly.  PR11523.


Modified:
    cfe/trunk/lib/CodeGen/CGExprCXX.cpp
    cfe/trunk/test/CodeGenCXX/new.cpp

Modified: cfe/trunk/lib/CodeGen/CGExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprCXX.cpp?rev=146291&r1=146290&r2=146291&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprCXX.cpp Fri Dec  9 17:05:37 2011
@@ -828,7 +828,7 @@
   StoreAnyExprIntoOneUnit(*this, E, curPtr);
 
   // Leave the cleanup if we entered one.
-  if (cleanup != EHStack.stable_end()) {
+  if (cleanupDominator) {
     DeactivateCleanupBlock(cleanup, cleanupDominator);
     cleanupDominator->eraseFromParent();
   }
@@ -883,7 +883,8 @@
                                      RequiresZeroInitialization);
       return;
     } else if (E->getNumConstructorArgs() == 1 &&
-               isa<ImplicitValueInitExpr>(E->getConstructorArg(0))) {
+               isa<ImplicitValueInitExpr>(E->getConstructorArg(0)) &&
+               CGF.CGM.getTypes().isZeroInitializable(ElementType)) {
       // Optimization: since zero initialization will just set the memory
       // to all zeroes, generate a single memset to do it in one shot.
       EmitZeroMemSet(CGF, ElementType, NewPtr, AllocSizeWithoutCookie);

Modified: cfe/trunk/test/CodeGenCXX/new.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/new.cpp?rev=146291&r1=146290&r2=146291&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/new.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/new.cpp Fri Dec  9 17:05:37 2011
@@ -231,3 +231,11 @@
 
   template void f<int>();
 }
+
+namespace PR11523 {
+  class MyClass;
+  typedef int MyClass::* NewTy;
+  // CHECK: define i64* @_ZN7PR115231fEv
+  // CHECK: store i64 -1
+  NewTy* f() { return new NewTy[2](); }
+}





More information about the cfe-commits mailing list