Skip to content

Commit de044f7

Browse files
committed
Revert "[AST][FPEnv] Keep FP options in trailing storage of CastExpr"
This reverts commit 6c8041a. It caused some fails on buildbots.
1 parent b3f364e commit de044f7

34 files changed

+253
-461
lines changed

clang/include/clang/AST/Expr.h

Lines changed: 29 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -3440,11 +3440,9 @@ class CastExpr : public Expr {
34403440
}
34413441
CXXBaseSpecifier **path_buffer();
34423442

3443-
friend class ASTStmtReader;
3444-
34453443
protected:
34463444
CastExpr(StmtClass SC, QualType ty, ExprValueKind VK, const CastKind kind,
3447-
Expr *op, unsigned BasePathSize, bool HasFPFeatures)
3445+
Expr *op, unsigned BasePathSize)
34483446
: Expr(SC, ty, VK, OK_Ordinary), Op(op) {
34493447
CastExprBits.Kind = kind;
34503448
CastExprBits.PartOfExplicitCast = false;
@@ -3453,27 +3451,17 @@ class CastExpr : public Expr {
34533451
"BasePathSize overflow!");
34543452
setDependence(computeDependence(this));
34553453
assert(CastConsistency());
3456-
CastExprBits.HasFPFeatures = HasFPFeatures;
34573454
}
34583455

