@@ -42,6 +42,7 @@ $(GNAME TraitsKeyword):
42
42
$(GLINK isRef)
43
43
$(GLINK isOut)
44
44
$(GLINK isLazy)
45
+ $(GLINK isReturnOnStack)
45
46
$(GLINK hasMember)
46
47
$(GLINK identifier)
47
48
$(GLINK getAliasThis)
@@ -399,6 +400,39 @@ static assert(!__traits(isTemplate,foo!int()));
399
400
static assert(!__traits(isTemplate,"string"));
400
401
---
401
402
403
+ $(H2 $(GNAME isReturnOnStack))
404
+
405
+ $(P
406
+ Takes one argument which must either be a function symbol, function literal,
407
+ a delegate, or a function pointer.
408
+ It returns a `bool` which is `true` if the return value of the function is
409
+ returned on the stack via a pointer to it passed as a hidden extra
410
+ parameter to the function.
411
+ )
412
+
413
+ ---
414
+ struct S { int[20] a; }
415
+ int test1();
416
+ S test2();
417
+
418
+ static assert(__traits(isReturnOnStack, test1) == false);
419
+ static assert(__traits(isReturnOnStack, test2) == true);
420
+ ---
421
+
422
+ $(IMPLEMENTATION_DEFINED
423
+ This is determined by the function ABI calling convention in use,
424
+ which is often complex.
425
+ )
426
+
427
+ $(BEST_PRACTICE This has applications in:
428
+ $(OL
429
+ $(LI Returning values in registers is often faster, so this can be used as
430
+ a check on a hot function to ensure it is using the fastest method.)
431
+ $(LI When using inline assembly to correctly call a function.)
432
+ $(LI Testing that the compiler does this correctly is normally hackish and awkward,
433
+ this enables efficient, direct, and simple testing.)
434
+ ))
435
+
402
436
$(H2 $(GNAME hasMember))
403
437
404
438
$(P The first argument is a type that has members, or
0 commit comments