@@ -225,6 +225,70 @@ class FormatArgs : public Expr
225
225
virtual Expr *clone_expr_impl () const override ;
226
226
};
227
227
228
+ // a FormatArgs which hasn't had its first argument parsed yet
229
+ // used to handle eager expansion
230
+ class FormatArgsEager final : public Expr
231
+ {
232
+ public:
233
+ using Newline = FormatArgs::Newline;
234
+
235
+ FormatArgsEager (location_t loc, std::unique_ptr<Expr> &&template_expr,
236
+ FormatArguments &&arguments, Newline newline)
237
+ : loc (loc), template_expr (std::move (template_expr)),
238
+ arguments (std::move (arguments)), newline (newline)
239
+ {}
240
+
241
+ FormatArgsEager (const FormatArgsEager &other): Expr (other), loc (other.loc), template_expr (other.template_expr->clone_expr ()), arguments (other.arguments), newline (other.newline) {}
242
+
243
+ FormatArgsEager &operator = (const FormatArgsEager &other)
244
+ {
245
+ Expr::operator = (other);
246
+ loc = other.loc ;
247
+ template_expr = other.template_expr ->clone_expr ();
248
+ arguments = other.arguments ;
249
+ newline = other.newline ;
250
+ return *this ;
251
+ }
252
+
253
+ FormatArgsEager (FormatArgsEager &&other) = default;
254
+ FormatArgsEager &operator = (FormatArgsEager &&other) = default ;
255
+
256
+ void accept_vis (AST::ASTVisitor &vis) override ;
257
+
258
+ const Expr &get_template () const { return *template_expr; }
259
+
260
+ Expr &get_template () { return *template_expr; }
261
+
262
+ std::unique_ptr<Expr> &get_template_ptr () { return template_expr; }
263
+
264
+ const FormatArguments &get_arguments () const { return arguments; }
265
+
266
+ FormatArguments &get_arguments () { return arguments; }
267
+
268
+ virtual location_t get_locus () const override { return loc; }
269
+
270
+ Newline get_newline () const { return newline; }
271
+
272
+ Expr::Kind get_expr_kind () const override { return Expr::Kind::FormatArgsEager; }
273
+
274
+ private:
275
+ location_t loc;
276
+ std::unique_ptr<Expr> template_expr;
277
+ FormatArguments arguments;
278
+ Newline newline;
279
+
280
+ bool marked_for_strip = false ;
281
+
282
+ protected:
283
+ virtual std::string as_string () const override ;
284
+ virtual bool is_expr_without_block () const override ;
285
+ virtual void mark_for_strip () override ;
286
+ virtual bool is_marked_for_strip () const override ;
287
+ virtual std::vector<Attribute> &get_outer_attrs () override ;
288
+ virtual void set_outer_attrs (std::vector<Attribute>) override ;
289
+ virtual FormatArgsEager *clone_expr_impl () const override ;
290
+ };
291
+
228
292
/* *
229
293
* The node associated with the builtin offset_of!() macro
230
294
*/
0 commit comments