diff options
author | Ted Kremenek <kremenek@apple.com> | 2012-03-06 20:05:56 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2012-03-06 20:05:56 +0000 |
commit | ebcb57a8d298862c65043e88b2429591ab3c58d3 (patch) | |
tree | adbe4e0a60340ec2858e4b8d74d7bb0f23887d67 /lib/Sema/SemaExprCXX.cpp | |
parent | 9f86af897458b3b44e26b9e06a857f626f71a692 (diff) |
Add clang support for new Objective-C literal syntax for NSDictionary, NSArray,
NSNumber, and boolean literals. This includes both Sema and Codegen support.
Included is also support for new Objective-C container subscripting.
My apologies for the large patch. It was very difficult to break apart.
The patch introduces changes to the driver as well to cause clang to link
in additional runtime support when needed to support the new language features.
Docs are forthcoming to document the implementation and behavior of these features.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152137 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExprCXX.cpp')
-rw-r--r-- | lib/Sema/SemaExprCXX.cpp | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index f6662ba37f..dca7719894 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -4456,11 +4456,27 @@ ExprResult Sema::MaybeBindToTemporary(Expr *E) { } else if (isa<StmtExpr>(E)) { ReturnsRetained = true; + // We hit this case with the lambda conversion-to-block optimization; + // we don't want any extra casts here. + } else if (isa<CastExpr>(E) && + isa<BlockExpr>(cast<CastExpr>(E)->getSubExpr())) { + return Owned(E); + // For message sends and property references, we try to find an // actual method. FIXME: we should infer retention by selector in // cases where we don't have an actual method. - } else if (ObjCMessageExpr *Send = dyn_cast<ObjCMessageExpr>(E)) { - ObjCMethodDecl *D = Send->getMethodDecl(); + } else { + ObjCMethodDecl *D = 0; + if (ObjCMessageExpr *Send = dyn_cast<ObjCMessageExpr>(E)) { + D = Send->getMethodDecl(); + } else if (ObjCNumericLiteral *NumLit = dyn_cast<ObjCNumericLiteral>(E)) { + D = NumLit->getObjCNumericLiteralMethod(); + } else if (ObjCArrayLiteral *ArrayLit = dyn_cast<ObjCArrayLiteral>(E)) { + D = ArrayLit->getArrayWithObjectsMethod(); + } else if (ObjCDictionaryLiteral *DictLit + = dyn_cast<ObjCDictionaryLiteral>(E)) { + D = DictLit->getDictWithObjectsMethod(); + } ReturnsRetained = (D && D->hasAttr<NSReturnsRetainedAttr>()); @@ -4470,13 +4486,6 @@ ExprResult Sema::MaybeBindToTemporary(Expr *E) { if (!ReturnsRetained && D && D->getMethodFamily() == OMF_performSelector) return Owned(E); - } else if (isa<CastExpr>(E) && - isa<BlockExpr>(cast<CastExpr>(E)->getSubExpr())) { - // We hit this case with the lambda conversion-to-block optimization; - // we don't want any extra casts here. - return Owned(E); - } else { - ReturnsRetained = false; } // Don't reclaim an object of Class type. |