diff options
author | Jordan Rupprecht <rupprecht@google.com> | 2019-05-14 21:58:59 +0000 |
---|---|---|
committer | Jordan Rupprecht <rupprecht@google.com> | 2019-05-14 21:58:59 +0000 |
commit | b35a2aa71f76a334a9c98c0a3c3995b5d902d2b9 (patch) | |
tree | cdff4a5d1a715d4ad622fd8f190128b54bebe440 /lib/AST/ExprObjC.cpp | |
parent | 3748d41833787fcbf59cc5624e8d2b042a8991bc (diff) | |
parent | 741e05796da92b46d4f7bcbee00702ff37df6489 (diff) |
Creating branches/google/stable and tags/google/stable/2019-05-14 from r360103upstream/google/stable
git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/google/stable@360714 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/ExprObjC.cpp')
-rw-r--r-- | lib/AST/ExprObjC.cpp | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/lib/AST/ExprObjC.cpp b/lib/AST/ExprObjC.cpp index e1a23f5985..53d0e873f8 100644 --- a/lib/AST/ExprObjC.cpp +++ b/lib/AST/ExprObjC.cpp @@ -1,9 +1,8 @@ //===- ExprObjC.cpp - (ObjC) Expression AST Node Implementation -----------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // @@ -293,6 +292,32 @@ void ObjCMessageExpr::getSelectorLocs( SelLocs.push_back(getSelectorLoc(i)); } + +QualType ObjCMessageExpr::getCallReturnType(ASTContext &Ctx) const { + if (const ObjCMethodDecl *MD = getMethodDecl()) { + QualType QT = MD->getReturnType(); + if (QT == Ctx.getObjCInstanceType()) { + // instancetype corresponds to expression types. + return getType(); + } + return QT; + } + + // Expression type might be different from an expected call return type, + // as expression type would never be a reference even if call returns a + // reference. Reconstruct the original expression type. + QualType QT = getType(); + switch (getValueKind()) { + case VK_LValue: + return Ctx.getLValueReferenceType(QT); + case VK_XValue: + return Ctx.getRValueReferenceType(QT); + case VK_RValue: + return QT; + } + llvm_unreachable("Unsupported ExprValueKind"); +} + SourceRange ObjCMessageExpr::getReceiverRange() const { switch (getReceiverKind()) { case Instance: @@ -352,6 +377,11 @@ Stmt::child_range ObjCMessageExpr::children() { reinterpret_cast<Stmt **>(getArgs() + getNumArgs())); } +Stmt::const_child_range ObjCMessageExpr::children() const { + auto Children = const_cast<ObjCMessageExpr *>(this)->children(); + return const_child_range(Children.begin(), Children.end()); +} + StringRef ObjCBridgedCastExpr::getBridgeKindName() const { switch (getBridgeKind()) { case OBC_Bridge: |