Skip to content

Commit 4819b75

Browse files
committed
[clang] NFC: change uses of Expr->getValueKind into is?Value
Signed-off-by: Matheus Izvekov <[email protected]> Reviewed By: rsmith Differential Revision: https://reviews.llvm.org/D100733
1 parent ce2a5fa commit 4819b75

File tree

10 files changed

+28
-27
lines changed

10 files changed

+28
-27
lines changed

clang/include/clang/AST/ExprCXX.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4528,9 +4528,7 @@ class MaterializeTemporaryExpr : public Expr {
45284528

45294529
/// Determine whether this materialized temporary is bound to an
45304530
/// lvalue reference; otherwise, it's bound to an rvalue reference.
4531-
bool isBoundToLvalueReference() const {
4532-
return getValueKind() == VK_LValue;
4533-
}
4531+
bool isBoundToLvalueReference() const { return isLValue(); }
45344532

45354533
/// Determine whether this temporary object is usable in constant
45364534
/// expressions, as specified in C++20 [expr.const]p4.

clang/lib/AST/Expr.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2406,7 +2406,7 @@ bool Expr::isReadIfDiscardedInCPlusPlus11() const {
24062406
// In C++11, discarded-value expressions of a certain form are special,
24072407
// according to [expr]p10:
24082408
// The lvalue-to-rvalue conversion (4.1) is applied only if the
2409-
// expression is an lvalue of volatile-qualified type and it has
2409+
// expression is a glvalue of volatile-qualified type and it has
24102410
// one of the following forms:
24112411
if (!isGLValue() || !getType().isVolatileQualified())
24122412
return false;
@@ -3874,8 +3874,7 @@ Expr::isNullPointerConstant(ASTContext &Ctx,
38743874
const ObjCPropertyRefExpr *Expr::getObjCProperty() const {
38753875
const Expr *E = this;
38763876
while (true) {
3877-
assert((E->getValueKind() == VK_LValue &&
3878-
E->getObjectKind() == OK_ObjCProperty) &&
3877+
assert((E->isLValue() && E->getObjectKind() == OK_ObjCProperty) &&
38793878
"expression is not a property reference");
38803879
E = E->IgnoreParenCasts();
38813880
if (const BinaryOperator *BO = dyn_cast<BinaryOperator>(E)) {
@@ -3914,7 +3913,7 @@ FieldDecl *Expr::getSourceBitField() {
39143913

39153914
while (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(E)) {
39163915
if (ICE->getCastKind() == CK_LValueToRValue ||
3917-
(ICE->getValueKind() != VK_PRValue && ICE->getCastKind() == CK_NoOp))
3916+
(ICE->isGLValue() && ICE->getCastKind() == CK_NoOp))
39183917
E = ICE->getSubExpr()->IgnoreParens();
39193918
else
39203919
break;
@@ -3961,7 +3960,7 @@ bool Expr::refersToVectorElement() const {
39613960
const Expr *E = this->IgnoreParens();
39623961

39633962
while (const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(E)) {
3964-
if (ICE->getValueKind() != VK_PRValue && ICE->getCastKind() == CK_NoOp)
3963+
if (ICE->isGLValue() && ICE->getCastKind() == CK_NoOp)
39653964
E = ICE->getSubExpr()->IgnoreParens();
39663965
else
39673966
break;

clang/lib/AST/ExprClassification.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,12 @@ Cl Expr::ClassifyImpl(ASTContext &Ctx, SourceLocation *Loc) const {
5353

5454
// Enable this assertion for testing.
5555
switch (kind) {
56-
case Cl::CL_LValue: assert(getValueKind() == VK_LValue); break;
57-
case Cl::CL_XValue: assert(getValueKind() == VK_XValue); break;
56+
case Cl::CL_LValue:
57+
assert(isLValue());
58+
break;
59+
case Cl::CL_XValue:
60+
assert(isXValue());
61+
break;
5862
case Cl::CL_Function:
5963
case Cl::CL_Void:
6064
case Cl::CL_AddressableVoid:
@@ -65,7 +69,7 @@ Cl Expr::ClassifyImpl(ASTContext &Ctx, SourceLocation *Loc) const {
6569
case Cl::CL_ArrayTemporary:
6670
case Cl::CL_ObjCMessageRValue:
6771
case Cl::CL_PRValue:
68-
assert(getValueKind() == VK_PRValue);
72+
assert(isPRValue());
6973
break;
7074
}
7175

clang/lib/CodeGen/CGDecl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -714,10 +714,10 @@ static bool tryEmitARCCopyWeakInit(CodeGenFunction &CGF,
714714
}
715715

716716
// If it was an l-value, use objc_copyWeak.
717-
if (srcExpr->getValueKind() == VK_LValue) {
717+
if (srcExpr->isLValue()) {
718718
CGF.EmitARCCopyWeak(destLV.getAddress(CGF), srcAddr);
719719
} else {
720-
assert(srcExpr->getValueKind() == VK_XValue);
720+
assert(srcExpr->isXValue());
721721
CGF.EmitARCMoveWeak(destLV.getAddress(CGF), srcAddr);
722722
}
723723
return true;

clang/lib/CodeGen/CGExprScalar.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1965,7 +1965,7 @@ bool CodeGenFunction::ShouldNullCheckClassCastValue(const CastExpr *CE) {
19651965

19661966
if (const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(CE)) {
19671967
// And that glvalue casts are never null.
1968-
if (ICE->getValueKind() != VK_PRValue)
1968+
if (ICE->isGLValue())
19691969
return false;
19701970
}
19711971

clang/lib/Sema/Sema.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ ExprResult Sema::ImpCastExprToType(Expr *E, QualType Ty,
632632
if (Kind == CK_ArrayToPointerDecay) {
633633
// C++1z [conv.array]: The temporary materialization conversion is applied.
634634
// We also use this to fuel C++ DR1213, which applies to C++11 onwards.
635-
if (getLangOpts().CPlusPlus && E->getValueKind() == VK_PRValue) {
635+
if (getLangOpts().CPlusPlus && E->isPRValue()) {
636636
// The temporary is an lvalue in C++98 and an xvalue otherwise.
637637
ExprResult Materialized = CreateMaterializeTemporaryExpr(
638638
E->getType(), E, !getLangOpts().CPlusPlus11);

clang/lib/Sema/SemaCoroutine.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -877,7 +877,7 @@ ExprResult Sema::BuildResolvedCoawaitExpr(SourceLocation Loc, Expr *E,
877877

878878
// If the expression is a temporary, materialize it as an lvalue so that we
879879
// can use it multiple times.
880-
if (E->getValueKind() == VK_PRValue)
880+
if (E->isPRValue())
881881
E = CreateMaterializeTemporaryExpr(E->getType(), E, true);
882882

883883
// The location of the `co_await` token cannot be used when constructing
@@ -937,7 +937,7 @@ ExprResult Sema::BuildCoyieldExpr(SourceLocation Loc, Expr *E) {
937937

938938
// If the expression is a temporary, materialize it as an lvalue so that we
939939
// can use it multiple times.
940-
if (E->getValueKind() == VK_PRValue)
940+
if (E->isPRValue())
941941
E = CreateMaterializeTemporaryExpr(E->getType(), E, true);
942942

943943
// Build the await_ready, await_suspend, await_resume calls.

clang/lib/Sema/SemaExpr.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5546,7 +5546,7 @@ Sema::CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc,
55465546
BaseExpr = LHSExp; // vectors: V[123]
55475547
IndexExpr = RHSExp;
55485548
// We apply C++ DR1213 to vector subscripting too.
5549-
if (getLangOpts().CPlusPlus11 && LHSExp->getValueKind() == VK_PRValue) {
5549+
if (getLangOpts().CPlusPlus11 && LHSExp->isPRValue()) {
55505550
ExprResult Materialized = TemporaryMaterializationConversion(LHSExp);
55515551
if (Materialized.isInvalid())
55525552
return ExprError();
@@ -10159,7 +10159,7 @@ QualType Sema::CheckVectorOperands(ExprResult &LHS, ExprResult &RHS,
1015910159
RHSType, DiagID))
1016010160
return RHSType;
1016110161
} else {
10162-
if (LHS.get()->getValueKind() == VK_LValue ||
10162+
if (LHS.get()->isLValue() ||
1016310163
!tryGCCVectorConvertAndSplat(*this, &LHS, &RHS))
1016410164
return RHSType;
1016510165
}
@@ -14939,7 +14939,7 @@ ExprResult Sema::CreateBuiltinUnaryOp(SourceLocation OpLoc,
1493914939
// complex l-values to ordinary l-values and all other values to r-values.
1494014940
if (Input.isInvalid()) return ExprError();
1494114941
if (Opc == UO_Real || Input.get()->getType()->isAnyComplexType()) {
14942-
if (Input.get()->getValueKind() != VK_PRValue &&
14942+
if (Input.get()->isGLValue() &&
1494314943
Input.get()->getObjectKind() == OK_Ordinary)
1494414944
VK = Input.get()->getValueKind();
1494514945
} else if (!getLangOpts().CPlusPlus) {
@@ -19176,7 +19176,7 @@ namespace {
1917619176
Expr *SubExpr = SubResult.get();
1917719177
E->setSubExpr(SubExpr);
1917819178
E->setType(S.Context.getPointerType(SubExpr->getType()));
19179-
assert(E->getValueKind() == VK_PRValue);
19179+
assert(E->isPRValue());
1918019180
assert(E->getObjectKind() == OK_Ordinary);
1918119181
return E;
1918219182
}
@@ -19186,7 +19186,7 @@ namespace {
1918619186

1918719187
E->setType(VD->getType());
1918819188

19189-
assert(E->getValueKind() == VK_PRValue);
19189+
assert(E->isPRValue());
1919019190
if (S.getLangOpts().CPlusPlus &&
1919119191
!(isa<CXXMethodDecl>(VD) &&
1919219192
cast<CXXMethodDecl>(VD)->isInstance()))
@@ -19277,7 +19277,7 @@ namespace {
1927719277
return ExprError();
1927819278
}
1927919279

19280-
assert(E->getValueKind() == VK_PRValue);
19280+
assert(E->isPRValue());
1928119281
assert(E->getObjectKind() == OK_Ordinary);
1928219282
E->setType(DestType);
1928319283

@@ -19437,7 +19437,7 @@ ExprResult RebuildUnknownAnyExpr::VisitObjCMessageExpr(ObjCMessageExpr *E) {
1943719437
ExprResult RebuildUnknownAnyExpr::VisitImplicitCastExpr(ImplicitCastExpr *E) {
1943819438
// The only case we should ever see here is a function-to-pointer decay.
1943919439
if (E->getCastKind() == CK_FunctionToPointerDecay) {
19440-
assert(E->getValueKind() == VK_PRValue);
19440+
assert(E->isPRValue());
1944119441
assert(E->getObjectKind() == OK_Ordinary);
1944219442

1944319443
E->setType(DestType);
@@ -19451,7 +19451,7 @@ ExprResult RebuildUnknownAnyExpr::VisitImplicitCastExpr(ImplicitCastExpr *E) {
1945119451
E->setSubExpr(Result.get());
1945219452
return E;
1945319453
} else if (E->getCastKind() == CK_LValueToRValue) {
19454-
assert(E->getValueKind() == VK_PRValue);
19454+
assert(E->isPRValue());
1945519455
assert(E->getObjectKind() == OK_Ordinary);
1945619456

1945719457
assert(isa<BlockPointerType>(E->getType()));

clang/lib/Sema/SemaExprCXX.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6897,7 +6897,7 @@ ExprResult Sema::MaybeBindToTemporary(Expr *E) {
68976897
assert(!isa<CXXBindTemporaryExpr>(E) && "Double-bound temporary?");
68986898

68996899
// If the result is a glvalue, we shouldn't bind it.
6900-
if (!E->isPRValue())
6900+
if (E->isGLValue())
69016901
return E;
69026902

69036903
// In ARC, calls that return a retainable type can return retained,

clang/lib/Sema/SemaInit.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5832,7 +5832,7 @@ void InitializationSequence::InitializeFrom(Sema &S,
58325832
Entity.getType()) &&
58335833
canPerformArrayCopy(Entity)) {
58345834
// If source is a prvalue, use it directly.
5835-
if (Initializer->getValueKind() == VK_PRValue) {
5835+
if (Initializer->isPRValue()) {
58365836
AddArrayInitStep(DestType, /*IsGNUExtension*/false);
58375837
return;
58385838
}

0 commit comments

Comments
 (0)