forked from OSchip/llvm-project
[clang] NFC: change uses of `Expr->getValueKind` into `is?Value`
Signed-off-by: Matheus Izvekov <mizvekov@gmail.com> Reviewed By: rsmith Differential Revision: https://reviews.llvm.org/D100733
This commit is contained in:
parent
ce2a5fa72b
commit
4819b751bd
|
@ -4528,9 +4528,7 @@ public:
|
||||||
|
|
||||||
/// Determine whether this materialized temporary is bound to an
|
/// Determine whether this materialized temporary is bound to an
|
||||||
/// lvalue reference; otherwise, it's bound to an rvalue reference.
|
/// lvalue reference; otherwise, it's bound to an rvalue reference.
|
||||||
bool isBoundToLvalueReference() const {
|
bool isBoundToLvalueReference() const { return isLValue(); }
|
||||||
return getValueKind() == VK_LValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Determine whether this temporary object is usable in constant
|
/// Determine whether this temporary object is usable in constant
|
||||||
/// expressions, as specified in C++20 [expr.const]p4.
|
/// expressions, as specified in C++20 [expr.const]p4.
|
||||||
|
|
|
@ -2406,7 +2406,7 @@ bool Expr::isReadIfDiscardedInCPlusPlus11() const {
|
||||||
// In C++11, discarded-value expressions of a certain form are special,
|
// In C++11, discarded-value expressions of a certain form are special,
|
||||||
// according to [expr]p10:
|
// according to [expr]p10:
|
||||||
// The lvalue-to-rvalue conversion (4.1) is applied only if the
|
// The lvalue-to-rvalue conversion (4.1) is applied only if the
|
||||||
// expression is an lvalue of volatile-qualified type and it has
|
// expression is a glvalue of volatile-qualified type and it has
|
||||||
// one of the following forms:
|
// one of the following forms:
|
||||||
if (!isGLValue() || !getType().isVolatileQualified())
|
if (!isGLValue() || !getType().isVolatileQualified())
|
||||||
return false;
|
return false;
|
||||||
|
@ -3874,8 +3874,7 @@ Expr::isNullPointerConstant(ASTContext &Ctx,
|
||||||
const ObjCPropertyRefExpr *Expr::getObjCProperty() const {
|
const ObjCPropertyRefExpr *Expr::getObjCProperty() const {
|
||||||
const Expr *E = this;
|
const Expr *E = this;
|
||||||
while (true) {
|
while (true) {
|
||||||
assert((E->getValueKind() == VK_LValue &&
|
assert((E->isLValue() && E->getObjectKind() == OK_ObjCProperty) &&
|
||||||
E->getObjectKind() == OK_ObjCProperty) &&
|
|
||||||
"expression is not a property reference");
|
"expression is not a property reference");
|
||||||
E = E->IgnoreParenCasts();
|
E = E->IgnoreParenCasts();
|
||||||
if (const BinaryOperator *BO = dyn_cast<BinaryOperator>(E)) {
|
if (const BinaryOperator *BO = dyn_cast<BinaryOperator>(E)) {
|
||||||
|
@ -3914,7 +3913,7 @@ FieldDecl *Expr::getSourceBitField() {
|
||||||
|
|
||||||
while (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(E)) {
|
while (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(E)) {
|
||||||
if (ICE->getCastKind() == CK_LValueToRValue ||
|
if (ICE->getCastKind() == CK_LValueToRValue ||
|
||||||
(ICE->getValueKind() != VK_PRValue && ICE->getCastKind() == CK_NoOp))
|
(ICE->isGLValue() && ICE->getCastKind() == CK_NoOp))
|
||||||
E = ICE->getSubExpr()->IgnoreParens();
|
E = ICE->getSubExpr()->IgnoreParens();
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
|
@ -3961,7 +3960,7 @@ bool Expr::refersToVectorElement() const {
|
||||||
const Expr *E = this->IgnoreParens();
|
const Expr *E = this->IgnoreParens();
|
||||||
|
|
||||||
while (const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(E)) {
|
while (const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(E)) {
|
||||||
if (ICE->getValueKind() != VK_PRValue && ICE->getCastKind() == CK_NoOp)
|
if (ICE->isGLValue() && ICE->getCastKind() == CK_NoOp)
|
||||||
E = ICE->getSubExpr()->IgnoreParens();
|
E = ICE->getSubExpr()->IgnoreParens();
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -53,8 +53,12 @@ Cl Expr::ClassifyImpl(ASTContext &Ctx, SourceLocation *Loc) const {
|
||||||
|
|
||||||
// Enable this assertion for testing.
|
// Enable this assertion for testing.
|
||||||
switch (kind) {
|
switch (kind) {
|
||||||
case Cl::CL_LValue: assert(getValueKind() == VK_LValue); break;
|
case Cl::CL_LValue:
|
||||||
case Cl::CL_XValue: assert(getValueKind() == VK_XValue); break;
|
assert(isLValue());
|
||||||
|
break;
|
||||||
|
case Cl::CL_XValue:
|
||||||
|
assert(isXValue());
|
||||||
|
break;
|
||||||
case Cl::CL_Function:
|
case Cl::CL_Function:
|
||||||
case Cl::CL_Void:
|
case Cl::CL_Void:
|
||||||
case Cl::CL_AddressableVoid:
|
case Cl::CL_AddressableVoid:
|
||||||
|
@ -65,7 +69,7 @@ Cl Expr::ClassifyImpl(ASTContext &Ctx, SourceLocation *Loc) const {
|
||||||
case Cl::CL_ArrayTemporary:
|
case Cl::CL_ArrayTemporary:
|
||||||
case Cl::CL_ObjCMessageRValue:
|
case Cl::CL_ObjCMessageRValue:
|
||||||
case Cl::CL_PRValue:
|
case Cl::CL_PRValue:
|
||||||
assert(getValueKind() == VK_PRValue);
|
assert(isPRValue());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -714,10 +714,10 @@ static bool tryEmitARCCopyWeakInit(CodeGenFunction &CGF,
|
||||||
}
|
}
|
||||||
|
|
||||||
// If it was an l-value, use objc_copyWeak.
|
// If it was an l-value, use objc_copyWeak.
|
||||||
if (srcExpr->getValueKind() == VK_LValue) {
|
if (srcExpr->isLValue()) {
|
||||||
CGF.EmitARCCopyWeak(destLV.getAddress(CGF), srcAddr);
|
CGF.EmitARCCopyWeak(destLV.getAddress(CGF), srcAddr);
|
||||||
} else {
|
} else {
|
||||||
assert(srcExpr->getValueKind() == VK_XValue);
|
assert(srcExpr->isXValue());
|
||||||
CGF.EmitARCMoveWeak(destLV.getAddress(CGF), srcAddr);
|
CGF.EmitARCMoveWeak(destLV.getAddress(CGF), srcAddr);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -1965,7 +1965,7 @@ bool CodeGenFunction::ShouldNullCheckClassCastValue(const CastExpr *CE) {
|
||||||
|
|
||||||
if (const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(CE)) {
|
if (const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(CE)) {
|
||||||
// And that glvalue casts are never null.
|
// And that glvalue casts are never null.
|
||||||
if (ICE->getValueKind() != VK_PRValue)
|
if (ICE->isGLValue())
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -632,7 +632,7 @@ ExprResult Sema::ImpCastExprToType(Expr *E, QualType Ty,
|
||||||
if (Kind == CK_ArrayToPointerDecay) {
|
if (Kind == CK_ArrayToPointerDecay) {
|
||||||
// C++1z [conv.array]: The temporary materialization conversion is applied.
|
// C++1z [conv.array]: The temporary materialization conversion is applied.
|
||||||
// We also use this to fuel C++ DR1213, which applies to C++11 onwards.
|
// We also use this to fuel C++ DR1213, which applies to C++11 onwards.
|
||||||
if (getLangOpts().CPlusPlus && E->getValueKind() == VK_PRValue) {
|
if (getLangOpts().CPlusPlus && E->isPRValue()) {
|
||||||
// The temporary is an lvalue in C++98 and an xvalue otherwise.
|
// The temporary is an lvalue in C++98 and an xvalue otherwise.
|
||||||
ExprResult Materialized = CreateMaterializeTemporaryExpr(
|
ExprResult Materialized = CreateMaterializeTemporaryExpr(
|
||||||
E->getType(), E, !getLangOpts().CPlusPlus11);
|
E->getType(), E, !getLangOpts().CPlusPlus11);
|
||||||
|
|
|
@ -877,7 +877,7 @@ ExprResult Sema::BuildResolvedCoawaitExpr(SourceLocation Loc, Expr *E,
|
||||||
|
|
||||||
// If the expression is a temporary, materialize it as an lvalue so that we
|
// If the expression is a temporary, materialize it as an lvalue so that we
|
||||||
// can use it multiple times.
|
// can use it multiple times.
|
||||||
if (E->getValueKind() == VK_PRValue)
|
if (E->isPRValue())
|
||||||
E = CreateMaterializeTemporaryExpr(E->getType(), E, true);
|
E = CreateMaterializeTemporaryExpr(E->getType(), E, true);
|
||||||
|
|
||||||
// The location of the `co_await` token cannot be used when constructing
|
// The location of the `co_await` token cannot be used when constructing
|
||||||
|
@ -937,7 +937,7 @@ ExprResult Sema::BuildCoyieldExpr(SourceLocation Loc, Expr *E) {
|
||||||
|
|
||||||
// If the expression is a temporary, materialize it as an lvalue so that we
|
// If the expression is a temporary, materialize it as an lvalue so that we
|
||||||
// can use it multiple times.
|
// can use it multiple times.
|
||||||
if (E->getValueKind() == VK_PRValue)
|
if (E->isPRValue())
|
||||||
E = CreateMaterializeTemporaryExpr(E->getType(), E, true);
|
E = CreateMaterializeTemporaryExpr(E->getType(), E, true);
|
||||||
|
|
||||||
// Build the await_ready, await_suspend, await_resume calls.
|
// Build the await_ready, await_suspend, await_resume calls.
|
||||||
|
|
|
@ -5546,7 +5546,7 @@ Sema::CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc,
|
||||||
BaseExpr = LHSExp; // vectors: V[123]
|
BaseExpr = LHSExp; // vectors: V[123]
|
||||||
IndexExpr = RHSExp;
|
IndexExpr = RHSExp;
|
||||||
// We apply C++ DR1213 to vector subscripting too.
|
// We apply C++ DR1213 to vector subscripting too.
|
||||||
if (getLangOpts().CPlusPlus11 && LHSExp->getValueKind() == VK_PRValue) {
|
if (getLangOpts().CPlusPlus11 && LHSExp->isPRValue()) {
|
||||||
ExprResult Materialized = TemporaryMaterializationConversion(LHSExp);
|
ExprResult Materialized = TemporaryMaterializationConversion(LHSExp);
|
||||||
if (Materialized.isInvalid())
|
if (Materialized.isInvalid())
|
||||||
return ExprError();
|
return ExprError();
|
||||||
|
@ -10159,7 +10159,7 @@ QualType Sema::CheckVectorOperands(ExprResult &LHS, ExprResult &RHS,
|
||||||
RHSType, DiagID))
|
RHSType, DiagID))
|
||||||
return RHSType;
|
return RHSType;
|
||||||
} else {
|
} else {
|
||||||
if (LHS.get()->getValueKind() == VK_LValue ||
|
if (LHS.get()->isLValue() ||
|
||||||
!tryGCCVectorConvertAndSplat(*this, &LHS, &RHS))
|
!tryGCCVectorConvertAndSplat(*this, &LHS, &RHS))
|
||||||
return RHSType;
|
return RHSType;
|
||||||
}
|
}
|
||||||
|
@ -14939,7 +14939,7 @@ ExprResult Sema::CreateBuiltinUnaryOp(SourceLocation OpLoc,
|
||||||
// complex l-values to ordinary l-values and all other values to r-values.
|
// complex l-values to ordinary l-values and all other values to r-values.
|
||||||
if (Input.isInvalid()) return ExprError();
|
if (Input.isInvalid()) return ExprError();
|
||||||
if (Opc == UO_Real || Input.get()->getType()->isAnyComplexType()) {
|
if (Opc == UO_Real || Input.get()->getType()->isAnyComplexType()) {
|
||||||
if (Input.get()->getValueKind() != VK_PRValue &&
|
if (Input.get()->isGLValue() &&
|
||||||
Input.get()->getObjectKind() == OK_Ordinary)
|
Input.get()->getObjectKind() == OK_Ordinary)
|
||||||
VK = Input.get()->getValueKind();
|
VK = Input.get()->getValueKind();
|
||||||
} else if (!getLangOpts().CPlusPlus) {
|
} else if (!getLangOpts().CPlusPlus) {
|
||||||
|
@ -19176,7 +19176,7 @@ namespace {
|
||||||
Expr *SubExpr = SubResult.get();
|
Expr *SubExpr = SubResult.get();
|
||||||
E->setSubExpr(SubExpr);
|
E->setSubExpr(SubExpr);
|
||||||
E->setType(S.Context.getPointerType(SubExpr->getType()));
|
E->setType(S.Context.getPointerType(SubExpr->getType()));
|
||||||
assert(E->getValueKind() == VK_PRValue);
|
assert(E->isPRValue());
|
||||||
assert(E->getObjectKind() == OK_Ordinary);
|
assert(E->getObjectKind() == OK_Ordinary);
|
||||||
return E;
|
return E;
|
||||||
}
|
}
|
||||||
|
@ -19186,7 +19186,7 @@ namespace {
|
||||||
|
|
||||||
E->setType(VD->getType());
|
E->setType(VD->getType());
|
||||||
|
|
||||||
assert(E->getValueKind() == VK_PRValue);
|
assert(E->isPRValue());
|
||||||
if (S.getLangOpts().CPlusPlus &&
|
if (S.getLangOpts().CPlusPlus &&
|
||||||
!(isa<CXXMethodDecl>(VD) &&
|
!(isa<CXXMethodDecl>(VD) &&
|
||||||
cast<CXXMethodDecl>(VD)->isInstance()))
|
cast<CXXMethodDecl>(VD)->isInstance()))
|
||||||
|
@ -19277,7 +19277,7 @@ namespace {
|
||||||
return ExprError();
|
return ExprError();
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(E->getValueKind() == VK_PRValue);
|
assert(E->isPRValue());
|
||||||
assert(E->getObjectKind() == OK_Ordinary);
|
assert(E->getObjectKind() == OK_Ordinary);
|
||||||
E->setType(DestType);
|
E->setType(DestType);
|
||||||
|
|
||||||
|
@ -19437,7 +19437,7 @@ ExprResult RebuildUnknownAnyExpr::VisitObjCMessageExpr(ObjCMessageExpr *E) {
|
||||||
ExprResult RebuildUnknownAnyExpr::VisitImplicitCastExpr(ImplicitCastExpr *E) {
|
ExprResult RebuildUnknownAnyExpr::VisitImplicitCastExpr(ImplicitCastExpr *E) {
|
||||||
// The only case we should ever see here is a function-to-pointer decay.
|
// The only case we should ever see here is a function-to-pointer decay.
|
||||||
if (E->getCastKind() == CK_FunctionToPointerDecay) {
|
if (E->getCastKind() == CK_FunctionToPointerDecay) {
|
||||||
assert(E->getValueKind() == VK_PRValue);
|
assert(E->isPRValue());
|
||||||
assert(E->getObjectKind() == OK_Ordinary);
|
assert(E->getObjectKind() == OK_Ordinary);
|
||||||
|
|
||||||
E->setType(DestType);
|
E->setType(DestType);
|
||||||
|
@ -19451,7 +19451,7 @@ ExprResult RebuildUnknownAnyExpr::VisitImplicitCastExpr(ImplicitCastExpr *E) {
|
||||||
E->setSubExpr(Result.get());
|
E->setSubExpr(Result.get());
|
||||||
return E;
|
return E;
|
||||||
} else if (E->getCastKind() == CK_LValueToRValue) {
|
} else if (E->getCastKind() == CK_LValueToRValue) {
|
||||||
assert(E->getValueKind() == VK_PRValue);
|
assert(E->isPRValue());
|
||||||
assert(E->getObjectKind() == OK_Ordinary);
|
assert(E->getObjectKind() == OK_Ordinary);
|
||||||
|
|
||||||
assert(isa<BlockPointerType>(E->getType()));
|
assert(isa<BlockPointerType>(E->getType()));
|
||||||
|
|
|
@ -6897,7 +6897,7 @@ ExprResult Sema::MaybeBindToTemporary(Expr *E) {
|
||||||
assert(!isa<CXXBindTemporaryExpr>(E) && "Double-bound temporary?");
|
assert(!isa<CXXBindTemporaryExpr>(E) && "Double-bound temporary?");
|
||||||
|
|
||||||
// If the result is a glvalue, we shouldn't bind it.
|
// If the result is a glvalue, we shouldn't bind it.
|
||||||
if (!E->isPRValue())
|
if (E->isGLValue())
|
||||||
return E;
|
return E;
|
||||||
|
|
||||||
// In ARC, calls that return a retainable type can return retained,
|
// In ARC, calls that return a retainable type can return retained,
|
||||||
|
|
|
@ -5832,7 +5832,7 @@ void InitializationSequence::InitializeFrom(Sema &S,
|
||||||
Entity.getType()) &&
|
Entity.getType()) &&
|
||||||
canPerformArrayCopy(Entity)) {
|
canPerformArrayCopy(Entity)) {
|
||||||
// If source is a prvalue, use it directly.
|
// If source is a prvalue, use it directly.
|
||||||
if (Initializer->getValueKind() == VK_PRValue) {
|
if (Initializer->isPRValue()) {
|
||||||
AddArrayInitStep(DestType, /*IsGNUExtension*/false);
|
AddArrayInitStep(DestType, /*IsGNUExtension*/false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue