@@ -2272,12 +2272,12 @@ class UnaryOperator final
2272
2272
// / Is FPFeatures in Trailing Storage?
2273
2273
bool hasStoredFPFeatures () const { return UnaryOperatorBits.HasFPFeatures ; }
2274
2274
2275
- protected:
2276
- // / Get FPFeatures from trailing storage
2275
+ // / Get FPFeatures from trailing storage.
2277
2276
FPOptionsOverride getStoredFPFeatures () const {
2278
2277
return getTrailingFPFeatures ();
2279
2278
}
2280
2279
2280
+ protected:
2281
2281
// / Set FPFeatures in trailing storage, used only by Serialization
2282
2282
void setStoredFPFeatures (FPOptionsOverride F) { getTrailingFPFeatures () = F; }
2283
2283
@@ -2787,6 +2787,8 @@ class CallExpr : public Expr {
2787
2787
//
2788
2788
// * An array of getNumArgs() "Stmt *" for the argument expressions.
2789
2789
//
2790
+ // * An optional of type FPOptionsOverride.
2791
+ //
2790
2792
// Note that we store the offset in bytes from the this pointer to the start
2791
2793
// of the trailing objects. It would be perfectly possible to compute it
2792
2794
// based on the dynamic kind of the CallExpr. However 1.) we have plenty of
@@ -2808,6 +2810,15 @@ class CallExpr : public Expr {
2808
2810
// / this pointer to the trailing objects.
2809
2811
static unsigned offsetToTrailingObjects (StmtClass SC);
2810
2812
2813
+ unsigned getSizeOfTrailingStmts () const {
2814
+ return (1 + getNumPreArgs () + getNumArgs ()) * sizeof (Stmt *);
2815
+ }
2816
+
2817
+ size_t getOffsetOfTrailingFPFeatures () const {
2818
+ assert (hasStoredFPFeatures ());
2819
+ return CallExprBits.OffsetToTrailingObjects + getSizeOfTrailingStmts ();
2820
+ }
2821
+
2811
2822
public:
2812
2823
enum class ADLCallKind : bool { NotADL, UsesADL };
2813
2824
static constexpr ADLCallKind NotADL = ADLCallKind::NotADL;
@@ -2818,16 +2829,19 @@ class CallExpr : public Expr {
2818
2829
// / allocated for the trailing objects.
2819
2830
CallExpr (StmtClass SC, Expr *Fn, ArrayRef<Expr *> PreArgs,
2820
2831
ArrayRef<Expr *> Args, QualType Ty, ExprValueKind VK,
2821
- SourceLocation RParenLoc, unsigned MinNumArgs, ADLCallKind UsesADL);
2832
+ SourceLocation RParenLoc, FPOptionsOverride FPFeatures,
2833
+ unsigned MinNumArgs, ADLCallKind UsesADL);
2822
2834
2823
2835
// / Build an empty call expression, for deserialization.
2824
2836
CallExpr (StmtClass SC, unsigned NumPreArgs, unsigned NumArgs,
2825
- EmptyShell Empty);
2837
+ bool hasFPFeatures, EmptyShell Empty);
2826
2838
2827
2839
// / Return the size in bytes needed for the trailing objects.
2828
2840
// / Used by the derived classes to allocate the right amount of storage.
2829
- static unsigned sizeOfTrailingObjects (unsigned NumPreArgs, unsigned NumArgs) {
2830
- return (1 + NumPreArgs + NumArgs) * sizeof (Stmt *);
2841
+ static unsigned sizeOfTrailingObjects (unsigned NumPreArgs, unsigned NumArgs,
2842
+ bool HasFPFeatures) {
2843
+ return (1 + NumPreArgs + NumArgs) * sizeof (Stmt *) +
2844
+ HasFPFeatures * sizeof (FPOptionsOverride);
2831
2845
}
2832
2846
2833
2847
Stmt *getPreArg (unsigned I) {
@@ -2845,22 +2859,43 @@ class CallExpr : public Expr {
2845
2859
2846
2860
unsigned getNumPreArgs () const { return CallExprBits.NumPreArgs ; }
2847
2861
2862
+ // / Return a pointer to the trailing FPOptions
2863
+ FPOptionsOverride *getTrailingFPFeatures () {
2864
+ assert (hasStoredFPFeatures ());
2865
+ return reinterpret_cast <FPOptionsOverride *>(
2866
+ reinterpret_cast <char *>(this ) + CallExprBits.OffsetToTrailingObjects +
2867
+ getSizeOfTrailingStmts ());
2868
+ }
2869
+ const FPOptionsOverride *getTrailingFPFeatures () const {
2870
+ assert (hasStoredFPFeatures ());
2871
+ return reinterpret_cast <const FPOptionsOverride *>(
2872
+ reinterpret_cast <const char *>(this ) +
2873
+ CallExprBits.OffsetToTrailingObjects + getSizeOfTrailingStmts ());
2874
+ }
2875
+
2848
2876
public:
2849
- // / Create a call expression. Fn is the callee expression, Args is the
2850
- // / argument array, Ty is the type of the call expression (which is *not*
2851
- // / the return type in general), VK is the value kind of the call expression
2852
- // / (lvalue, rvalue, ...), and RParenLoc is the location of the right
2853
- // / parenthese in the call expression. MinNumArgs specifies the minimum
2854
- // / number of arguments. The actual number of arguments will be the greater
2855
- // / of Args.size() and MinNumArgs. This is used in a few places to allocate
2856
- // / enough storage for the default arguments. UsesADL specifies whether the
2857
- // / callee was found through argument-dependent lookup.
2877
+ // / Create a call expression.
2878
+ // / \param Fn The callee expression,
2879
+ // / \param Args The argument array,
2880
+ // / \param Ty The type of the call expression (which is *not* the return
2881
+ // / type in general),
2882
+ // / \param VK The value kind of the call expression (lvalue, rvalue, ...),
2883
+ // / \param RParenLoc The location of the right parenthesis in the call
2884
+ // / expression.
2885
+ // / \param FPFeatures Floating-point features associated with the call,
2886
+ // / \param MinNumArgs Specifies the minimum number of arguments. The actual
2887
+ // / number of arguments will be the greater of Args.size()
2888
+ // / and MinNumArgs. This is used in a few places to allocate
2889
+ // / enough storage for the default arguments.
2890
+ // / \param UsesADL Specifies whether the callee was found through
2891
+ // / argument-dependent lookup.
2858
2892
// /
2859
2893
// / Note that you can use CreateTemporary if you need a temporary call
2860
2894
// / expression on the stack.
2861
2895
static CallExpr *Create (const ASTContext &Ctx, Expr *Fn,
2862
2896
ArrayRef<Expr *> Args, QualType Ty, ExprValueKind VK,
2863
- SourceLocation RParenLoc, unsigned MinNumArgs = 0 ,
2897
+ SourceLocation RParenLoc,
2898
+ FPOptionsOverride FPFeatures, unsigned MinNumArgs = 0 ,
2864
2899
ADLCallKind UsesADL = NotADL);
2865
2900
2866
2901
// / Create a temporary call expression with no arguments in the memory
@@ -2877,7 +2912,7 @@ class CallExpr : public Expr {
2877
2912
2878
2913
// / Create an empty call expression, for deserialization.
2879
2914
static CallExpr *CreateEmpty (const ASTContext &Ctx, unsigned NumArgs,
2880
- EmptyShell Empty);
2915
+ bool HasFPFeatures, EmptyShell Empty);
2881
2916
2882
2917
Expr *getCallee () { return cast<Expr>(getTrailingStmts ()[FN]); }
2883
2918
const Expr *getCallee () const { return cast<Expr>(getTrailingStmts ()[FN]); }
@@ -2891,6 +2926,8 @@ class CallExpr : public Expr {
2891
2926
}
2892
2927
bool usesADL () const { return getADLCallKind () == UsesADL; }
2893
2928
2929
+ bool hasStoredFPFeatures () const { return CallExprBits.HasFPFeatures ; }
2930
+
2894
2931
Decl *getCalleeDecl () { return getCallee ()->getReferencedDeclOfCallee (); }
2895
2932
const Decl *getCalleeDecl () const {
2896
2933
return getCallee ()->getReferencedDeclOfCallee ();
@@ -2983,6 +3020,31 @@ class CallExpr : public Expr {
2983
3020
// / this function call.
2984
3021
unsigned getNumCommas () const { return getNumArgs () ? getNumArgs () - 1 : 0 ; }
2985
3022
3023
+ // / Get FPOptionsOverride from trailing storage.
3024
+ FPOptionsOverride getStoredFPFeatures () const {
3025
+ assert (hasStoredFPFeatures ());
3026
+ return *getTrailingFPFeatures ();
3027
+ }
3028
+ // / Set FPOptionsOverride in trailing storage. Used only by Serialization.
3029
+ void setStoredFPFeatures (FPOptionsOverride F) {
3030
+ assert (hasStoredFPFeatures ());
3031
+ *getTrailingFPFeatures () = F;
3032
+ }
3033
+
3034
+ // Get the FP features status of this operator. Only meaningful for
3035
+ // operations on floating point types.
3036
+ FPOptions getFPFeaturesInEffect (const LangOptions &LO) const {
3037
+ if (hasStoredFPFeatures ())
3038
+ return getStoredFPFeatures ().applyOverrides (LO);
3039
+ return FPOptions::defaultWithoutTrailingStorage (LO);
3040
+ }
3041
+
3042
+ FPOptionsOverride getFPFeatures () const {
3043
+ if (hasStoredFPFeatures ())
3044
+ return getStoredFPFeatures ();
3045
+ return FPOptionsOverride ();
3046
+ }
3047
+
2986
3048
// / getBuiltinCallee - If this is a call to a builtin, return the builtin ID
2987
3049
// / of the callee. If not, return 0.
2988
3050
unsigned getBuiltinCallee () const ;
0 commit comments