diff --git a/clang/lib/CodeGen/CGCXX.cpp b/clang/lib/CodeGen/CGCXX.cpp index 15686f7ff6ed..eeedaf106438 100644 --- a/clang/lib/CodeGen/CGCXX.cpp +++ b/clang/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/clang/test/CodeGenCXX/microsoft-abi-structors-alias.cpp b/clang/test/CodeGenCXX/microsoft-abi-structors-alias.cpp new file mode 100644 index 000000000000..d54520fab72c --- /dev/null +++ b/clang/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" +}