From e6d509f2e09698df4e334b77596ca40e4899b2e4 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Wed, 6 Nov 2013 19:18:55 +0000 Subject: [PATCH] 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194158 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGCXX.cpp | 4 ++-- test/CodeGenCXX/microsoft-abi-structors-alias.cpp | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 test/CodeGenCXX/microsoft-abi-structors-alias.cpp diff --git a/lib/CodeGen/CGCXX.cpp b/lib/CodeGen/CGCXX.cpp index 15686f7ff6..eeedaf1064 100644 --- a/lib/CodeGen/CGCXX.cpp +++ b/lib/CodeGen/CGCXX.cpp @@ -146,13 +146,13 @@ bool CodeGenModule::TryEmitDefinitionAsAlias(GlobalDecl AliasDecl, 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. diff --git a/test/CodeGenCXX/microsoft-abi-structors-alias.cpp b/test/CodeGenCXX/microsoft-abi-structors-alias.cpp new file mode 100644 index 0000000000..d54520fab7 --- /dev/null +++ b/test/CodeGenCXX/microsoft-abi-structors-alias.cpp @@ -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 class A { + ~A() {} +}; +template class A; +// CHECK: define weak_odr x86_thiscallcc void @"\01??1?$A@D@test1@@AAE@XZ" +} -- 2.40.0