diff options
author | John McCall <rjmccall@apple.com> | 2012-07-31 05:14:30 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2012-07-31 05:14:30 +0000 |
commit | f253834456b24247aad1ddfdafad55bad668c0b6 (patch) | |
tree | 7ff7a74649075f26e4790acc350f8abe89a311bb /clang/lib/Sema/SemaExprObjC.cpp | |
parent | fb39f97d4cb1f59aeeb967e3b5fbad47847a8597 (diff) | |
download | bcm5719-llvm-f253834456b24247aad1ddfdafad55bad668c0b6.tar.gz bcm5719-llvm-f253834456b24247aad1ddfdafad55bad668c0b6.zip |
Introduce new queries on ObjCRuntime for how to interpret subscripts
on object pointers and whether pointer arithmetic on object pointers
is supported. Make ObjFW interpret subscripts as pseudo-objects.
Based on a patch by Jonathan Schleifer.
llvm-svn: 161028
Diffstat (limited to 'clang/lib/Sema/SemaExprObjC.cpp')
-rw-r--r-- | clang/lib/Sema/SemaExprObjC.cpp | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/clang/lib/Sema/SemaExprObjC.cpp b/clang/lib/Sema/SemaExprObjC.cpp index d57329b69ec..638a30f13a1 100644 --- a/clang/lib/Sema/SemaExprObjC.cpp +++ b/clang/lib/Sema/SemaExprObjC.cpp @@ -575,27 +575,33 @@ ExprResult Sema::BuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr) { return MaybeBindToTemporary(BoxedExpr); } +/// Build an ObjC subscript pseudo-object expression, given that +/// that's supported by the runtime. ExprResult Sema::BuildObjCSubscriptExpression(SourceLocation RB, Expr *BaseExpr, Expr *IndexExpr, ObjCMethodDecl *getterMethod, ObjCMethodDecl *setterMethod) { - // Subscripting is only supported in the non-fragile ABI. - if (LangOpts.ObjCRuntime.isFragile()) - return ExprError(); + assert(!LangOpts.ObjCRuntime.isSubscriptPointerArithmetic()); - // If the expression is type-dependent, there's nothing for us to do. - assert ((!BaseExpr->isTypeDependent() && !IndexExpr->isTypeDependent()) && - "base or index cannot have dependent type here"); + // We can't get dependent types here; our callers should have + // filtered them out. + assert((!BaseExpr->isTypeDependent() && !IndexExpr->isTypeDependent()) && + "base or index cannot have dependent type here"); + + // Filter out placeholders in the index. In theory, overloads could + // be preserved here, although that might not actually work correctly. ExprResult Result = CheckPlaceholderExpr(IndexExpr); if (Result.isInvalid()) return ExprError(); IndexExpr = Result.get(); - // Perform lvalue-to-rvalue conversion. + // Perform lvalue-to-rvalue conversion on the base. Result = DefaultLvalueConversion(BaseExpr); if (Result.isInvalid()) return ExprError(); BaseExpr = Result.get(); + + // Build the pseudo-object expression. return Owned(ObjCSubscriptRefExpr::Create(Context, BaseExpr, IndexExpr, |