@@ -3440,9 +3440,11 @@ class CastExpr : public Expr {
3440
3440
}
3441
3441
CXXBaseSpecifier **path_buffer ();
3442
3442
3443
+ friend class ASTStmtReader ;
3444
+
3443
3445
protected:
3444
3446
CastExpr (StmtClass SC, QualType ty, ExprValueKind VK, const CastKind kind,
3445
- Expr *op, unsigned BasePathSize)
3447
+ Expr *op, unsigned BasePathSize, bool HasFPFeatures )
3446
3448
: Expr(SC, ty, VK, OK_Ordinary), Op(op) {
3447
3449
CastExprBits.Kind = kind;
3448
3450
CastExprBits.PartOfExplicitCast = false ;
@@ -3451,17 +3453,27 @@ class CastExpr : public Expr {
3451
3453
" BasePathSize overflow!" );
3452
3454
setDependence (computeDependence (this ));
3453
3455
assert (CastConsistency ());
3456
+ CastExprBits.HasFPFeatures = HasFPFeatures;
3454
3457
}
3455
3458
3456
3459
// / Construct an empty cast.
3457
- CastExpr (StmtClass SC, EmptyShell Empty, unsigned BasePathSize)
3458
- : Expr(SC, Empty) {
3460
+ CastExpr (StmtClass SC, EmptyShell Empty, unsigned BasePathSize,
3461
+ bool HasFPFeatures)
3462
+ : Expr(SC, Empty) {
3459
3463
CastExprBits.PartOfExplicitCast = false ;
3460
3464
CastExprBits.BasePathSize = BasePathSize;
3465
+ CastExprBits.HasFPFeatures = HasFPFeatures;
3461
3466
assert ((CastExprBits.BasePathSize == BasePathSize) &&
3462
3467
" BasePathSize overflow!" );
3463
3468
}
3464
3469
3470
+ // / Return a pointer to the trailing FPOptions.
3471
+ // / \pre hasStoredFPFeatures() == true
3472
+ FPOptionsOverride *getTrailingFPFeatures ();
3473
+ const FPOptionsOverride *getTrailingFPFeatures () const {
3474
+ return const_cast <CastExpr *>(this )->getTrailingFPFeatures ();
3475
+ }
3476
+
3465
3477
public:
3466
3478
CastKind getCastKind () const { return (CastKind) CastExprBits.Kind ; }
3467
3479
void setCastKind (CastKind K) { CastExprBits.Kind = K; }
@@ -3506,6 +3518,28 @@ class CastExpr : public Expr {
3506
3518
return getTargetFieldForToUnionCast (getType (), getSubExpr ()->getType ());
3507
3519
}
3508
3520
3521
+ bool hasStoredFPFeatures () const { return CastExprBits.HasFPFeatures ; }
3522
+
3523
+ // / Get FPOptionsOverride from trailing storage.
3524
+ FPOptionsOverride getStoredFPFeatures () const {
3525
+ assert (hasStoredFPFeatures ());
3526
+ return *getTrailingFPFeatures ();
3527
+ }
3528
+
3529
+ // Get the FP features status of this operation. Only meaningful for
3530
+ // operations on floating point types.
3531
+ FPOptions getFPFeaturesInEffect (const LangOptions &LO) const {
3532
+ if (hasStoredFPFeatures ())
3533
+ return getStoredFPFeatures ().applyOverrides (LO);
3534
+ return FPOptions::defaultWithoutTrailingStorage (LO);
3535
+ }
3536
+
3537
+ FPOptionsOverride getFPFeatures () const {
3538
+ if (hasStoredFPFeatures ())
3539
+ return getStoredFPFeatures ();
3540
+ return FPOptionsOverride ();
3541
+ }
3542
+
3509
3543
static const FieldDecl *getTargetFieldForToUnionCast (QualType unionType,
3510
3544
QualType opType);
3511
3545
static const FieldDecl *getTargetFieldForToUnionCast (const RecordDecl *RD,
@@ -3543,21 +3577,35 @@ class CastExpr : public Expr {
3543
3577
// / @endcode
3544
3578
class ImplicitCastExpr final
3545
3579
: public CastExpr,
3546
- private llvm::TrailingObjects<ImplicitCastExpr, CXXBaseSpecifier *> {
3580
+ private llvm::TrailingObjects<ImplicitCastExpr, CXXBaseSpecifier *,
3581
+ FPOptionsOverride> {
3547
3582
3548
3583
ImplicitCastExpr (QualType ty, CastKind kind, Expr *op,
3549
- unsigned BasePathLength, ExprValueKind VK)
3550
- : CastExpr(ImplicitCastExprClass, ty, VK, kind, op, BasePathLength) { }
3584
+ unsigned BasePathLength, FPOptionsOverride FPO,
3585
+ ExprValueKind VK)
3586
+ : CastExpr(ImplicitCastExprClass, ty, VK, kind, op, BasePathLength,
3587
+ FPO.requiresTrailingStorage()) {
3588
+ if (hasStoredFPFeatures ())
3589
+ *getTrailingFPFeatures () = FPO;
3590
+ }
3551
3591
3552
3592
// / Construct an empty implicit cast.
3553
- explicit ImplicitCastExpr (EmptyShell Shell, unsigned PathSize)
3554
- : CastExpr(ImplicitCastExprClass, Shell, PathSize) { }
3593
+ explicit ImplicitCastExpr (EmptyShell Shell, unsigned PathSize,
3594
+ bool HasFPFeatures)
3595
+ : CastExpr(ImplicitCastExprClass, Shell, PathSize, HasFPFeatures) {}
3596
+
3597
+ unsigned numTrailingObjects (OverloadToken<CXXBaseSpecifier *>) const {
3598
+ return path_size ();
3599
+ }
3555
3600
3556
3601
public:
3557
3602
enum OnStack_t { OnStack };
3558
3603
ImplicitCastExpr (OnStack_t _, QualType ty, CastKind kind, Expr *op,
3559
- ExprValueKind VK)
3560
- : CastExpr(ImplicitCastExprClass, ty, VK, kind, op, 0 ) {
3604
+ ExprValueKind VK, FPOptionsOverride FPO)
3605
+ : CastExpr(ImplicitCastExprClass, ty, VK, kind, op, 0 ,
3606
+ FPO.requiresTrailingStorage()) {
3607
+ if (hasStoredFPFeatures ())
3608
+ *getTrailingFPFeatures () = FPO;
3561
3609
}
3562
3610
3563
3611
bool isPartOfExplicitCast () const { return CastExprBits.PartOfExplicitCast ; }
@@ -3568,10 +3616,10 @@ class ImplicitCastExpr final
3568
3616
static ImplicitCastExpr *Create (const ASTContext &Context, QualType T,
3569
3617
CastKind Kind, Expr *Operand,
3570
3618
const CXXCastPath *BasePath,
3571
- ExprValueKind Cat);
3619
+ ExprValueKind Cat, FPOptionsOverride FPO );
3572
3620
3573
3621
static ImplicitCastExpr *CreateEmpty (const ASTContext &Context,
3574
- unsigned PathSize);
3622
+ unsigned PathSize, bool HasFPFeatures );
3575
3623
3576
3624
SourceLocation getBeginLoc () const LLVM_READONLY {
3577
3625
return getSubExpr ()->getBeginLoc ();
@@ -3612,12 +3660,14 @@ class ExplicitCastExpr : public CastExpr {
3612
3660
protected:
3613
3661
ExplicitCastExpr (StmtClass SC, QualType exprTy, ExprValueKind VK,
3614
3662
CastKind kind, Expr *op, unsigned PathSize,
3615
- TypeSourceInfo *writtenTy)
3616
- : CastExpr(SC, exprTy, VK, kind, op, PathSize), TInfo(writtenTy) {}
3663
+ bool HasFPFeatures, TypeSourceInfo *writtenTy)
3664
+ : CastExpr(SC, exprTy, VK, kind, op, PathSize, HasFPFeatures),
3665
+ TInfo (writtenTy) {}
3617
3666
3618
3667
// / Construct an empty explicit cast.
3619
- ExplicitCastExpr (StmtClass SC, EmptyShell Shell, unsigned PathSize)
3620
- : CastExpr(SC, Shell, PathSize) { }
3668
+ ExplicitCastExpr (StmtClass SC, EmptyShell Shell, unsigned PathSize,
3669
+ bool HasFPFeatures)
3670
+ : CastExpr(SC, Shell, PathSize, HasFPFeatures) {}
3621
3671
3622
3672
public:
3623
3673
// / getTypeInfoAsWritten - Returns the type source info for the type
@@ -3640,29 +3690,38 @@ class ExplicitCastExpr : public CastExpr {
3640
3690
// / (Type)expr. For example: @c (int)f.
3641
3691
class CStyleCastExpr final
3642
3692
: public ExplicitCastExpr,
3643
- private llvm::TrailingObjects<CStyleCastExpr, CXXBaseSpecifier *> {
3693
+ private llvm::TrailingObjects<CStyleCastExpr, CXXBaseSpecifier *,
3694
+ FPOptionsOverride> {
3644
3695
SourceLocation LPLoc; // the location of the left paren
3645
3696
SourceLocation RPLoc; // the location of the right paren
3646
3697
3647
3698
CStyleCastExpr (QualType exprTy, ExprValueKind vk, CastKind kind, Expr *op,
3648
- unsigned PathSize, TypeSourceInfo *writtenTy,
3649
- SourceLocation l, SourceLocation r)
3650
- : ExplicitCastExpr(CStyleCastExprClass, exprTy, vk, kind, op, PathSize,
3651
- writtenTy), LPLoc(l), RPLoc(r) {}
3699
+ unsigned PathSize, FPOptionsOverride FPO,
3700
+ TypeSourceInfo *writtenTy, SourceLocation l, SourceLocation r)
3701
+ : ExplicitCastExpr(CStyleCastExprClass, exprTy, vk, kind, op, PathSize,
3702
+ FPO.requiresTrailingStorage(), writtenTy),
3703
+ LPLoc (l), RPLoc(r) {
3704
+ if (hasStoredFPFeatures ())
3705
+ *getTrailingFPFeatures () = FPO;
3706
+ }
3652
3707
3653
3708
// / Construct an empty C-style explicit cast.
3654
- explicit CStyleCastExpr (EmptyShell Shell, unsigned PathSize)
3655
- : ExplicitCastExpr(CStyleCastExprClass, Shell, PathSize) { }
3709
+ explicit CStyleCastExpr (EmptyShell Shell, unsigned PathSize,
3710
+ bool HasFPFeatures)
3711
+ : ExplicitCastExpr(CStyleCastExprClass, Shell, PathSize, HasFPFeatures) {}
3712
+
3713
+ unsigned numTrailingObjects (OverloadToken<CXXBaseSpecifier *>) const {
3714
+ return path_size ();
3715
+ }
3656
3716
3657
3717
public:
3658
- static CStyleCastExpr *Create (const ASTContext &Context, QualType T,
3659
- ExprValueKind VK, CastKind K,
3660
- Expr *Op, const CXXCastPath *BasePath,
3661
- TypeSourceInfo *WrittenTy, SourceLocation L,
3662
- SourceLocation R);
3718
+ static CStyleCastExpr *
3719
+ Create (const ASTContext &Context, QualType T, ExprValueKind VK, CastKind K,
3720
+ Expr *Op, const CXXCastPath *BasePath, FPOptionsOverride FPO,
3721
+ TypeSourceInfo *WrittenTy, SourceLocation L, SourceLocation R);
3663
3722
3664
3723
static CStyleCastExpr *CreateEmpty (const ASTContext &Context,
3665
- unsigned PathSize);
3724
+ unsigned PathSize, bool HasFPFeatures );
3666
3725
3667
3726
SourceLocation getLParenLoc () const { return LPLoc; }
3668
3727
void setLParenLoc (SourceLocation L) { LPLoc = L; }
0 commit comments