aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/clang/lib/Sema/SemaExprObjC.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2021-08-22 19:00:43 +0000
committerDimitry Andric <dim@FreeBSD.org>2021-11-13 20:39:49 +0000
commitfe6060f10f634930ff71b7c50291ddc610da2475 (patch)
tree1483580c790bd4d27b6500a7542b5ee00534d3cc /contrib/llvm-project/clang/lib/Sema/SemaExprObjC.cpp
parentb61bce17f346d79cecfd8f195a64b10f77be43b1 (diff)
parent344a3780b2e33f6ca763666c380202b18aab72a3 (diff)
Diffstat (limited to 'contrib/llvm-project/clang/lib/Sema/SemaExprObjC.cpp')
-rw-r--r--contrib/llvm-project/clang/lib/Sema/SemaExprObjC.cpp30
1 files changed, 17 insertions, 13 deletions
diff --git a/contrib/llvm-project/clang/lib/Sema/SemaExprObjC.cpp b/contrib/llvm-project/clang/lib/Sema/SemaExprObjC.cpp
index f5456ee0711e..8a9c933fc93f 100644
--- a/contrib/llvm-project/clang/lib/Sema/SemaExprObjC.cpp
+++ b/contrib/llvm-project/clang/lib/Sema/SemaExprObjC.cpp
@@ -1786,7 +1786,7 @@ bool Sema::CheckMessageArgumentTypes(
} else {
ReturnType = Context.getObjCIdType();
}
- VK = VK_RValue;
+ VK = VK_PRValue;
return false;
}
@@ -1821,7 +1821,8 @@ bool Sema::CheckMessageArgumentTypes(
ParmVarDecl *param = Method->parameters()[i];
assert(argExpr && "CheckMessageArgumentTypes(): missing expression");
- if (param->hasAttr<NoEscapeAttr>())
+ if (param->hasAttr<NoEscapeAttr>() &&
+ param->getType()->isBlockPointerType())
if (auto *BE = dyn_cast<BlockExpr>(
argExpr->IgnoreParenNoopCasts(Context)))
BE->getBlockDecl()->setDoesNotEscape();
@@ -1872,7 +1873,7 @@ bool Sema::CheckMessageArgumentTypes(
// If we are type-erasing a block to a block-compatible
// Objective-C pointer type, we may need to extend the lifetime
// of the block object.
- if (typeArgs && Args[i]->isRValue() && paramType->isBlockPointerType() &&
+ if (typeArgs && Args[i]->isPRValue() && paramType->isBlockPointerType() &&
Args[i]->getType()->isBlockPointerType() &&
origParamType->isObjCObjectPointerType()) {
ExprResult arg = Args[i];
@@ -2633,7 +2634,7 @@ ExprResult Sema::BuildClassMessage(TypeSourceInfo *ReceiverTypeInfo,
Expr **Args = ArgsIn.data();
assert(SuperLoc.isInvalid() && "Message to super with dependent type");
return ObjCMessageExpr::Create(
- Context, ReceiverType, VK_RValue, LBracLoc, ReceiverTypeInfo, Sel,
+ Context, ReceiverType, VK_PRValue, LBracLoc, ReceiverTypeInfo, Sel,
SelectorLocs, /*Method=*/nullptr, makeArrayRef(Args, NumArgs), RBracLoc,
isImplicit);
}
@@ -2681,7 +2682,7 @@ ExprResult Sema::BuildClassMessage(TypeSourceInfo *ReceiverTypeInfo,
// Check the argument types and determine the result type.
QualType ReturnType;
- ExprValueKind VK = VK_RValue;
+ ExprValueKind VK = VK_PRValue;
unsigned NumArgs = ArgsIn.size();
Expr **Args = ArgsIn.data();
@@ -2886,7 +2887,7 @@ ExprResult Sema::BuildInstanceMessage(Expr *Receiver,
Expr **Args = ArgsIn.data();
assert(SuperLoc.isInvalid() && "Message to super with dependent type");
return ObjCMessageExpr::Create(
- Context, Context.DependentTy, VK_RValue, LBracLoc, Receiver, Sel,
+ Context, Context.DependentTy, VK_PRValue, LBracLoc, Receiver, Sel,
SelectorLocs, /*Method=*/nullptr, makeArrayRef(Args, NumArgs),
RBracLoc, isImplicit);
}
@@ -3225,7 +3226,7 @@ ExprResult Sema::BuildInstanceMessage(Expr *Receiver,
unsigned NumArgs = ArgsIn.size();
Expr **Args = ArgsIn.data();
QualType ReturnType;
- ExprValueKind VK = VK_RValue;
+ ExprValueKind VK = VK_PRValue;
bool ClassMessage = (ReceiverType->isObjCClassType() ||
ReceiverType->isObjCQualifiedClassType());
if (CheckMessageArgumentTypes(Receiver, ReceiverType,
@@ -3847,9 +3848,12 @@ static inline T *getObjCBridgeAttr(const TypedefType *TD) {
QualType QT = TDNDecl->getUnderlyingType();
if (QT->isPointerType()) {
QT = QT->getPointeeType();
- if (const RecordType *RT = QT->getAs<RecordType>())
- if (RecordDecl *RD = RT->getDecl()->getMostRecentDecl())
- return RD->getAttr<T>();
+ if (const RecordType *RT = QT->getAs<RecordType>()) {
+ for (auto *Redecl : RT->getDecl()->getMostRecentDecl()->redecls()) {
+ if (auto *attr = Redecl->getAttr<T>())
+ return attr;
+ }
+ }
}
return nullptr;
}
@@ -4469,7 +4473,7 @@ Sema::CheckObjCConversion(SourceRange castRange, QualType castType,
case ACC_plusOne:
castExpr = ImplicitCastExpr::Create(Context, castExpr->getType(),
CK_ARCConsumeObject, castExpr, nullptr,
- VK_RValue, FPOptionsOverride());
+ VK_PRValue, FPOptionsOverride());
Cleanup.setExprNeedsCleanups(true);
return ACR_okay;
}
@@ -4696,7 +4700,7 @@ ExprResult Sema::BuildObjCBridgedCast(SourceLocation LParenLoc,
case OBC_BridgeRetained:
// Produce the object before casting it.
SubExpr = ImplicitCastExpr::Create(Context, FromType, CK_ARCProduceObject,
- SubExpr, nullptr, VK_RValue,
+ SubExpr, nullptr, VK_PRValue,
FPOptionsOverride());
break;
@@ -4736,7 +4740,7 @@ ExprResult Sema::BuildObjCBridgedCast(SourceLocation LParenLoc,
if (MustConsume) {
Cleanup.setExprNeedsCleanups(true);
Result = ImplicitCastExpr::Create(Context, T, CK_ARCConsumeObject, Result,
- nullptr, VK_RValue, FPOptionsOverride());
+ nullptr, VK_PRValue, FPOptionsOverride());
}
return Result;