diff options
author | David Majnemer <david.majnemer@gmail.com> | 2016-01-08 20:48:26 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2016-01-08 20:48:26 +0000 |
commit | d2385c08cfbb6d64d7a166aa38c1448159fcf923 (patch) | |
tree | 5f746426acab8b1a529ba715549a16aa0e83e32e /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | 728384a05ecf23ff3ede48ee6bf03fadfe09c726 (diff) | |
download | bcm5719-llvm-d2385c08cfbb6d64d7a166aa38c1448159fcf923.tar.gz bcm5719-llvm-d2385c08cfbb6d64d7a166aa38c1448159fcf923.zip |
[MS ABI] Complete and base constructor GlobalDecls must have the same name
Clang got itself into the situation where we mangled the same
constructor twice with two different constructor types. After one of
the constructors were utilized, the tag used for one of the types
changed from class to struct because a class template became complete.
This resulted in one of the constructor types varying from the other
constructor.
Instead, force "base" constructor types to "complete" if the ABI doesn't
have constructor variants. This will ensure that GlobalDecls for both
variants will get the same mangled name.
This fixes PR26029.
llvm-svn: 257205
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 536c55ae4e1..97b166278f8 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -615,7 +615,20 @@ void CodeGenModule::setTLSMode(llvm::GlobalValue *GV, const VarDecl &D) const { } StringRef CodeGenModule::getMangledName(GlobalDecl GD) { - StringRef &FoundStr = MangledDeclNames[GD.getCanonicalDecl()]; + GlobalDecl CanonicalGD = GD.getCanonicalDecl(); + + // Some ABIs don't have constructor variants. Make sure that base and + // complete constructors get mangled the same. + if (const auto *CD = dyn_cast<CXXConstructorDecl>(CanonicalGD.getDecl())) { + if (!getTarget().getCXXABI().hasConstructorVariants()) { + CXXCtorType OrigCtorType = GD.getCtorType(); + assert(OrigCtorType == Ctor_Base || OrigCtorType == Ctor_Complete); + if (OrigCtorType == Ctor_Base) + CanonicalGD = GlobalDecl(CD, Ctor_Complete); + } + } + + StringRef &FoundStr = MangledDeclNames[CanonicalGD]; if (!FoundStr.empty()) return FoundStr; |