diff options
author | John McCall <rjmccall@apple.com> | 2011-07-09 09:09:00 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2011-07-09 09:09:00 +0000 |
commit | c2f0001c806d4c27cb8e7820e34a7f5e8a734921 (patch) | |
tree | 8e7a71c93c1ac98feee8f69ee1b1851a1007a20f /clang/lib/CodeGen/CGDecl.cpp | |
parent | ee24d32071baa4136a6c13de2ccd9ce1d1f24978 (diff) | |
download | bcm5719-llvm-c2f0001c806d4c27cb8e7820e34a7f5e8a734921.tar.gz bcm5719-llvm-c2f0001c806d4c27cb8e7820e34a7f5e8a734921.zip |
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.
llvm-svn: 134813
Diffstat (limited to 'clang/lib/CodeGen/CGDecl.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGDecl.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp index 3d9691d20a3..ae9753b03df 100644 --- a/clang/lib/CodeGen/CGDecl.cpp +++ b/clang/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, |