34593456
/// Construct an empty cast.
3460-
CastExpr(StmtClass SC, EmptyShell Empty, unsigned BasePathSize,
3461-
bool HasFPFeatures)
3462-
: Expr(SC, Empty) {
3457+
CastExpr(StmtClass SC, EmptyShell Empty, unsigned BasePathSize)
3458+
: Expr(SC, Empty) {
34633459
CastExprBits.PartOfExplicitCast = false;
34643460
CastExprBits.BasePathSize = BasePathSize;
3465-
CastExprBits.HasFPFeatures = HasFPFeatures;
34663461
assert((CastExprBits.BasePathSize == BasePathSize) &&
34673462
"BasePathSize overflow!");
34683463
}
34693464

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-
34773465
public:
34783466
CastKind getCastKind() const { return (CastKind) CastExprBits.Kind; }
34793467
void setCastKind(CastKind K) { CastExprBits.Kind = K; }
@@ -3518,28 +3506,6 @@ class CastExpr : public Expr {
35183506
return getTargetFieldForToUnionCast(getType(), getSubExpr()->getType());
35193507
}
35203508

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-
35433509
static const FieldDecl *getTargetFieldForToUnionCast(QualType unionType,
35443510
QualType opType);
35453511
static const FieldDecl *getTargetFieldForToUnionCast(const RecordDecl *RD,
@@ -3577,35 +3543,21 @@ class CastExpr : public Expr {
35773543
/// @endcode
35783544
class ImplicitCastExpr final
35793545
: public CastExpr,
3580-
private llvm::TrailingObjects<ImplicitCastExpr, CXXBaseSpecifier *,
3581-
FPOptionsOverride> {
3546+
private llvm::TrailingObjects<ImplicitCastExpr, CXXBaseSpecifier *> {
35823547

35833548
ImplicitCastExpr(QualType ty, CastKind kind, Expr *op,
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-
}
3549+
unsigned BasePathLength, ExprValueKind VK)
3550+
: CastExpr(ImplicitCastExprClass, ty, VK, kind, op, BasePathLength) { }
35913551

35923552
/// Construct an empty implicit cast.
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-
}
3553+
explicit ImplicitCastExpr(EmptyShell Shell, unsigned PathSize)
3554+
: CastExpr(ImplicitCastExprClass, Shell, PathSize) { }
36003555

36013556
public:
36023557
enum OnStack_t { OnStack };
36033558
ImplicitCastExpr(OnStack_t _, QualType ty, CastKind kind, Expr *op,
3604-
ExprValueKind VK, FPOptionsOverride FPO)
3605-
: CastExpr(ImplicitCastExprClass, ty, VK, kind, op, 0,
3606-
FPO.requiresTrailingStorage()) {
3607-
if (hasStoredFPFeatures())
3608-
*getTrailingFPFeatures() = FPO;
3559+
ExprValueKind VK)
3560+
: CastExpr(ImplicitCastExprClass, ty, VK, kind, op, 0) {
36093561
}
36103562

36113563
bool isPartOfExplicitCast() const { return CastExprBits.PartOfExplicitCast; }
@@ -3616,10 +3568,10 @@ class ImplicitCastExpr final
36163568
static ImplicitCastExpr *Create(const ASTContext &Context, QualType T,
36173569
CastKind Kind, Expr *Operand,
36183570
const CXXCastPath *BasePath,
3619-
ExprValueKind Cat, FPOptionsOverride FPO);
3571+
ExprValueKind Cat);
36203572

36213573
static ImplicitCastExpr *CreateEmpty(const ASTContext &Context,
3622-
unsigned PathSize, bool HasFPFeatures);
3574+
unsigned PathSize);
36233575

36243576
SourceLocation getBeginLoc() const LLVM_READONLY {
36253577
return getSubExpr()->getBeginLoc();
@@ -3660,14 +3612,12 @@ class ExplicitCastExpr : public CastExpr {
36603612
protected:
36613613
ExplicitCastExpr(StmtClass SC, QualType exprTy, ExprValueKind VK,
36623614
CastKind kind, Expr *op, unsigned PathSize,
3663-
bool HasFPFeatures, TypeSourceInfo *writtenTy)
3664-
: CastExpr(SC, exprTy, VK, kind, op, PathSize, HasFPFeatures),
3665-
TInfo(writtenTy) {}
3615+
TypeSourceInfo *writtenTy)
3616+
: CastExpr(SC, exprTy, VK, kind, op, PathSize), TInfo(writtenTy) {}
36663617

36673618
/// Construct an empty explicit cast.
3668-
ExplicitCastExpr(StmtClass SC, EmptyShell Shell, unsigned PathSize,
3669-
bool HasFPFeatures)
3670-
: CastExpr(SC, Shell, PathSize, HasFPFeatures) {}
3619+
ExplicitCastExpr(StmtClass SC, EmptyShell Shell, unsigned PathSize)
3620+
: CastExpr(SC, Shell, PathSize) { }
36713621

36723622
public:
36733623
/// getTypeInfoAsWritten - Returns the type source info for the type
@@ -3690,38 +3640,29 @@ class ExplicitCastExpr : public CastExpr {
36903640
/// (Type)expr. For example: @c (int)f.
36913641
class CStyleCastExpr final
36923642
: public ExplicitCastExpr,
3693-
private llvm::TrailingObjects<CStyleCastExpr, CXXBaseSpecifier *,
3694-
FPOptionsOverride> {
3643+
private llvm::TrailingObjects<CStyleCastExpr, CXXBaseSpecifier *> {
36953644
SourceLocation LPLoc; // the location of the left paren
36963645
SourceLocation RPLoc; // the location of the right paren
36973646

36983647
CStyleCastExpr(QualType exprTy, ExprValueKind vk, CastKind kind, Expr *op,
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-
}
3648+
unsigned PathSize, TypeSourceInfo *writtenTy,
3649+
SourceLocation l, SourceLocation r)
3650+
: ExplicitCastExpr(CStyleCastExprClass, exprTy, vk, kind, op, PathSize,
3651+
writtenTy), LPLoc(l), RPLoc(r) {}
37073652

37083653
/// Construct an empty C-style explicit cast.
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-
}
3654+
explicit CStyleCastExpr(EmptyShell Shell, unsigned PathSize)
3655+
: ExplicitCastExpr(CStyleCastExprClass, Shell, PathSize) { }
37163656

37173657
public:
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);
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);
37223663

37233664
static CStyleCastExpr *CreateEmpty(const ASTContext &Context,
3724-
unsigned PathSize, bool HasFPFeatures);
3665+
unsigned PathSize);
37253666

37263667
SourceLocation getLParenLoc() const { return LPLoc; }
37273668
void setLParenLoc(SourceLocation L) { LPLoc = L; }

0 commit comments

Comments
 (0)