From 206aa5b280268b011596eb9ae247aca50ce7b9c5 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Mon, 16 Dec 2019 21:48:36 -0800 Subject: [PATCH] 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 --- src/sim/guest_abi.hh | 6 ++++++ src/sim/guest_abi.test.cc | 11 +++++++++++ 2 files changed, 17 insertions(+) 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); +} -- 2.30.2