aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGDecl.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2011-07-09 09:09:00 +0000
committerJohn McCall <rjmccall@apple.com>2011-07-09 09:09:00 +0000
commit0850e8d1b093cfe1fc2fdf533a0e264ef9d5412e (patch)
treeefc3e4f42742aa4cddf0c233eb489f4bd02a086c /lib/CodeGen/CGDecl.cpp
parentf0733249ff54bf9397b0a0f696057921856e3eea (diff)
More compiler workarounds. I have to admit that I was not
expecting so much concentrated oddity on what seemed like a trivial feature. Thanks to François Pichet for doing the MSVC legwork here. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134813 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGDecl.cpp')
-rw-r--r--lib/CodeGen/CGDecl.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/CodeGen/CGDecl.cpp b/lib/CodeGen/CGDecl.cpp
index 3d9691d20a..ae9753b03d 100644
--- a/lib/CodeGen/CGDecl.cpp
+++ b/lib/CodeGen/CGDecl.cpp
@@ -1099,13 +1099,23 @@ void CodeGenFunction::EmitAutoVarCleanups(const AutoVarEmission &emission) {
CodeGenFunction::Destroyer &
CodeGenFunction::getDestroyer(QualType::DestructionKind kind) {
- // GCC 4.2 requires the *& on these function references.
+ // This is surprisingly compiler-dependent. GCC 4.2 can't bind
+ // references to functions directly in returns, and using '*&foo'
+ // confuses MSVC. Luckily, the following code pattern works in both.
+ Destroyer *destroyer = 0;
switch (kind) {
case QualType::DK_none: llvm_unreachable("no destroyer for trivial dtor");
- case QualType::DK_cxx_destructor: return *&destroyCXXObject;
- case QualType::DK_objc_strong_lifetime: return *&destroyARCStrongPrecise;
- case QualType::DK_objc_weak_lifetime: return *&destroyARCWeak;
+ case QualType::DK_cxx_destructor:
+ destroyer = &destroyCXXObject;
+ break;
+ case QualType::DK_objc_strong_lifetime:
+ destroyer = &destroyARCStrongPrecise;
+ break;
+ case QualType::DK_objc_weak_lifetime:
+ destroyer = &destroyARCWeak;
+ break;
}
+ return *destroyer;
}
void CodeGenFunction::pushDestroy(CleanupKind cleanupKind, llvm::Value *addr,