@@ -4579,25 +4579,97 @@ class ShuffleVectorExpr : public Expr {
45794579// / ConvertVectorExpr - Clang builtin function __builtin_convertvector
45804580// / This AST node provides support for converting a vector type to another
45814581// / vector type of the same arity.
4582- class ConvertVectorExpr : public Expr {
4582+ class ConvertVectorExpr final
4583+ : public Expr,
4584+ private llvm::TrailingObjects<ConvertVectorExpr, FPOptionsOverride> {
45834585private:
45844586 Stmt *SrcExpr;
45854587 TypeSourceInfo *TInfo;
45864588 SourceLocation BuiltinLoc, RParenLoc;
45874589
4590+ friend TrailingObjects;
45884591 friend class ASTReader ;
45894592 friend class ASTStmtReader ;
4590- explicit ConvertVectorExpr (EmptyShell Empty) : Expr(ConvertVectorExprClass, Empty) {}
4593+ explicit ConvertVectorExpr (bool HasFPFeatures, EmptyShell Empty)
4594+ : Expr(ConvertVectorExprClass, Empty) {
4595+ ConvertVectorExprBits.HasFPFeatures = HasFPFeatures;
4596+ }
45914597
4592- public:
45934598 ConvertVectorExpr (Expr *SrcExpr, TypeSourceInfo *TI, QualType DstType,
45944599 ExprValueKind VK, ExprObjectKind OK,
4595- SourceLocation BuiltinLoc, SourceLocation RParenLoc)
4600+ SourceLocation BuiltinLoc, SourceLocation RParenLoc,
4601+ FPOptionsOverride FPFeatures)
45964602 : Expr(ConvertVectorExprClass, DstType, VK, OK), SrcExpr(SrcExpr),
45974603 TInfo (TI), BuiltinLoc(BuiltinLoc), RParenLoc(RParenLoc) {
4604+ ConvertVectorExprBits.HasFPFeatures = FPFeatures.requiresTrailingStorage ();
4605+ if (hasStoredFPFeatures ())
4606+ setStoredFPFeatures (FPFeatures);
45984607 setDependence (computeDependence (this ));
45994608 }
46004609
4610+ size_t numTrailingObjects (OverloadToken<FPOptionsOverride>) const {
4611+ return ConvertVectorExprBits.HasFPFeatures ? 1 : 0 ;
4612+ }
4613+
4614+ FPOptionsOverride &getTrailingFPFeatures () {
4615+ assert (ConvertVectorExprBits.HasFPFeatures );
4616+ return *getTrailingObjects<FPOptionsOverride>();
4617+ }
4618+
4619+ const FPOptionsOverride &getTrailingFPFeatures () const {
4620+ assert (ConvertVectorExprBits.HasFPFeatures );
4621+ return *getTrailingObjects<FPOptionsOverride>();
4622+ }
4623+
4624+ public:
4625+ static ConvertVectorExpr *CreateEmpty (const ASTContext &C,
4626+ bool hasFPFeatures);
4627+
4628+ static ConvertVectorExpr *Create (const ASTContext &C, Expr *SrcExpr,
4629+ TypeSourceInfo *TI, QualType DstType,
4630+ ExprValueKind VK, ExprObjectKind OK,
4631+ SourceLocation BuiltinLoc,
4632+ SourceLocation RParenLoc,
4633+ FPOptionsOverride FPFeatures);
4634+
4635+ // / Get the FP contractibility status of this operator. Only meaningful for
4636+ // / operations on floating point types.
4637+ bool isFPContractableWithinStatement (const LangOptions &LO) const {
4638+ return getFPFeaturesInEffect (LO).allowFPContractWithinStatement ();
4639+ }
4640+
4641+ // / Is FPFeatures in Trailing Storage?
4642+ bool hasStoredFPFeatures () const {
4643+ return ConvertVectorExprBits.HasFPFeatures ;
4644+ }
4645+
4646+ // / Get FPFeatures from trailing storage.
4647+ FPOptionsOverride getStoredFPFeatures () const {
4648+ return getTrailingFPFeatures ();
4649+ }
4650+
4651+ // / Get the store FPOptionsOverride or default if not stored.
4652+ FPOptionsOverride getStoredFPFeaturesOrDefault () const {
4653+ return hasStoredFPFeatures () ? getStoredFPFeatures () : FPOptionsOverride ();
4654+ }
4655+
4656+ // / Set FPFeatures in trailing storage, used by Serialization & ASTImporter.
4657+ void setStoredFPFeatures (FPOptionsOverride F) { getTrailingFPFeatures () = F; }
4658+
4659+ // / Get the FP features status of this operator. Only meaningful for
4660+ // / operations on floating point types.
4661+ FPOptions getFPFeaturesInEffect (const LangOptions &LO) const {
4662+ if (ConvertVectorExprBits.HasFPFeatures )
4663+ return getStoredFPFeatures ().applyOverrides (LO);
4664+ return FPOptions::defaultWithoutTrailingStorage (LO);
4665+ }
4666+
4667+ FPOptionsOverride getFPOptionsOverride () const {
4668+ if (ConvertVectorExprBits.HasFPFeatures )
4669+ return getStoredFPFeatures ();
4670+ return FPOptionsOverride ();
4671+ }
4672+
46014673 // / getSrcExpr - Return the Expr to be converted.
46024674 Expr *getSrcExpr () const { return cast<Expr>(SrcExpr); }
46034675
0 commit comments