r194411 - Fix pr17875.

Rafael Espindola rafael.espindola at gmail.com
Mon Nov 11 11:35:06 PST 2013


Author: rafael
Date: Mon Nov 11 13:35:06 2013
New Revision: 194411

URL: http://llvm.org/viewvc/llvm-project?rev=194411&view=rev
Log:
Fix pr17875.

The assert this patch deletes was valid only when aliasing D2 to D1, not when
looking at a base class. Since the assert was in the path where we had already
decided to not produce an alias, just drop it.

Modified:
    cfe/trunk/lib/CodeGen/CGCXX.cpp
    cfe/trunk/test/CodeGenCXX/ctor-dtor-alias.cpp

Modified: cfe/trunk/lib/CodeGen/CGCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXX.cpp?rev=194411&r1=194410&r2=194411&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCXX.cpp Mon Nov 11 13:35:06 2013
@@ -150,10 +150,8 @@ bool CodeGenModule::TryEmitDefinitionAsA
     // Don't create an alias to a linker weak symbol unless we know we can do
     // that in every TU. This avoids producing different COMDATs in different
     // TUs.
-    if (llvm::GlobalValue::isWeakForLinker(TargetLinkage)) {
-      assert(Linkage == TargetLinkage);
+    if (llvm::GlobalValue::isWeakForLinker(TargetLinkage))
       return true;
-    }
   }
 
   // Create the alias with no name.

Modified: cfe/trunk/test/CodeGenCXX/ctor-dtor-alias.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/ctor-dtor-alias.cpp?rev=194411&r1=194410&r2=194411&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/ctor-dtor-alias.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/ctor-dtor-alias.cpp Mon Nov 11 13:35:06 2013
@@ -88,3 +88,18 @@ namespace test6 {
   B X;
   // CHECK-DAG: call i32 @__cxa_atexit({{.*}}@_ZN5test61AD2Ev
 }
+
+namespace test7 {
+  // Test that we don't produce an alias from ~B to ~A<int> (or crash figuring
+  // out if we should).
+  // pr17875.
+  // CHECK-DAG: define void @_ZN5test71BD2Ev
+  template <typename> struct A {
+    ~A() {}
+  };
+  class B : A<int> {
+    ~B();
+  };
+  template class A<int>;
+  B::~B() {}
+}





More information about the cfe-commits mailing list