r194158 - Fix the -cxx-abi microsoft -mconstructor-aliases combination.

Rafael Espindola rafael.espindola at gmail.com
Wed Nov 6 11:18:55 PST 2013


Author: rafael
Date: Wed Nov  6 13:18:55 2013
New Revision: 194158

URL: http://llvm.org/viewvc/llvm-project?rev=194158&view=rev
Log:
Fix the -cxx-abi microsoft -mconstructor-aliases combination.

On the microsoft ABI clang is producing one weak_odr and one linkonce_odr
destructor, which is reasonable since only one is required.

The fix is simply to move the assert past the special case treatment of
linkonce_odr.

Added:
    cfe/trunk/test/CodeGenCXX/microsoft-abi-structors-alias.cpp
Modified:
    cfe/trunk/lib/CodeGen/CGCXX.cpp

Modified: cfe/trunk/lib/CodeGen/CGCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXX.cpp?rev=194158&r1=194157&r2=194158&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCXX.cpp Wed Nov  6 13:18:55 2013
@@ -146,13 +146,13 @@ bool CodeGenModule::TryEmitDefinitionAsA
     if (!InEveryTU)
       return true;
 
-    assert(Linkage == TargetLinkage);
     // Instead of creating as alias to a linkonce_odr, replace all of the uses
     // of the aliassee.
-    if (TargetLinkage == llvm::GlobalValue::LinkOnceODRLinkage) {
+    if (Linkage == llvm::GlobalValue::LinkOnceODRLinkage) {
       Replacements[MangledName] = Aliasee;
       return false;
     }
+    assert(Linkage == TargetLinkage);
   }
 
   // Create the alias with no name.

Added: cfe/trunk/test/CodeGenCXX/microsoft-abi-structors-alias.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/microsoft-abi-structors-alias.cpp?rev=194158&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/microsoft-abi-structors-alias.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/microsoft-abi-structors-alias.cpp Wed Nov  6 13:18:55 2013
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -cxx-abi microsoft -triple=i386-pc-win32 -fno-rtti -mconstructor-aliases | FileCheck %s
+
+namespace test1 {
+template <typename T> class A {
+  ~A() {}
+};
+template class A<char>;
+// CHECK: define weak_odr x86_thiscallcc void @"\01??1?$A at D@test1@@AAE at XZ"
+}





More information about the cfe-commits mailing list