From: Gabe Black Date: Tue, 17 Dec 2019 05:48:36 +0000 (-0800) Subject: sim: Add a typetraits style mechanism to test for VarArgs. X-Git-Tag: v19.0.0.0~37 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=206aa5b280268b011596eb9ae247aca50ce7b9c5;p=gem5.git sim: Add a typetraits style mechanism to test for VarArgs. This family of types can be cumbersome to check for when building ABI rules. This struct template makes that a little easier. Change-Id: Ic3a1b8424f8ca04564f8228365371b357f33276c Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/23750 Maintainer: Gabe Black Tested-by: kokoro Reviewed-by: Jason Lowe-Power --- diff --git a/src/sim/guest_abi.hh b/src/sim/guest_abi.hh index 5432af3f9..9726c49db 100644 --- a/src/sim/guest_abi.hh +++ b/src/sim/guest_abi.hh @@ -284,6 +284,12 @@ class VarArgs } }; +template +struct IsVarArgs : public std::false_type {}; + +template +struct IsVarArgs> : public std::true_type {}; + template std::ostream & operator << (std::ostream &os, const VarArgs &va) diff --git a/src/sim/guest_abi.test.cc b/src/sim/guest_abi.test.cc index 506163ee6..bd444aa32 100644 --- a/src/sim/guest_abi.test.cc +++ b/src/sim/guest_abi.test.cc @@ -362,3 +362,14 @@ TEST(GuestABI, dumpSimcall) std::string dump = dumpSimcall("test", &tc, testIntVoid); EXPECT_EQ(dump, "test(0, 11, 2, 13, ...)"); } + +TEST(GuestABI, isVarArgs) +{ + EXPECT_TRUE(GuestABI::IsVarArgs>::value); + EXPECT_FALSE(GuestABI::IsVarArgs::value); + EXPECT_FALSE(GuestABI::IsVarArgs::value); + struct FooStruct {}; + EXPECT_FALSE(GuestABI::IsVarArgs::value); + union FooUnion {}; + EXPECT_FALSE(GuestABI::IsVarArgs::value); +}