[cfe-commits] r155189 - in /cfe/trunk: lib/CodeGen/CGClass.cpp test/CodeGenCXX/microsoft-abi-constructors.cpp

Timur Iskhodzhanov timurrrr at google.com
Fri Apr 20 01:05:00 PDT 2012


Author: timurrrr
Date: Fri Apr 20 03:05:00 2012
New Revision: 155189

URL: http://llvm.org/viewvc/llvm-project?rev=155189&view=rev
Log:
Fix bug 12574 - Avoid infinite recursion in constructors and destructors when using Microsoft C++ ABI

Added:
    cfe/trunk/test/CodeGenCXX/microsoft-abi-constructors.cpp   (with props)
Modified:
    cfe/trunk/lib/CodeGen/CGClass.cpp

Modified: cfe/trunk/lib/CodeGen/CGClass.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=155189&r1=155188&r2=155189&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGClass.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGClass.cpp Fri Apr 20 03:05:00 2012
@@ -717,7 +717,8 @@
 
   // Before we go any further, try the complete->base constructor
   // delegation optimization.
-  if (CtorType == Ctor_Complete && IsConstructorDelegationValid(Ctor)) {
+  if (CtorType == Ctor_Complete && IsConstructorDelegationValid(Ctor) &&
+      CGM.getContext().getTargetInfo().getCXXABI() != CXXABI_Microsoft) {
     if (CGDebugInfo *DI = getDebugInfo()) 
       DI->EmitLocation(Builder, Ctor->getLocEnd());
     EmitDelegateCXXConstructorCall(Ctor, Ctor_Base, Args);
@@ -916,7 +917,7 @@
     // Enter the cleanup scopes for virtual bases.
     EnterDtorCleanups(Dtor, Dtor_Complete);
 
-    if (!isTryBody) {
+    if (!isTryBody && CGM.getContext().getTargetInfo().getCXXABI() != CXXABI_Microsoft) {
       EmitCXXDestructorCall(Dtor, Dtor_Base, /*ForVirtualBase=*/false,
                             LoadCXXThis());
       break;

Added: cfe/trunk/test/CodeGenCXX/microsoft-abi-constructors.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/microsoft-abi-constructors.cpp?rev=155189&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/microsoft-abi-constructors.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/microsoft-abi-constructors.cpp Fri Apr 20 03:05:00 2012
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -cxx-abi microsoft -triple=i386-pc-win32 | FileCheck %s
+
+class A {
+ public:
+  A() { }
+  ~A() { }
+};
+
+void no_contstructor_destructor_infinite_recursion() {
+  A a;
+
+// Make sure that the constructor doesn't call itself:
+// CHECK: define {{.*}} @"\01??0A@@QAE at XZ"
+// CHECK-NOT: call void @"\01??0A@@QAE at XZ"
+// CHECK: ret
+
+// Make sure that the destructor doesn't call itself:
+// CHECK: define {{.*}} @"\01??1A@@QAE at XZ"
+// CHECK-NOT: call void @"\01??1A@@QAE at XZ"
+// CHECK: ret
+}

Propchange: cfe/trunk/test/CodeGenCXX/microsoft-abi-constructors.cpp
------------------------------------------------------------------------------
    svn:eol-style = LF





More information about the cfe-commits mailing list