summaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGCXX.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2014-05-16 19:35:48 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2014-05-16 19:35:48 +0000
commit70c7eda21fd736f29ed4132cdcc656228d6ea952 (patch)
tree9972b6f8ecaf4b66fc7e2a8345e27d147db7d02d /lib/CodeGen/CGCXX.cpp
parent2cfcfd2aa5481b00614edcdf8399c6ffa3937bba (diff)
downloadclang-70c7eda21fd736f29ed4132cdcc656228d6ea952.tar.gz
clang-70c7eda21fd736f29ed4132cdcc656228d6ea952.tar.bz2
clang-70c7eda21fd736f29ed4132cdcc656228d6ea952.tar.xz
Update for llvm api change.
Now that llvm cannot represent alias cycles, we have to diagnose erros just before trying to close the cycle. This degrades the errors a bit. The real solution is what it was before: if we want to provide good errors for these cases, we have to be able to find a clang level decl given a mangled name and produce the error from Sema. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209008 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGCXX.cpp')
-rw-r--r--lib/CodeGen/CGCXX.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/CodeGen/CGCXX.cpp b/lib/CodeGen/CGCXX.cpp
index 08b74a3c30..0a73550c7a 100644
--- a/lib/CodeGen/CGCXX.cpp
+++ b/lib/CodeGen/CGCXX.cpp
@@ -138,12 +138,12 @@ bool CodeGenModule::TryEmitDefinitionAsAlias(GlobalDecl AliasDecl,
// which case the caller is responsible for ensuring the soundness
// of these semantics.
auto *Ref = cast<llvm::GlobalValue>(GetAddrOfGlobal(TargetDecl));
- llvm::Constant *Aliasee = Ref;
- if (Ref->getType() != AliasType)
- Aliasee = llvm::ConstantExpr::getBitCast(Ref, AliasType);
+ auto *Aliasee = dyn_cast<llvm::GlobalObject>(Ref);
+ if (!Aliasee)
+ Aliasee = cast<llvm::GlobalAlias>(Ref)->getAliasee();
// Instead of creating as alias to a linkonce_odr, replace all of the uses
- // of the aliassee.
+ // of the aliasee.
if (llvm::GlobalValue::isDiscardableIfUnused(Linkage) &&
(TargetLinkage != llvm::GlobalValue::AvailableExternallyLinkage ||
!TargetDecl.getDecl()->hasAttr<AlwaysInlineAttr>())) {
@@ -152,7 +152,10 @@ bool CodeGenModule::TryEmitDefinitionAsAlias(GlobalDecl AliasDecl,
// members with attribute "AlwaysInline" and expect no reference to
// be generated. It is desirable to reenable this optimisation after
// corresponding LLVM changes.
- Replacements[MangledName] = Aliasee;
+ llvm::Constant *Replacement = Aliasee;
+ if (Aliasee->getType() != AliasType)
+ Replacement = llvm::ConstantExpr::getBitCast(Aliasee, AliasType);
+ Replacements[MangledName] = Replacement;
return false;
}
@@ -160,7 +163,7 @@ bool CodeGenModule::TryEmitDefinitionAsAlias(GlobalDecl AliasDecl,
/// If we don't have a definition for the destructor yet, don't
/// emit. We can't emit aliases to declarations; that's just not
/// how aliases work.
- if (Ref->isDeclaration())
+ if (Aliasee->isDeclaration())
return true;
}