29
29
//
30
30
// ===----------------------------------------------------------------------===//
31
31
32
+ #include " clang/Sema/SemaPseudoObject.h"
32
33
#include " clang/AST/ExprCXX.h"
33
34
#include " clang/AST/ExprObjC.h"
34
35
#include " clang/Basic/CharInfo.h"
@@ -1446,73 +1447,73 @@ ExprResult MSPropertyOpBuilder::buildSet(Expr *op, SourceLocation sl,
1446
1447
// General Sema routines.
1447
1448
// ===----------------------------------------------------------------------===//
1448
1449
1449
- ExprResult Sema::checkPseudoObjectRValue (Expr *E) {
1450
+ ExprResult SemaPseudoObject::checkRValue (Expr *E) {
1450
1451
Expr *opaqueRef = E->IgnoreParens ();
1451
1452
if (ObjCPropertyRefExpr *refExpr
1452
1453
= dyn_cast<ObjCPropertyRefExpr>(opaqueRef)) {
1453
- ObjCPropertyOpBuilder builder (* this , refExpr, true );
1454
+ ObjCPropertyOpBuilder builder (SemaRef , refExpr, true );
1454
1455
return builder.buildRValueOperation (E);
1455
1456
}
1456
1457
else if (ObjCSubscriptRefExpr *refExpr
1457
1458
= dyn_cast<ObjCSubscriptRefExpr>(opaqueRef)) {
1458
- ObjCSubscriptOpBuilder builder (* this , refExpr, true );
1459
+ ObjCSubscriptOpBuilder builder (SemaRef , refExpr, true );
1459
1460
return builder.buildRValueOperation (E);
1460
1461
} else if (MSPropertyRefExpr *refExpr
1461
1462
= dyn_cast<MSPropertyRefExpr>(opaqueRef)) {
1462
- MSPropertyOpBuilder builder (* this , refExpr, true );
1463
+ MSPropertyOpBuilder builder (SemaRef , refExpr, true );
1463
1464
return builder.buildRValueOperation (E);
1464
1465
} else if (MSPropertySubscriptExpr *RefExpr =
1465
1466
dyn_cast<MSPropertySubscriptExpr>(opaqueRef)) {
1466
- MSPropertyOpBuilder Builder (* this , RefExpr, true );
1467
+ MSPropertyOpBuilder Builder (SemaRef , RefExpr, true );
1467
1468
return Builder.buildRValueOperation (E);
1468
1469
} else {
1469
1470
llvm_unreachable (" unknown pseudo-object kind!" );
1470
1471
}
1471
1472
}
1472
1473
1473
1474
// / Check an increment or decrement of a pseudo-object expression.
1474
- ExprResult Sema::checkPseudoObjectIncDec (Scope *Sc, SourceLocation opcLoc,
1475
+ ExprResult SemaPseudoObject::checkIncDec (Scope *Sc, SourceLocation opcLoc,
1475
1476
UnaryOperatorKind opcode, Expr *op) {
1476
1477
// Do nothing if the operand is dependent.
1477
1478
if (op->isTypeDependent ())
1478
- return UnaryOperator::Create (Context, op, opcode, Context. DependentTy ,
1479
- VK_PRValue, OK_Ordinary, opcLoc, false ,
1480
- CurFPFeatureOverrides ());
1479
+ return UnaryOperator::Create (
1480
+ SemaRef. Context , op, opcode, SemaRef. Context . DependentTy , VK_PRValue ,
1481
+ OK_Ordinary, opcLoc, false , SemaRef. CurFPFeatureOverrides ());
1481
1482
1482
1483
assert (UnaryOperator::isIncrementDecrementOp (opcode));
1483
1484
Expr *opaqueRef = op->IgnoreParens ();
1484
1485
if (ObjCPropertyRefExpr *refExpr
1485
1486
= dyn_cast<ObjCPropertyRefExpr>(opaqueRef)) {
1486
- ObjCPropertyOpBuilder builder (* this , refExpr, false );
1487
+ ObjCPropertyOpBuilder builder (SemaRef , refExpr, false );
1487
1488
return builder.buildIncDecOperation (Sc, opcLoc, opcode, op);
1488
1489
} else if (isa<ObjCSubscriptRefExpr>(opaqueRef)) {
1489
1490
Diag (opcLoc, diag::err_illegal_container_subscripting_op);
1490
1491
return ExprError ();
1491
1492
} else if (MSPropertyRefExpr *refExpr
1492
1493
= dyn_cast<MSPropertyRefExpr>(opaqueRef)) {
1493
- MSPropertyOpBuilder builder (* this , refExpr, false );
1494
+ MSPropertyOpBuilder builder (SemaRef , refExpr, false );
1494
1495
return builder.buildIncDecOperation (Sc, opcLoc, opcode, op);
1495
1496
} else if (MSPropertySubscriptExpr *RefExpr
1496
1497
= dyn_cast<MSPropertySubscriptExpr>(opaqueRef)) {
1497
- MSPropertyOpBuilder Builder (* this , RefExpr, false );
1498
+ MSPropertyOpBuilder Builder (SemaRef , RefExpr, false );
1498
1499
return Builder.buildIncDecOperation (Sc, opcLoc, opcode, op);
1499
1500
} else {
1500
1501
llvm_unreachable (" unknown pseudo-object kind!" );
1501
1502
}
1502
1503
}
1503
1504
1504
- ExprResult Sema::checkPseudoObjectAssignment (Scope *S, SourceLocation opcLoc,
1505
+ ExprResult SemaPseudoObject::checkAssignment (Scope *S, SourceLocation opcLoc,
1505
1506
BinaryOperatorKind opcode,
1506
1507
Expr *LHS, Expr *RHS) {
1507
1508
// Do nothing if either argument is dependent.
1508
1509
if (LHS->isTypeDependent () || RHS->isTypeDependent ())
1509
- return BinaryOperator::Create (Context, LHS, RHS, opcode,
1510
- Context.DependentTy , VK_PRValue, OK_Ordinary ,
1511
- opcLoc, CurFPFeatureOverrides ());
1510
+ return BinaryOperator::Create (
1511
+ SemaRef. Context , LHS, RHS, opcode, SemaRef. Context .DependentTy ,
1512
+ VK_PRValue, OK_Ordinary, opcLoc, SemaRef. CurFPFeatureOverrides ());
1512
1513
1513
1514
// Filter out non-overload placeholder types in the RHS.
1514
1515
if (RHS->getType ()->isNonOverloadPlaceholderType ()) {
1515
- ExprResult result = CheckPlaceholderExpr (RHS);
1516
+ ExprResult result = SemaRef. CheckPlaceholderExpr (RHS);
1516
1517
if (result.isInvalid ()) return ExprError ();
1517
1518
RHS = result.get ();
1518
1519
}
@@ -1521,20 +1522,20 @@ ExprResult Sema::checkPseudoObjectAssignment(Scope *S, SourceLocation opcLoc,
1521
1522
Expr *opaqueRef = LHS->IgnoreParens ();
1522
1523
if (ObjCPropertyRefExpr *refExpr
1523
1524
= dyn_cast<ObjCPropertyRefExpr>(opaqueRef)) {
1524
- ObjCPropertyOpBuilder builder (* this , refExpr, IsSimpleAssign);
1525
+ ObjCPropertyOpBuilder builder (SemaRef , refExpr, IsSimpleAssign);
1525
1526
return builder.buildAssignmentOperation (S, opcLoc, opcode, LHS, RHS);
1526
1527
} else if (ObjCSubscriptRefExpr *refExpr
1527
1528
= dyn_cast<ObjCSubscriptRefExpr>(opaqueRef)) {
1528
- ObjCSubscriptOpBuilder builder (* this , refExpr, IsSimpleAssign);
1529
+ ObjCSubscriptOpBuilder builder (SemaRef , refExpr, IsSimpleAssign);
1529
1530
return builder.buildAssignmentOperation (S, opcLoc, opcode, LHS, RHS);
1530
1531
} else if (MSPropertyRefExpr *refExpr
1531
1532
= dyn_cast<MSPropertyRefExpr>(opaqueRef)) {
1532
- MSPropertyOpBuilder builder (* this , refExpr, IsSimpleAssign);
1533
- return builder.buildAssignmentOperation (S, opcLoc, opcode, LHS, RHS);
1533
+ MSPropertyOpBuilder builder (SemaRef , refExpr, IsSimpleAssign);
1534
+ return builder.buildAssignmentOperation (S, opcLoc, opcode, LHS, RHS);
1534
1535
} else if (MSPropertySubscriptExpr *RefExpr
1535
1536
= dyn_cast<MSPropertySubscriptExpr>(opaqueRef)) {
1536
- MSPropertyOpBuilder Builder (* this , RefExpr, IsSimpleAssign);
1537
- return Builder.buildAssignmentOperation (S, opcLoc, opcode, LHS, RHS);
1537
+ MSPropertyOpBuilder Builder (SemaRef , RefExpr, IsSimpleAssign);
1538
+ return Builder.buildAssignmentOperation (S, opcLoc, opcode, LHS, RHS);
1538
1539
} else {
1539
1540
llvm_unreachable (" unknown pseudo-object kind!" );
1540
1541
}
@@ -1557,36 +1558,38 @@ static Expr *stripOpaqueValuesFromPseudoObjectRef(Sema &S, Expr *E) {
1557
1558
// / This is a hack which should be removed when TreeTransform is
1558
1559
// / capable of rebuilding a tree without stripping implicit
1559
1560
// / operations.
1560
- Expr *Sema ::recreateSyntacticForm (PseudoObjectExpr *E) {
1561
+ Expr *SemaPseudoObject ::recreateSyntacticForm (PseudoObjectExpr *E) {
1561
1562
Expr *syntax = E->getSyntacticForm ();
1562
1563
if (UnaryOperator *uop = dyn_cast<UnaryOperator>(syntax)) {
1563
- Expr *op = stripOpaqueValuesFromPseudoObjectRef (* this , uop->getSubExpr ());
1564
- return UnaryOperator::Create (Context, op, uop-> getOpcode (), uop-> getType (),
1565
- uop->getValueKind (), uop->getObjectKind (),
1566
- uop->getOperatorLoc (), uop->canOverflow (),
1567
- CurFPFeatureOverrides ());
1564
+ Expr *op = stripOpaqueValuesFromPseudoObjectRef (SemaRef , uop->getSubExpr ());
1565
+ return UnaryOperator::Create (
1566
+ SemaRef. Context , op, uop->getOpcode (), uop->getType (),
1567
+ uop-> getValueKind (), uop->getObjectKind (), uop->getOperatorLoc (),
1568
+ uop-> canOverflow (), SemaRef. CurFPFeatureOverrides ());
1568
1569
} else if (CompoundAssignOperator *cop
1569
1570
= dyn_cast<CompoundAssignOperator>(syntax)) {
1570
- Expr *lhs = stripOpaqueValuesFromPseudoObjectRef (* this , cop->getLHS ());
1571
+ Expr *lhs = stripOpaqueValuesFromPseudoObjectRef (SemaRef , cop->getLHS ());
1571
1572
Expr *rhs = cast<OpaqueValueExpr>(cop->getRHS ())->getSourceExpr ();
1572
1573
return CompoundAssignOperator::Create (
1573
- Context, lhs, rhs, cop->getOpcode (), cop->getType (),
1574
+ SemaRef. Context , lhs, rhs, cop->getOpcode (), cop->getType (),
1574
1575
cop->getValueKind (), cop->getObjectKind (), cop->getOperatorLoc (),
1575
- CurFPFeatureOverrides (), cop->getComputationLHSType (),
1576
+ SemaRef. CurFPFeatureOverrides (), cop->getComputationLHSType (),
1576
1577
cop->getComputationResultType ());
1577
1578
1578
1579
} else if (BinaryOperator *bop = dyn_cast<BinaryOperator>(syntax)) {
1579
- Expr *lhs = stripOpaqueValuesFromPseudoObjectRef (* this , bop->getLHS ());
1580
+ Expr *lhs = stripOpaqueValuesFromPseudoObjectRef (SemaRef , bop->getLHS ());
1580
1581
Expr *rhs = cast<OpaqueValueExpr>(bop->getRHS ())->getSourceExpr ();
1581
- return BinaryOperator::Create (Context, lhs, rhs, bop->getOpcode (),
1582
+ return BinaryOperator::Create (SemaRef. Context , lhs, rhs, bop->getOpcode (),
1582
1583
bop->getType (), bop->getValueKind (),
1583
1584
bop->getObjectKind (), bop->getOperatorLoc (),
1584
- CurFPFeatureOverrides ());
1585
+ SemaRef. CurFPFeatureOverrides ());
1585
1586
1586
1587
} else if (isa<CallExpr>(syntax)) {
1587
1588
return syntax;
1588
1589
} else {
1589
1590
assert (syntax->hasPlaceholderType (BuiltinType::PseudoObject));
1590
- return stripOpaqueValuesFromPseudoObjectRef (* this , syntax);
1591
+ return stripOpaqueValuesFromPseudoObjectRef (SemaRef , syntax);
1591
1592
}
1592
1593
}
1594
+
1595
+ SemaPseudoObject::SemaPseudoObject (Sema &S) : SemaBase(S) {}
0 commit comments