diff options
| author | John McCall <rjmccall@apple.com> | 2011-09-10 01:16:55 +0000 |
|---|---|---|
| committer | John McCall <rjmccall@apple.com> | 2011-09-10 01:16:55 +0000 |
| commit | cd78e805e9c0d1a1b7ccbb67773aa51589c040f7 (patch) | |
| tree | 0d46a178933812aaad4d14ba3d3449b2397061fb /clang/lib/Sema/SemaExprCXX.cpp | |
| parent | a51d74fc35aafa7c609e950cfc6e39146a8280cb (diff) | |
| download | bcm5719-llvm-cd78e805e9c0d1a1b7ccbb67773aa51589c040f7.tar.gz bcm5719-llvm-cd78e805e9c0d1a1b7ccbb67773aa51589c040f7.zip | |
When converting a block pointer to an Objective-C pointer type, extend
the lifetime of the block by copying it to the heap, or else we'll get
a dangling reference because the code working with the non-block-typed
object will not know it needs to copy.
There is some danger here, e.g. with assigning a block literal to an
unsafe variable, but, well, it's an unsafe variable.
llvm-svn: 139451
Diffstat (limited to 'clang/lib/Sema/SemaExprCXX.cpp')
| -rw-r--r-- | clang/lib/Sema/SemaExprCXX.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index 1d903379c01..b8b722503a6 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -2388,6 +2388,15 @@ Sema::PerformImplicitConversion(Expr *From, QualType ToType, CXXCastPath BasePath; if (CheckPointerConversion(From, ToType, Kind, BasePath, CStyle)) return ExprError(); + + // Make sure we extend blocks if necessary. + // FIXME: doing this here is really ugly. + if (Kind == CK_BlockPointerToObjCPointerCast) { + ExprResult E = From; + (void) PrepareCastToObjCObjectPointer(E); + From = E.take(); + } + From = ImpCastExprToType(From, ToType, Kind, VK_RValue, &BasePath, CCK) .take(); break; |

