diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h --- a/clang/include/clang/AST/Expr.h +++ b/clang/include/clang/AST/Expr.h @@ -3442,23 +3442,52 @@ CXXBaseSpecifier **path_buffer(); protected: + // size_t offsetOfTrailingStorage() const; + + // KPN + /// Return a pointer to the trailing FPOptions + FPOptionsOverride *getTrailingFPFeatures() { + assert(CastExprBits.HasFPFeatures); + return reinterpret_cast(path_end()); + // reinterpret_cast(this) + offsetOfTrailingStorage()); + } + + const FPOptionsOverride *getTrailingFPFeatures() const { + assert(CastExprBits.HasFPFeatures); + return reinterpret_cast(path_end()); + // reinterpret_cast(this) + offsetOfTrailingStorage()); + } + + /// Return the size in bytes needed for the trailing objects. + /// Used to allocate the right amount of storage. + static unsigned sizeOfTrailingObjects(unsigned BasePathSize, + bool HasFPFeatures) { + return BasePathSize + HasFPFeatures * sizeof(FPOptionsOverride); + } + CastExpr(StmtClass SC, QualType ty, ExprValueKind VK, const CastKind kind, - Expr *op, unsigned BasePathSize) + Expr *op, unsigned BasePathSize, FPOptionsOverride FPFeatures) : Expr(SC, ty, VK, OK_Ordinary), Op(op) { CastExprBits.Kind = kind; CastExprBits.PartOfExplicitCast = false; CastExprBits.BasePathSize = BasePathSize; assert((CastExprBits.BasePathSize == BasePathSize) && "BasePathSize overflow!"); + setDependence(computeDependence(this)); assert(CastConsistency()); + CastExprBits.HasFPFeatures = FPFeatures.requiresTrailingStorage(); + if (hasStoredFPFeatures()) + setStoredFPFeatures(FPFeatures); } /// Construct an empty cast. - CastExpr(StmtClass SC, EmptyShell Empty, unsigned BasePathSize) - : Expr(SC, Empty) { + CastExpr(StmtClass SC, EmptyShell Empty, unsigned BasePathSize, + bool HasFPFeatures) + : Expr(SC, Empty) { CastExprBits.PartOfExplicitCast = false; CastExprBits.BasePathSize = BasePathSize; + CastExprBits.HasFPFeatures = HasFPFeatures; assert((CastExprBits.BasePathSize == BasePathSize) && "BasePathSize overflow!"); } @@ -3485,7 +3514,38 @@ /// If this cast applies a user-defined conversion, retrieve the conversion /// function that it invokes. NamedDecl *getConversionFunction() const; + // XXX + /// Set and fetch the bit that shows whether FPFeatures needs to be + /// allocated in Trailing Storage + void setHasStoredFPFeatures(bool B) { CastExprBits.HasFPFeatures = B; } + bool hasStoredFPFeatures() const { return CastExprBits.HasFPFeatures; } + /// Get FPFeatures from trailing storage + FPOptionsOverride getStoredFPFeatures() const { + assert(hasStoredFPFeatures()); + return *getTrailingFPFeatures(); + } + /// Set FPFeatures in trailing storage, used only by Serialization + void setStoredFPFeatures(FPOptionsOverride F) { + assert(CastExprBits.HasFPFeatures); + *getTrailingFPFeatures() = F; + } + + // Get the FP features status of this operator. Only meaningful for + // operations on floating point types. + FPOptions getFPFeaturesInEffect(const LangOptions &LO) const { + if (CastExprBits.HasFPFeatures) + return getStoredFPFeatures().applyOverrides(LO); + return FPOptions::defaultWithoutTrailingStorage(LO); + } + + // This is used in ASTImporter + FPOptionsOverride getFPFeatures(const LangOptions &LO) const { + if (CastExprBits.HasFPFeatures) + return getStoredFPFeatures(); + return FPOptionsOverride(); + } + // XXX typedef CXXBaseSpecifier **path_iterator; typedef const CXXBaseSpecifier *const *path_const_iterator; bool path_empty() const { return path_size() == 0; } @@ -3547,19 +3607,22 @@ private llvm::TrailingObjects { ImplicitCastExpr(QualType ty, CastKind kind, Expr *op, - unsigned BasePathLength, ExprValueKind VK) - : CastExpr(ImplicitCastExprClass, ty, VK, kind, op, BasePathLength) { } + unsigned BasePathLength, FPOptionsOverride FPFeatures, + ExprValueKind VK) + : CastExpr(ImplicitCastExprClass, ty, VK, kind, op, BasePathLength, + FPFeatures) {} /// Construct an empty implicit cast. - explicit ImplicitCastExpr(EmptyShell Shell, unsigned PathSize) - : CastExpr(ImplicitCastExprClass, Shell, PathSize) { } + explicit ImplicitCastExpr(EmptyShell Shell, unsigned PathSize, + bool HasFPFeatures) + : CastExpr(ImplicitCastExprClass, Shell, PathSize, HasFPFeatures) {} public: enum OnStack_t { OnStack }; ImplicitCastExpr(OnStack_t _, QualType ty, CastKind kind, Expr *op, ExprValueKind VK) - : CastExpr(ImplicitCastExprClass, ty, VK, kind, op, 0) { - } + : CastExpr(ImplicitCastExprClass, ty, VK, kind, op, 0, + FPOptionsOverride()) {} bool isPartOfExplicitCast() const { return CastExprBits.PartOfExplicitCast; } void setIsPartOfExplicitCast(bool PartOfExplicitCast) { @@ -3569,10 +3632,11 @@ static ImplicitCastExpr *Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, + FPOptionsOverride FPFeatures, ExprValueKind Cat); static ImplicitCastExpr *CreateEmpty(const ASTContext &Context, - unsigned PathSize); + unsigned PathSize, bool HasFPFeatures); SourceLocation getBeginLoc() const LLVM_READONLY { return getSubExpr()->getBeginLoc(); @@ -3613,12 +3677,14 @@ protected: ExplicitCastExpr(StmtClass SC, QualType exprTy, ExprValueKind VK, CastKind kind, Expr *op, unsigned PathSize, - TypeSourceInfo *writtenTy) - : CastExpr(SC, exprTy, VK, kind, op, PathSize), TInfo(writtenTy) {} + FPOptionsOverride FPFeatures, TypeSourceInfo *writtenTy) + : CastExpr(SC, exprTy, VK, kind, op, PathSize, FPFeatures), + TInfo(writtenTy) {} /// Construct an empty explicit cast. - ExplicitCastExpr(StmtClass SC, EmptyShell Shell, unsigned PathSize) - : CastExpr(SC, Shell, PathSize) { } + ExplicitCastExpr(StmtClass SC, EmptyShell Shell, unsigned PathSize, + bool HasFPFeatures) + : CastExpr(SC, Shell, PathSize, HasFPFeatures) {} public: /// getTypeInfoAsWritten - Returns the type source info for the type @@ -3646,24 +3712,25 @@ SourceLocation RPLoc; // the location of the right paren CStyleCastExpr(QualType exprTy, ExprValueKind vk, CastKind kind, Expr *op, - unsigned PathSize, TypeSourceInfo *writtenTy, - SourceLocation l, SourceLocation r) - : ExplicitCastExpr(CStyleCastExprClass, exprTy, vk, kind, op, PathSize, - writtenTy), LPLoc(l), RPLoc(r) {} + unsigned PathSize, FPOptionsOverride FPFeatures, + TypeSourceInfo *writtenTy, SourceLocation l, SourceLocation r) + : ExplicitCastExpr(CStyleCastExprClass, exprTy, vk, kind, op, PathSize, + FPFeatures, writtenTy), + LPLoc(l), RPLoc(r) {} /// Construct an empty C-style explicit cast. - explicit CStyleCastExpr(EmptyShell Shell, unsigned PathSize) - : ExplicitCastExpr(CStyleCastExprClass, Shell, PathSize) { } + explicit CStyleCastExpr(EmptyShell Shell, unsigned PathSize, + bool HasFPFeatures) + : ExplicitCastExpr(CStyleCastExprClass, Shell, PathSize, HasFPFeatures) {} public: - static CStyleCastExpr *Create(const ASTContext &Context, QualType T, - ExprValueKind VK, CastKind K, - Expr *Op, const CXXCastPath *BasePath, - TypeSourceInfo *WrittenTy, SourceLocation L, - SourceLocation R); + static CStyleCastExpr * + Create(const ASTContext &Context, QualType T, ExprValueKind VK, CastKind K, + Expr *Op, const CXXCastPath *BasePath, FPOptionsOverride FPFeatures, + TypeSourceInfo *WrittenTy, SourceLocation L, SourceLocation R); static CStyleCastExpr *CreateEmpty(const ASTContext &Context, - unsigned PathSize); + unsigned PathSize, bool HasFPFeatures); SourceLocation getLParenLoc() const { return LPLoc; } void setLParenLoc(SourceLocation L) { LPLoc = L; } diff --git a/clang/include/clang/AST/ExprCXX.h b/clang/include/clang/AST/ExprCXX.h --- a/clang/include/clang/AST/ExprCXX.h +++ b/clang/include/clang/AST/ExprCXX.h @@ -374,16 +374,16 @@ protected: friend class ASTStmtReader; - CXXNamedCastExpr(StmtClass SC, QualType ty, ExprValueKind VK, - CastKind kind, Expr *op, unsigned PathSize, + CXXNamedCastExpr(StmtClass SC, QualType ty, ExprValueKind VK, CastKind kind, + Expr *op, unsigned PathSize, FPOptionsOverride FPFeatures, TypeSourceInfo *writtenTy, SourceLocation l, - SourceLocation RParenLoc, - SourceRange AngleBrackets) - : ExplicitCastExpr(SC, ty, VK, kind, op, PathSize, writtenTy), Loc(l), - RParenLoc(RParenLoc), AngleBrackets(AngleBrackets) {} + SourceLocation RParenLoc, SourceRange AngleBrackets) + : ExplicitCastExpr(SC, ty, VK, kind, op, PathSize, FPFeatures, writtenTy), + Loc(l), RParenLoc(RParenLoc), AngleBrackets(AngleBrackets) {} - explicit CXXNamedCastExpr(StmtClass SC, EmptyShell Shell, unsigned PathSize) - : ExplicitCastExpr(SC, Shell, PathSize) {} + explicit CXXNamedCastExpr(StmtClass SC, EmptyShell Shell, unsigned PathSize, + bool HasFPFeatures) + : ExplicitCastExpr(SC, Shell, PathSize, HasFPFeatures) {} public: const char *getCastName() const; @@ -421,27 +421,28 @@ : public CXXNamedCastExpr, private llvm::TrailingObjects { CXXStaticCastExpr(QualType ty, ExprValueKind vk, CastKind kind, Expr *op, - unsigned pathSize, TypeSourceInfo *writtenTy, - SourceLocation l, SourceLocation RParenLoc, - SourceRange AngleBrackets) + unsigned pathSize, FPOptionsOverride FPFeatures, + TypeSourceInfo *writtenTy, SourceLocation l, + SourceLocation RParenLoc, SourceRange AngleBrackets) : CXXNamedCastExpr(CXXStaticCastExprClass, ty, vk, kind, op, pathSize, - writtenTy, l, RParenLoc, AngleBrackets) {} + FPFeatures, writtenTy, l, RParenLoc, AngleBrackets) {} - explicit CXXStaticCastExpr(EmptyShell Empty, unsigned PathSize) - : CXXNamedCastExpr(CXXStaticCastExprClass, Empty, PathSize) {} + explicit CXXStaticCastExpr(EmptyShell Empty, unsigned PathSize, + bool HasFPFeatures) + : CXXNamedCastExpr(CXXStaticCastExprClass, Empty, PathSize, + HasFPFeatures) {} public: friend class CastExpr; friend TrailingObjects; - static CXXStaticCastExpr *Create(const ASTContext &Context, QualType T, - ExprValueKind VK, CastKind K, Expr *Op, - const CXXCastPath *Path, - TypeSourceInfo *Written, SourceLocation L, - SourceLocation RParenLoc, - SourceRange AngleBrackets); + static CXXStaticCastExpr * + Create(const ASTContext &Context, QualType T, ExprValueKind VK, CastKind K, + Expr *Op, const CXXCastPath *Path, FPOptionsOverride FPFeatures, + TypeSourceInfo *Written, SourceLocation L, SourceLocation RParenLoc, + SourceRange AngleBrackets); static CXXStaticCastExpr *CreateEmpty(const ASTContext &Context, - unsigned PathSize); + unsigned PathSize, bool HasFPFeatures); static bool classof(const Stmt *T) { return T->getStmtClass() == CXXStaticCastExprClass; @@ -456,15 +457,16 @@ class CXXDynamicCastExpr final : public CXXNamedCastExpr, private llvm::TrailingObjects { - CXXDynamicCastExpr(QualType ty, ExprValueKind VK, CastKind kind, - Expr *op, unsigned pathSize, TypeSourceInfo *writtenTy, + CXXDynamicCastExpr(QualType ty, ExprValueKind VK, CastKind kind, Expr *op, + unsigned pathSize, TypeSourceInfo *writtenTy, SourceLocation l, SourceLocation RParenLoc, SourceRange AngleBrackets) : CXXNamedCastExpr(CXXDynamicCastExprClass, ty, VK, kind, op, pathSize, - writtenTy, l, RParenLoc, AngleBrackets) {} + FPOptionsOverride(), writtenTy, l, RParenLoc, + AngleBrackets) {} explicit CXXDynamicCastExpr(EmptyShell Empty, unsigned pathSize) - : CXXNamedCastExpr(CXXDynamicCastExprClass, Empty, pathSize) {} + : CXXNamedCastExpr(CXXDynamicCastExprClass, Empty, pathSize, false) {} public: friend class CastExpr; @@ -499,16 +501,16 @@ : public CXXNamedCastExpr, private llvm::TrailingObjects { - CXXReinterpretCastExpr(QualType ty, ExprValueKind vk, CastKind kind, - Expr *op, unsigned pathSize, - TypeSourceInfo *writtenTy, SourceLocation l, - SourceLocation RParenLoc, + CXXReinterpretCastExpr(QualType ty, ExprValueKind vk, CastKind kind, Expr *op, + unsigned pathSize, TypeSourceInfo *writtenTy, + SourceLocation l, SourceLocation RParenLoc, SourceRange AngleBrackets) : CXXNamedCastExpr(CXXReinterpretCastExprClass, ty, vk, kind, op, - pathSize, writtenTy, l, RParenLoc, AngleBrackets) {} + pathSize, FPOptionsOverride(), writtenTy, l, RParenLoc, + AngleBrackets) {} CXXReinterpretCastExpr(EmptyShell Empty, unsigned pathSize) - : CXXNamedCastExpr(CXXReinterpretCastExprClass, Empty, pathSize) {} + : CXXNamedCastExpr(CXXReinterpretCastExprClass, Empty, pathSize, false) {} public: friend class CastExpr; @@ -541,11 +543,12 @@ CXXConstCastExpr(QualType ty, ExprValueKind VK, Expr *op, TypeSourceInfo *writtenTy, SourceLocation l, SourceLocation RParenLoc, SourceRange AngleBrackets) - : CXXNamedCastExpr(CXXConstCastExprClass, ty, VK, CK_NoOp, op, - 0, writtenTy, l, RParenLoc, AngleBrackets) {} + : CXXNamedCastExpr(CXXConstCastExprClass, ty, VK, CK_NoOp, op, 0, + FPOptionsOverride(), writtenTy, l, RParenLoc, + AngleBrackets) {} explicit CXXConstCastExpr(EmptyShell Empty) - : CXXNamedCastExpr(CXXConstCastExprClass, Empty, 0) {} + : CXXNamedCastExpr(CXXConstCastExprClass, Empty, 0, false) {} public: friend class CastExpr; @@ -578,10 +581,11 @@ TypeSourceInfo *writtenTy, SourceLocation l, SourceLocation RParenLoc, SourceRange AngleBrackets) : CXXNamedCastExpr(CXXAddrspaceCastExprClass, ty, VK, Kind, op, 0, - writtenTy, l, RParenLoc, AngleBrackets) {} + FPOptionsOverride(), writtenTy, l, RParenLoc, + AngleBrackets) {} explicit CXXAddrspaceCastExpr(EmptyShell Empty) - : CXXNamedCastExpr(CXXAddrspaceCastExprClass, Empty, 0) {} + : CXXNamedCastExpr(CXXAddrspaceCastExprClass, Empty, 0, false) {} public: friend class CastExpr; @@ -1698,29 +1702,30 @@ SourceLocation RParenLoc; CXXFunctionalCastExpr(QualType ty, ExprValueKind VK, - TypeSourceInfo *writtenTy, - CastKind kind, Expr *castExpr, unsigned pathSize, - SourceLocation lParenLoc, SourceLocation rParenLoc) - : ExplicitCastExpr(CXXFunctionalCastExprClass, ty, VK, kind, - castExpr, pathSize, writtenTy), + TypeSourceInfo *writtenTy, CastKind kind, + Expr *castExpr, unsigned pathSize, + FPOptionsOverride FPFeatures, SourceLocation lParenLoc, + SourceLocation rParenLoc) + : ExplicitCastExpr(CXXFunctionalCastExprClass, ty, VK, kind, castExpr, + pathSize, FPFeatures, writtenTy), LParenLoc(lParenLoc), RParenLoc(rParenLoc) {} - explicit CXXFunctionalCastExpr(EmptyShell Shell, unsigned PathSize) - : ExplicitCastExpr(CXXFunctionalCastExprClass, Shell, PathSize) {} + explicit CXXFunctionalCastExpr(EmptyShell Shell, unsigned PathSize, + bool HasFPFeatures) + : ExplicitCastExpr(CXXFunctionalCastExprClass, Shell, PathSize, + HasFPFeatures) {} public: friend class CastExpr; friend TrailingObjects; - static CXXFunctionalCastExpr *Create(const ASTContext &Context, QualType T, - ExprValueKind VK, - TypeSourceInfo *Written, - CastKind Kind, Expr *Op, - const CXXCastPath *Path, - SourceLocation LPLoc, - SourceLocation RPLoc); - static CXXFunctionalCastExpr *CreateEmpty(const ASTContext &Context, - unsigned PathSize); + static CXXFunctionalCastExpr * + Create(const ASTContext &Context, QualType T, ExprValueKind VK, + TypeSourceInfo *Written, CastKind Kind, Expr *Op, + const CXXCastPath *Path, FPOptionsOverride FPFeatures, + SourceLocation LPLoc, SourceLocation RPLoc); + static CXXFunctionalCastExpr * + CreateEmpty(const ASTContext &Context, unsigned PathSize, bool HasFPFeatures); SourceLocation getLParenLoc() const { return LParenLoc; } void setLParenLoc(SourceLocation L) { LParenLoc = L; } @@ -4829,10 +4834,10 @@ TypeSourceInfo *DstType, SourceLocation KWLoc, SourceLocation RParenLoc) : ExplicitCastExpr(BuiltinBitCastExprClass, T, VK, CK, SrcExpr, 0, - DstType), + FPOptionsOverride(), DstType), KWLoc(KWLoc), RParenLoc(RParenLoc) {} BuiltinBitCastExpr(EmptyShell Empty) - : ExplicitCastExpr(BuiltinBitCastExprClass, Empty, 0) {} + : ExplicitCastExpr(BuiltinBitCastExprClass, Empty, 0, false) {} SourceLocation getBeginLoc() const LLVM_READONLY { return KWLoc; } SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; } diff --git a/clang/include/clang/AST/ExprObjC.h b/clang/include/clang/AST/ExprObjC.h --- a/clang/include/clang/AST/ExprObjC.h +++ b/clang/include/clang/AST/ExprObjC.h @@ -1639,12 +1639,12 @@ CastKind CK, SourceLocation BridgeKeywordLoc, TypeSourceInfo *TSInfo, Expr *Operand) : ExplicitCastExpr(ObjCBridgedCastExprClass, TSInfo->getType(), VK_RValue, - CK, Operand, 0, TSInfo), + CK, Operand, 0, FPOptionsOverride(), TSInfo), LParenLoc(LParenLoc), BridgeKeywordLoc(BridgeKeywordLoc), Kind(Kind) {} /// Construct an empty Objective-C bridged cast. explicit ObjCBridgedCastExpr(EmptyShell Shell) - : ExplicitCastExpr(ObjCBridgedCastExprClass, Shell, 0) {} + : ExplicitCastExpr(ObjCBridgedCastExprClass, Shell, 0, false) {} SourceLocation getLParenLoc() const { return LParenLoc; } diff --git a/clang/include/clang/AST/Stmt.h b/clang/include/clang/AST/Stmt.h --- a/clang/include/clang/AST/Stmt.h +++ b/clang/include/clang/AST/Stmt.h @@ -521,6 +521,11 @@ unsigned Kind : 6; unsigned PartOfExplicitCast : 1; // Only set for ImplicitCastExpr. + /// This is only meaningful for operations on floating point + /// types when additional values need to be in trailing storage. + /// It is 0 otherwise. + unsigned HasFPFeatures : 1; + /// The number of CXXBaseSpecifiers in the cast. 14 bits would be enough /// here. ([implimits] Direct and indirect base classes [16384]). unsigned BasePathSize; diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp --- a/clang/lib/AST/ASTImporter.cpp +++ b/clang/lib/AST/ASTImporter.cpp @@ -6930,7 +6930,7 @@ return ImplicitCastExpr::Create( Importer.getToContext(), *ToTypeOrErr, E->getCastKind(), *ToSubExprOrErr, - &(*ToBasePathOrErr), E->getValueKind()); + &(*ToBasePathOrErr), FPOptionsOverride(), E->getValueKind()); // XXXFIXME } ExpectedStmt ASTNodeImporter::VisitExplicitCastExpr(ExplicitCastExpr *E) { @@ -6957,8 +6957,8 @@ return ToRParenLocOrErr.takeError(); return CStyleCastExpr::Create( Importer.getToContext(), ToType, E->getValueKind(), E->getCastKind(), - ToSubExpr, ToBasePath, ToTypeInfoAsWritten, *ToLParenLocOrErr, - *ToRParenLocOrErr); + ToSubExpr, ToBasePath, FPOptionsOverride() /*XXXFIXME*/, + ToTypeInfoAsWritten, *ToLParenLocOrErr, *ToRParenLocOrErr); } case Stmt::CXXFunctionalCastExprClass: { @@ -6971,7 +6971,8 @@ return ToRParenLocOrErr.takeError(); return CXXFunctionalCastExpr::Create( Importer.getToContext(), ToType, E->getValueKind(), ToTypeInfoAsWritten, - E->getCastKind(), ToSubExpr, ToBasePath, *ToLParenLocOrErr, + E->getCastKind(), ToSubExpr, ToBasePath, FPOptionsOverride(), + *ToLParenLocOrErr, // XXXFIXME *ToRParenLocOrErr); } @@ -7818,6 +7819,7 @@ if (isa(E)) { return CXXStaticCastExpr::Create( Importer.getToContext(), ToType, VK, CK, ToSubExpr, &(*ToBasePathOrErr), + FPOptionsOverride(), // XXXFIXME ToTypeInfoAsWritten, ToOperatorLoc, ToRParenLoc, ToAngleBrackets); } else if (isa(E)) { return CXXDynamicCastExpr::Create( diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp --- a/clang/lib/AST/Expr.cpp +++ b/clang/lib/AST/Expr.cpp @@ -1800,6 +1800,42 @@ llvm_unreachable("Unhandled cast kind!"); } +#if 0 /* { */ +//KPN +size_t CastExpr::offsetToTrailingObjects(StmtClass SC) const { + switch (SC) { + case CastExprClass: + return sizeof(CastExpr); + case ExplicitCastExprClass: + return sizeof(ExplicitCastExpr); + case BuiltinBitCastExprClass: + return sizeof(BuiltinBitCastExpr); + case CStyleCastExprClass: + return sizeof(CStyleCastExpr); + case CXXFunctionalCastExprClass: + return sizeof(CXXFunctionalCastExpr); + case CXXNamedCastExprCastExprClass: + return sizeof(CXXNamedCastExprCastExpr); + case CXXAddrspaceCastExprCastExprClass: + return sizeof(CXXAddrspaceCastExprCastExpr); + case CXXConstCastExprCastExprClass: + return sizeof(CXXConstCastExprCastExpr); + case CXXDynamicCastExprCastExprClass: + return sizeof(CXXDynamicCastExprCastExpr); + case CXXReinterpretCastExprClass: + return sizeof(CXXReinterpretCastExpr); + case CXXStaticCastExprCastExprClass: + return CXXStaticCastExprsizeof(CastExpr); + case ObjCBridgedCastExprCastExprClass: + return sizeof(ObjCBridgedCastExprCastExpr); + case ImplicitCastExprCastExprClass: + return sizeof(ImplicitCastExprCastExpr); + default: + llvm_unreachable("unexpected class deriving from CastExpr!"); + } +} +#endif /* } */ + namespace { const Expr *skipImplicitTemporary(const Expr *E) { // Skip through reference binding to temporary. @@ -1894,16 +1930,21 @@ ImplicitCastExpr *ImplicitCastExpr::Create(const ASTContext &C, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, + FPOptionsOverride FPFeatures, ExprValueKind VK) { unsigned PathSize = (BasePath ? BasePath->size() : 0); - void *Buffer = C.Allocate(totalSizeToAlloc(PathSize)); + unsigned BasePathSize = additionalSizeToAlloc(PathSize); + void *Buffer = + C.Allocate(sizeof(ImplicitCastExpr) + + ImplicitCastExpr::sizeOfTrailingObjects( + BasePathSize, FPFeatures.requiresTrailingStorage())); // Per C++ [conv.lval]p3, lvalue-to-rvalue conversions on class and // std::nullptr_t have special semantics not captured by CK_LValueToRValue. assert((Kind != CK_LValueToRValue || !(T->isNullPtrType() || T->getAsCXXRecordDecl())) && "invalid type for lvalue-to-rvalue conversion"); ImplicitCastExpr *E = - new (Buffer) ImplicitCastExpr(T, Kind, Operand, PathSize, VK); + new (Buffer) ImplicitCastExpr(T, Kind, Operand, PathSize, FPFeatures, VK); if (PathSize) std::uninitialized_copy_n(BasePath->data(), BasePath->size(), E->getTrailingObjects()); @@ -1911,21 +1952,29 @@ } ImplicitCastExpr *ImplicitCastExpr::CreateEmpty(const ASTContext &C, - unsigned PathSize) { - void *Buffer = C.Allocate(totalSizeToAlloc(PathSize)); - return new (Buffer) ImplicitCastExpr(EmptyShell(), PathSize); + unsigned PathSize, + bool HasFPFeatures) { + unsigned BasePathSize = additionalSizeToAlloc(PathSize); + void *Buffer = C.Allocate( + sizeof(ImplicitCastExpr) + + ImplicitCastExpr::sizeOfTrailingObjects(BasePathSize, HasFPFeatures)); + return new (Buffer) ImplicitCastExpr(EmptyShell(), PathSize, HasFPFeatures); } - CStyleCastExpr *CStyleCastExpr::Create(const ASTContext &C, QualType T, ExprValueKind VK, CastKind K, Expr *Op, const CXXCastPath *BasePath, + FPOptionsOverride FPFeatures, TypeSourceInfo *WrittenTy, SourceLocation L, SourceLocation R) { unsigned PathSize = (BasePath ? BasePath->size() : 0); - void *Buffer = C.Allocate(totalSizeToAlloc(PathSize)); - CStyleCastExpr *E = - new (Buffer) CStyleCastExpr(T, VK, K, Op, PathSize, WrittenTy, L, R); + unsigned BasePathSize = additionalSizeToAlloc(PathSize); + void *Buffer = + C.Allocate(sizeof(CStyleCastExpr) + + CStyleCastExpr::sizeOfTrailingObjects( + BasePathSize, FPFeatures.requiresTrailingStorage())); + CStyleCastExpr *E = new (Buffer) + CStyleCastExpr(T, VK, K, Op, PathSize, FPFeatures, WrittenTy, L, R); if (PathSize) std::uninitialized_copy_n(BasePath->data(), BasePath->size(), E->getTrailingObjects()); @@ -1933,9 +1982,13 @@ } CStyleCastExpr *CStyleCastExpr::CreateEmpty(const ASTContext &C, - unsigned PathSize) { - void *Buffer = C.Allocate(totalSizeToAlloc(PathSize)); - return new (Buffer) CStyleCastExpr(EmptyShell(), PathSize); + unsigned PathSize, + bool HasFPFeatures) { + unsigned BasePathSize = additionalSizeToAlloc(PathSize); + void *Buffer = + C.Allocate(sizeof(CStyleCastExpr) + CStyleCastExpr::sizeOfTrailingObjects( + BasePathSize, HasFPFeatures)); + return new (Buffer) CStyleCastExpr(EmptyShell(), PathSize, HasFPFeatures); } /// getOpcodeStr - Turn an Opcode enum value into the punctuation char it diff --git a/clang/lib/AST/ExprCXX.cpp b/clang/lib/AST/ExprCXX.cpp --- a/clang/lib/AST/ExprCXX.cpp +++ b/clang/lib/AST/ExprCXX.cpp @@ -690,19 +690,21 @@ } } -CXXStaticCastExpr *CXXStaticCastExpr::Create(const ASTContext &C, QualType T, - ExprValueKind VK, - CastKind K, Expr *Op, - const CXXCastPath *BasePath, - TypeSourceInfo *WrittenTy, - SourceLocation L, - SourceLocation RParenLoc, - SourceRange AngleBrackets) { +CXXStaticCastExpr * +CXXStaticCastExpr::Create(const ASTContext &C, QualType T, ExprValueKind VK, + CastKind K, Expr *Op, const CXXCastPath *BasePath, + FPOptionsOverride FPFeatures, + TypeSourceInfo *WrittenTy, SourceLocation L, + SourceLocation RParenLoc, SourceRange AngleBrackets) { unsigned PathSize = (BasePath ? BasePath->size() : 0); - void *Buffer = C.Allocate(totalSizeToAlloc(PathSize)); + unsigned BasePathSize = additionalSizeToAlloc(PathSize); + void *Buffer = + C.Allocate(sizeof(CXXStaticCastExpr) + + CXXStaticCastExpr::sizeOfTrailingObjects( + BasePathSize, FPFeatures.requiresTrailingStorage())); auto *E = - new (Buffer) CXXStaticCastExpr(T, VK, K, Op, PathSize, WrittenTy, L, - RParenLoc, AngleBrackets); + new (Buffer) CXXStaticCastExpr(T, VK, K, Op, PathSize, FPFeatures, + WrittenTy, L, RParenLoc, AngleBrackets); if (PathSize) std::uninitialized_copy_n(BasePath->data(), BasePath->size(), E->getTrailingObjects()); @@ -710,9 +712,13 @@ } CXXStaticCastExpr *CXXStaticCastExpr::CreateEmpty(const ASTContext &C, - unsigned PathSize) { - void *Buffer = C.Allocate(totalSizeToAlloc(PathSize)); - return new (Buffer) CXXStaticCastExpr(EmptyShell(), PathSize); + unsigned PathSize, + bool HasFPFeatures) { + unsigned BasePathSize = additionalSizeToAlloc(PathSize); + void *Buffer = C.Allocate( + sizeof(CXXStaticCastExpr) + + CXXStaticCastExpr::sizeOfTrailingObjects(BasePathSize, HasFPFeatures)); + return new (Buffer) CXXStaticCastExpr(EmptyShell(), PathSize, HasFPFeatures); } CXXDynamicCastExpr *CXXDynamicCastExpr::Create(const ASTContext &C, QualType T, @@ -823,25 +829,33 @@ return new (C) CXXAddrspaceCastExpr(EmptyShell()); } -CXXFunctionalCastExpr * -CXXFunctionalCastExpr::Create(const ASTContext &C, QualType T, ExprValueKind VK, - TypeSourceInfo *Written, CastKind K, Expr *Op, - const CXXCastPath *BasePath, - SourceLocation L, SourceLocation R) { +CXXFunctionalCastExpr *CXXFunctionalCastExpr::Create( + const ASTContext &C, QualType T, ExprValueKind VK, TypeSourceInfo *Written, + CastKind K, Expr *Op, const CXXCastPath *BasePath, + FPOptionsOverride FPFeatures, SourceLocation L, SourceLocation R) { unsigned PathSize = (BasePath ? BasePath->size() : 0); - void *Buffer = C.Allocate(totalSizeToAlloc(PathSize)); - auto *E = - new (Buffer) CXXFunctionalCastExpr(T, VK, Written, K, Op, PathSize, L, R); + unsigned BasePathSize = additionalSizeToAlloc(PathSize); + void *Buffer = + C.Allocate(sizeof(CXXFunctionalCastExpr) + + CXXFunctionalCastExpr::sizeOfTrailingObjects( + BasePathSize, FPFeatures.requiresTrailingStorage())); + auto *E = new (Buffer) + CXXFunctionalCastExpr(T, VK, Written, K, Op, PathSize, FPFeatures, L, R); if (PathSize) std::uninitialized_copy_n(BasePath->data(), BasePath->size(), E->getTrailingObjects()); return E; } -CXXFunctionalCastExpr * -CXXFunctionalCastExpr::CreateEmpty(const ASTContext &C, unsigned PathSize) { - void *Buffer = C.Allocate(totalSizeToAlloc(PathSize)); - return new (Buffer) CXXFunctionalCastExpr(EmptyShell(), PathSize); +CXXFunctionalCastExpr *CXXFunctionalCastExpr::CreateEmpty(const ASTContext &C, + unsigned PathSize, + bool HasFPFeatures) { + unsigned BasePathSize = additionalSizeToAlloc(PathSize); + void *Buffer = C.Allocate(sizeof(CXXFunctionalCastExpr) + + CXXFunctionalCastExpr::sizeOfTrailingObjects( + BasePathSize, HasFPFeatures)); + return new (Buffer) + CXXFunctionalCastExpr(EmptyShell(), PathSize, HasFPFeatures); } SourceLocation CXXFunctionalCastExpr::getBeginLoc() const { diff --git a/clang/lib/Analysis/BodyFarm.cpp b/clang/lib/Analysis/BodyFarm.cpp --- a/clang/lib/Analysis/BodyFarm.cpp +++ b/clang/lib/Analysis/BodyFarm.cpp @@ -166,10 +166,11 @@ ImplicitCastExpr *ASTMaker::makeImplicitCast(const Expr *Arg, QualType Ty, CastKind CK) { return ImplicitCastExpr::Create(C, Ty, - /* CastKind=*/ CK, - /* Expr=*/ const_cast(Arg), - /* CXXCastPath=*/ nullptr, - /* ExprValueKind=*/ VK_RValue); + /* CastKind=*/CK, + /* Expr=*/const_cast(Arg), + /* CXXCastPath=*/nullptr, + FPOptionsOverride(), // XXXFIXME + /* ExprValueKind=*/VK_RValue); } Expr *ASTMaker::makeIntegralCast(const Expr *Arg, QualType Ty) { @@ -177,12 +178,14 @@ return const_cast(Arg); return ImplicitCastExpr::Create(C, Ty, CK_IntegralCast, - const_cast(Arg), nullptr, VK_RValue); + const_cast(Arg), nullptr, + FPOptionsOverride(), VK_RValue); // XXXFIXME } ImplicitCastExpr *ASTMaker::makeIntegralCastToBoolean(const Expr *Arg) { return ImplicitCastExpr::Create(C, C.BoolTy, CK_IntegralToBoolean, - const_cast(Arg), nullptr, VK_RValue); + const_cast(Arg), nullptr, + FPOptionsOverride(), VK_RValue); // XXXFIXME } ObjCBoolLiteralExpr *ASTMaker::makeObjCBool(bool Val) { diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp --- a/clang/lib/CodeGen/CGStmtOpenMP.cpp +++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp @@ -4137,6 +4137,7 @@ PrivateVD->setInitStyle(VarDecl::CInit); PrivateVD->setInit(ImplicitCastExpr::Create(C, ElemType, CK_LValueToRValue, InitRef, /*BasePath=*/nullptr, + FPOptionsOverride(), // XXXFIXME VK_RValue)); Data.FirstprivateVars.emplace_back(OrigRef); Data.FirstprivateCopies.emplace_back(PrivateRef); diff --git a/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp b/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp --- a/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp +++ b/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp @@ -586,6 +586,7 @@ CastKind Kind, Expr *E) { TypeSourceInfo *TInfo = Ctx->getTrivialTypeSourceInfo(Ty, SourceLocation()); return CStyleCastExpr::Create(*Ctx, Ty, VK_RValue, Kind, E, nullptr, + FPOptionsOverride(), // XXXFIXME TInfo, SourceLocation(), SourceLocation()); } @@ -2104,9 +2105,9 @@ // Now, we cast the reference to a pointer to the objc_msgSend type. QualType pToFunc = Context->getPointerType(msgSendType); - ImplicitCastExpr *ICE = - ImplicitCastExpr::Create(*Context, pToFunc, CK_FunctionToPointerDecay, - DRE, nullptr, VK_RValue); + ImplicitCastExpr *ICE = ImplicitCastExpr::Create( + *Context, pToFunc, CK_FunctionToPointerDecay, DRE, nullptr, + FPOptionsOverride(), VK_RValue); // XXXFIXME const auto *FT = msgSendType->castAs(); CallExpr *Exp = diff --git a/clang/lib/Frontend/Rewrite/RewriteObjC.cpp b/clang/lib/Frontend/Rewrite/RewriteObjC.cpp --- a/clang/lib/Frontend/Rewrite/RewriteObjC.cpp +++ b/clang/lib/Frontend/Rewrite/RewriteObjC.cpp @@ -492,6 +492,7 @@ CastKind Kind, Expr *E) { TypeSourceInfo *TInfo = Ctx->getTrivialTypeSourceInfo(Ty, SourceLocation()); return CStyleCastExpr::Create(*Ctx, Ty, VK_RValue, Kind, E, nullptr, + FPOptionsOverride(), // XXXFIXME TInfo, SourceLocation(), SourceLocation()); } @@ -2022,8 +2023,8 @@ // Now, we cast the reference to a pointer to the objc_msgSend type. QualType pToFunc = Context->getPointerType(msgSendType); ImplicitCastExpr *ICE = - ImplicitCastExpr::Create(*Context, pToFunc, CK_FunctionToPointerDecay, - DRE, nullptr, VK_RValue); + ImplicitCastExpr::Create(*Context, pToFunc, CK_FunctionToPointerDecay, + DRE, nullptr, FPOptionsOverride(), VK_RValue); const auto *FT = msgSendType->castAs(); diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp --- a/clang/lib/Sema/Sema.cpp +++ b/clang/lib/Sema/Sema.cpp @@ -585,7 +585,8 @@ } } - return ImplicitCastExpr::Create(Context, Ty, Kind, E, BasePath, VK); + return ImplicitCastExpr::Create(Context, Ty, Kind, E, BasePath, + FPOptionsOverride(), VK); // XXXFIXME } /// ScalarTypeToBooleanCastKind - Returns the cast kind corresponding diff --git a/clang/lib/Sema/SemaCast.cpp b/clang/lib/Sema/SemaCast.cpp --- a/clang/lib/Sema/SemaCast.cpp +++ b/clang/lib/Sema/SemaCast.cpp @@ -108,6 +108,7 @@ castExpr = ImplicitCastExpr::Create(Self.Context, Self.Context.ARCUnbridgedCastTy, CK_Dependent, castExpr, nullptr, + FPOptionsOverride(), // XXXFIXME castExpr->getValueKind()); } updatePartOfExplicitCastFlags(castExpr); @@ -361,11 +362,10 @@ DiscardMisalignedMemberAddress(DestType.getTypePtr(), E); } - return Op.complete(CXXStaticCastExpr::Create(Context, Op.ResultType, - Op.ValueKind, Op.Kind, Op.SrcExpr.get(), - &Op.BasePath, DestTInfo, - OpLoc, Parens.getEnd(), - AngleBrackets)); + return Op.complete(CXXStaticCastExpr::Create( + Context, Op.ResultType, Op.ValueKind, Op.Kind, Op.SrcExpr.get(), + &Op.BasePath, FPOptionsOverride(), DestTInfo, // XXXFIXME + OpLoc, Parens.getEnd(), AngleBrackets)); } } } @@ -3027,9 +3027,10 @@ // -Wcast-qual DiagnoseCastQual(Op.Self, Op.SrcExpr, Op.DestType); - return Op.complete(CStyleCastExpr::Create(Context, Op.ResultType, - Op.ValueKind, Op.Kind, Op.SrcExpr.get(), - &Op.BasePath, CastTypeInfo, LPLoc, RPLoc)); + return Op.complete(CStyleCastExpr::Create( + Context, Op.ResultType, Op.ValueKind, Op.Kind, Op.SrcExpr.get(), + &Op.BasePath, FPOptionsOverride(), CastTypeInfo, LPLoc, + RPLoc)); // XXXFIXME } ExprResult Sema::BuildCXXFunctionalCastExpr(TypeSourceInfo *CastTypeInfo, @@ -3052,7 +3053,8 @@ if (auto *ConstructExpr = dyn_cast(SubExpr)) ConstructExpr->setParenOrBraceRange(SourceRange(LPLoc, RPLoc)); - return Op.complete(CXXFunctionalCastExpr::Create(Context, Op.ResultType, - Op.ValueKind, CastTypeInfo, Op.Kind, - Op.SrcExpr.get(), &Op.BasePath, LPLoc, RPLoc)); + return Op.complete(CXXFunctionalCastExpr::Create( + Context, Op.ResultType, Op.ValueKind, CastTypeInfo, Op.Kind, + Op.SrcExpr.get(), &Op.BasePath, FPOptionsOverride(), LPLoc, + RPLoc)); // XXXFIXME } diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -18172,10 +18172,10 @@ // Adjust the Expr initializer and type. if (ECD->getInitExpr() && !Context.hasSameType(NewTy, ECD->getInitExpr()->getType())) - ECD->setInitExpr(ImplicitCastExpr::Create(Context, NewTy, - CK_IntegralCast, + ECD->setInitExpr(ImplicitCastExpr::Create(Context, NewTy, CK_IntegralCast, ECD->getInitExpr(), /*base paths*/ nullptr, + FPOptionsOverride(), // XXXFIXME VK_RValue)); if (getLangOpts().CPlusPlus) // C++ [dcl.enum]p4: Following the closing brace of an diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -1184,7 +1184,8 @@ // an xvalue otherwise if (!Src->getType()->isLValueReferenceType()) E = ImplicitCastExpr::Create(S.Context, E.get()->getType(), CK_NoOp, - E.get(), nullptr, VK_XValue); + E.get(), nullptr, FPOptionsOverride(), + VK_XValue); // XXXFIXME TemplateArgumentListInfo Args(Loc, Loc); Args.addArgument( @@ -14868,9 +14869,9 @@ // (since it's unusable otherwise); in the case where we inline the // block literal, it has block literal lifetime semantics. if (!BuildBlock.isInvalid() && !getLangOpts().ObjCAutoRefCount) - BuildBlock = ImplicitCastExpr::Create(Context, BuildBlock.get()->getType(), - CK_CopyAndAutoreleaseBlockObject, - BuildBlock.get(), nullptr, VK_RValue); + BuildBlock = ImplicitCastExpr::Create( + Context, BuildBlock.get()->getType(), CK_CopyAndAutoreleaseBlockObject, + BuildBlock.get(), nullptr, FPOptionsOverride(), VK_RValue); // XXXFIXME if (BuildBlock.isInvalid()) { Diag(CurrentLocation, diag::note_lambda_to_block_conv); diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -696,7 +696,8 @@ // C++ [conv.lval]p3: // If T is cv std::nullptr_t, the result is a null pointer constant. CastKind CK = T->isNullPtrType() ? CK_NullToPointer : CK_LValueToRValue; - Res = ImplicitCastExpr::Create(Context, T, CK, E, nullptr, VK_RValue); + Res = ImplicitCastExpr::Create(Context, T, CK, E, nullptr, + FPOptionsOverride(), VK_RValue); // XXXFIXME // C11 6.3.2.1p2: // ... if the lvalue has atomic type, the value has the non-atomic version @@ -704,7 +705,8 @@ if (const AtomicType *Atomic = T->getAs()) { T = Atomic->getValueType().getUnqualifiedType(); Res = ImplicitCastExpr::Create(Context, T, CK_AtomicToNonAtomic, Res.get(), - nullptr, VK_RValue); + nullptr, FPOptionsOverride(), + VK_RValue); // XXXFIXME } return Res; @@ -6964,9 +6966,9 @@ // Only do this in an r-value context. if (!getLangOpts().ObjCAutoRefCount) return; - E = ImplicitCastExpr::Create(Context, E.get()->getType(), - CK_ARCExtendBlockObject, E.get(), - /*base path*/ nullptr, VK_RValue); + E = ImplicitCastExpr::Create( + Context, E.get()->getType(), CK_ARCExtendBlockObject, E.get(), + /*base path*/ nullptr, FPOptionsOverride(), VK_RValue); // XXXFIXME Cleanup.setExprNeedsCleanups(true); } diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -1503,7 +1503,8 @@ : SourceRange(LParenOrBraceLoc, RParenOrBraceLoc); Result = CXXFunctionalCastExpr::Create( Context, ResultType, Expr::getValueKindForType(Ty), TInfo, CK_NoOp, - Result.get(), /*Path=*/nullptr, Locs.getBegin(), Locs.getEnd()); + Result.get(), /*Path=*/nullptr, FPOptionsOverride(), Locs.getBegin(), + Locs.getEnd()); // XXXFIXME } return Result; @@ -3917,7 +3918,8 @@ // Record usage of conversion in an implicit cast. Result = ImplicitCastExpr::Create(S.Context, Result.get()->getType(), CK_UserDefinedConversion, Result.get(), - nullptr, Result.get()->getValueKind()); + nullptr, FPOptionsOverride(), + Result.get()->getValueKind()); // XXXFIXME return S.MaybeBindToTemporary(Result.get()); } @@ -4097,8 +4099,9 @@ case ICK_Identity: if (const AtomicType *FromAtomic = FromType->getAs()) { FromType = FromAtomic->getValueType().getUnqualifiedType(); - From = ImplicitCastExpr::Create(Context, FromType, CK_AtomicToNonAtomic, - From, /*BasePath=*/nullptr, VK_RValue); + From = ImplicitCastExpr::Create( + Context, FromType, CK_AtomicToNonAtomic, From, /*BasePath=*/nullptr, + FPOptionsOverride(), VK_RValue); // XXXFIXME } break; @@ -6836,6 +6839,7 @@ CastKind ck = (ReturnsRetained ? CK_ARCConsumeObject : CK_ARCReclaimReturnedObject); return ImplicitCastExpr::Create(Context, E->getType(), ck, E, nullptr, + FPOptionsOverride(), // XXXFIXME VK_RValue); } diff --git a/clang/lib/Sema/SemaExprObjC.cpp b/clang/lib/Sema/SemaExprObjC.cpp --- a/clang/lib/Sema/SemaExprObjC.cpp +++ b/clang/lib/Sema/SemaExprObjC.cpp @@ -4461,9 +4461,9 @@ // If the result is +1, consume it here. case ACC_plusOne: - castExpr = ImplicitCastExpr::Create(Context, castExpr->getType(), - CK_ARCConsumeObject, castExpr, - nullptr, VK_RValue); + castExpr = ImplicitCastExpr::Create( + Context, castExpr->getType(), CK_ARCConsumeObject, castExpr, nullptr, + FPOptionsOverride(), VK_RValue); // XXXFIXME Cleanup.setExprNeedsCleanups(true); return ACR_okay; } @@ -4689,9 +4689,9 @@ case OBC_BridgeRetained: // Produce the object before casting it. - SubExpr = ImplicitCastExpr::Create(Context, FromType, - CK_ARCProduceObject, - SubExpr, nullptr, VK_RValue); + SubExpr = ImplicitCastExpr::Create(Context, FromType, CK_ARCProduceObject, + SubExpr, nullptr, FPOptionsOverride(), + VK_RValue); // XXXFIXME break; case OBC_BridgeTransfer: { @@ -4730,7 +4730,8 @@ if (MustConsume) { Cleanup.setExprNeedsCleanups(true); Result = ImplicitCastExpr::Create(Context, T, CK_ARCConsumeObject, Result, - nullptr, VK_RValue); + nullptr, FPOptionsOverride(), + VK_RValue); // XXXFIXME } return Result; diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -2891,7 +2891,8 @@ Context, CodeUnit, PromotedCharTy, SubExpr->getExprLoc()); if (CharTy != PromotedCharTy) Init = ImplicitCastExpr::Create(Context, CharTy, CK_IntegralCast, - Init, nullptr, VK_RValue); + Init, nullptr, FPOptionsOverride(), + VK_RValue); // XXXFIXME StructuredList->updateInit(Context, i, Init); } } else { @@ -2913,7 +2914,8 @@ Context, CodeUnit, PromotedCharTy, SubExpr->getExprLoc()); if (CharTy != PromotedCharTy) Init = ImplicitCastExpr::Create(Context, CharTy, CK_IntegralCast, - Init, nullptr, VK_RValue); + Init, nullptr, FPOptionsOverride(), + VK_RValue); // XXXFIXME StructuredList->updateInit(Context, i, Init); } } @@ -8019,9 +8021,9 @@ (Step->Kind == SK_CastDerivedToBaseXValue ? VK_XValue : VK_RValue); - CurInit = - ImplicitCastExpr::Create(S.Context, Step->Type, CK_DerivedToBase, - CurInit.get(), &BasePath, VK); + CurInit = ImplicitCastExpr::Create( + S.Context, Step->Type, CK_DerivedToBase, CurInit.get(), &BasePath, + FPOptionsOverride(), VK); // XXXFIXME break; } @@ -8152,6 +8154,7 @@ CurInit = ImplicitCastExpr::Create(S.Context, CurInit.get()->getType(), CastKind, CurInit.get(), nullptr, + FPOptionsOverride(), // XXXFIXME CurInit.get()->getValueKind()); if (shouldBindAsTemporary(Entity)) @@ -8493,9 +8496,9 @@ break; case SK_ProduceObjCObject: - CurInit = - ImplicitCastExpr::Create(S.Context, Step->Type, CK_ARCProduceObject, - CurInit.get(), nullptr, VK_RValue); + CurInit = ImplicitCastExpr::Create( + S.Context, Step->Type, CK_ARCProduceObject, CurInit.get(), nullptr, + FPOptionsOverride(), VK_RValue); // XXXFIXME break; case SK_StdInitializerList: { @@ -8549,9 +8552,10 @@ // Case 1b and 1c // No cast from integer to sampler is needed. if (!Var->hasGlobalStorage()) { - CurInit = ImplicitCastExpr::Create(S.Context, Step->Type, - CK_LValueToRValue, Init, - /*BasePath=*/nullptr, VK_RValue); + CurInit = ImplicitCastExpr::Create( + S.Context, Step->Type, CK_LValueToRValue, Init, + /*BasePath=*/nullptr, FPOptionsOverride(), + VK_RValue); // XXXFIXME break; } // Case 1a diff --git a/clang/lib/Sema/SemaLambda.cpp b/clang/lib/Sema/SemaLambda.cpp --- a/clang/lib/Sema/SemaLambda.cpp +++ b/clang/lib/Sema/SemaLambda.cpp @@ -680,8 +680,9 @@ ExprWithCleanups *cleanups = dyn_cast(retValue); Expr *E = (cleanups ? cleanups->getSubExpr() : retValue); - E = ImplicitCastExpr::Create(S.Context, returnType, CK_IntegralCast, - E, /*base path*/ nullptr, VK_RValue); + E = ImplicitCastExpr::Create(S.Context, returnType, CK_IntegralCast, E, + /*base path*/ nullptr, FPOptionsOverride(), + VK_RValue); // XXXFIXME if (cleanups) { cleanups->setSubExpr(E); } else { diff --git a/clang/lib/Sema/SemaObjCProperty.cpp b/clang/lib/Sema/SemaObjCProperty.cpp --- a/clang/lib/Sema/SemaObjCProperty.cpp +++ b/clang/lib/Sema/SemaObjCProperty.cpp @@ -1464,10 +1464,10 @@ DeclRefExpr(Context, SelfDecl, false, SelfDecl->getType(), VK_LValue, PropertyDiagLoc); MarkDeclRefReferenced(SelfExpr); - Expr *LoadSelfExpr = - ImplicitCastExpr::Create(Context, SelfDecl->getType(), - CK_LValueToRValue, SelfExpr, nullptr, - VK_RValue); + Expr *LoadSelfExpr = ImplicitCastExpr::Create( + Context, SelfDecl->getType(), CK_LValueToRValue, SelfExpr, nullptr, + FPOptionsOverride(), // XXXFIXME + VK_RValue); Expr *IvarRefExpr = new (Context) ObjCIvarRefExpr(Ivar, Ivar->getUsageType(SelfDecl->getType()), @@ -1528,10 +1528,10 @@ DeclRefExpr(Context, SelfDecl, false, SelfDecl->getType(), VK_LValue, PropertyDiagLoc); MarkDeclRefReferenced(SelfExpr); - Expr *LoadSelfExpr = - ImplicitCastExpr::Create(Context, SelfDecl->getType(), - CK_LValueToRValue, SelfExpr, nullptr, - VK_RValue); + Expr *LoadSelfExpr = ImplicitCastExpr::Create( + Context, SelfDecl->getType(), CK_LValueToRValue, SelfExpr, nullptr, + FPOptionsOverride(), // XXXFIXME + VK_RValue); Expr *lhs = new (Context) ObjCIvarRefExpr(Ivar, Ivar->getUsageType(SelfDecl->getType()), diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -15337,12 +15337,12 @@ if (!BasePath.empty()) { LHS = S.DefaultLvalueConversion(LHS.get()); RHS = S.DefaultLvalueConversion(RHS.get()); - LHS = ImplicitCastExpr::Create(Context, PtrRedTy, - CK_UncheckedDerivedToBase, LHS.get(), - &BasePath, LHS.get()->getValueKind()); - RHS = ImplicitCastExpr::Create(Context, PtrRedTy, - CK_UncheckedDerivedToBase, RHS.get(), - &BasePath, RHS.get()->getValueKind()); + LHS = ImplicitCastExpr::Create( + Context, PtrRedTy, CK_UncheckedDerivedToBase, LHS.get(), &BasePath, + FPOptionsOverride(), LHS.get()->getValueKind()); // XXXFIXME + RHS = ImplicitCastExpr::Create( + Context, PtrRedTy, CK_UncheckedDerivedToBase, RHS.get(), &BasePath, + FPOptionsOverride(), RHS.get()->getValueKind()); // XXXFIXME } FunctionProtoType::ExtProtoInfo EPI; QualType Params[] = {PtrRedTy, PtrRedTy}; diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -5833,7 +5833,8 @@ // Record usage of conversion in an implicit cast. From = ImplicitCastExpr::Create(SemaRef.Context, Result.get()->getType(), CK_UserDefinedConversion, Result.get(), - nullptr, Result.get()->getValueKind()); + nullptr, FPOptionsOverride(), + Result.get()->getValueKind()); // XXXFIXME } return false; } @@ -5862,7 +5863,8 @@ // Record usage of conversion in an implicit cast. From = ImplicitCastExpr::Create(SemaRef.Context, Result.get()->getType(), CK_UserDefinedConversion, Result.get(), - nullptr, Result.get()->getValueKind()); + nullptr, FPOptionsOverride(), + Result.get()->getValueKind()); // XXXFIXME return false; } @@ -14393,9 +14395,9 @@ if (Call.isInvalid()) return ExprError(); // Record usage of conversion in an implicit cast. - Call = ImplicitCastExpr::Create(Context, Call.get()->getType(), - CK_UserDefinedConversion, Call.get(), - nullptr, VK_RValue); + Call = ImplicitCastExpr::Create( + Context, Call.get()->getType(), CK_UserDefinedConversion, Call.get(), + nullptr, FPOptionsOverride(), VK_RValue); // XXXFIXME return BuildCallExpr(S, Call.get(), LParenLoc, Args, RParenLoc); } @@ -14800,9 +14802,9 @@ if (SubExpr == ICE->getSubExpr()) return ICE; - return ImplicitCastExpr::Create(Context, ICE->getType(), - ICE->getCastKind(), + return ImplicitCastExpr::Create(Context, ICE->getType(), ICE->getCastKind(), SubExpr, nullptr, + FPOptionsOverride(), // XXXFIXME ICE->getValueKind()); } diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp --- a/clang/lib/Sema/SemaStmt.cpp +++ b/clang/lib/Sema/SemaStmt.cpp @@ -3139,7 +3139,8 @@ // Promote "AsRvalue" to the heap, since we now need this // expression node to persist. Value = ImplicitCastExpr::Create(S.Context, Value->getType(), CK_NoOp, - Value, nullptr, VK_XValue); + Value, nullptr, FPOptionsOverride(), + VK_XValue); // XXXFIXME // Complete type-checking the initialization of the return type // using the constructor we found. diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -7478,7 +7478,7 @@ // FIXME: This is a hack. We need a better way to handle substituted // non-type template parameters. E = CStyleCastExpr::Create(Context, OrigT, VK_RValue, CK_IntegralCast, E, - nullptr, + nullptr, FPOptionsOverride(), // XXXFIXME Context.getTrivialTypeSourceInfo(OrigT, Loc), Loc, Loc); } diff --git a/clang/lib/Serialization/ASTReaderStmt.cpp b/clang/lib/Serialization/ASTReaderStmt.cpp --- a/clang/lib/Serialization/ASTReaderStmt.cpp +++ b/clang/lib/Serialization/ASTReaderStmt.cpp @@ -2890,13 +2890,17 @@ break; case EXPR_IMPLICIT_CAST: - S = ImplicitCastExpr::CreateEmpty(Context, - /*PathSize*/ Record[ASTStmtReader::NumExprFields]); + S = ImplicitCastExpr::CreateEmpty( + Context, + /*PathSize*/ Record[ASTStmtReader::NumExprFields], + false); // XXXFIXME FPOptionsOverride break; case EXPR_CSTYLE_CAST: - S = CStyleCastExpr::CreateEmpty(Context, - /*PathSize*/ Record[ASTStmtReader::NumExprFields]); + S = CStyleCastExpr::CreateEmpty( + Context, + /*PathSize*/ Record[ASTStmtReader::NumExprFields], + false); // XXXFIXME FPOptionsOverride break; case EXPR_COMPOUND_LITERAL: @@ -3498,8 +3502,10 @@ break; case EXPR_CXX_STATIC_CAST: - S = CXXStaticCastExpr::CreateEmpty(Context, - /*PathSize*/ Record[ASTStmtReader::NumExprFields]); + S = CXXStaticCastExpr::CreateEmpty( + Context, + /*PathSize*/ Record[ASTStmtReader::NumExprFields], + false); // XXXFIXME FPOptionsOverride break; case EXPR_CXX_DYNAMIC_CAST: @@ -3521,8 +3527,10 @@ break; case EXPR_CXX_FUNCTIONAL_CAST: - S = CXXFunctionalCastExpr::CreateEmpty(Context, - /*PathSize*/ Record[ASTStmtReader::NumExprFields]); + S = CXXFunctionalCastExpr::CreateEmpty( + Context, + /*PathSize*/ Record[ASTStmtReader::NumExprFields], + false); // XXXFIXME FPOptionsOverride break; case EXPR_BUILTIN_BIT_CAST: