When looking at template arguments in LLDB, we usually care about what the user passed in his code, not whether some of those arguments where passed as a variadic parameter pack. This patch extends all the C++ APIs to look at template parameters to take an additional 'expand_pack' boolean that automatically unwraps the potential argument packs. The equivalent SBAPI calls have been changed to pass true for this parameter. A byproduct of the patch is to also fix the support for template type that have only a parameter pack as argument (like the OnlyPack type in the test). Those were not recognized as template instanciations before. The added test verifies that the SBAPI is able to iterate over the arguments of a variadic template. The original patch was written by Fred Riss almost 4 years ago. Differential revision: https://reviews.llvm.org/D51387
50 lines
1.2 KiB
C++
50 lines
1.2 KiB
C++
template <class T, int... Args> struct C {
|
|
T member;
|
|
bool argsAre_16_32() { return false; }
|
|
};
|
|
|
|
template <> struct C<int, 16> {
|
|
int member;
|
|
bool argsAre_16_32() { return false; }
|
|
};
|
|
|
|
template <> struct C<int, 16, 32> : C<int, 16> {
|
|
bool argsAre_16_32() { return true; }
|
|
};
|
|
|
|
template <class T, typename... Args> struct D {
|
|
T member;
|
|
bool argsAre_Int_bool() { return false; }
|
|
};
|
|
|
|
template <> struct D<int, int> {
|
|
int member;
|
|
bool argsAre_Int_bool() { return false; }
|
|
};
|
|
|
|
template <> struct D<int, int, bool> : D<int, int> {
|
|
bool argsAre_Int_bool() { return true; }
|
|
};
|
|
|
|
template <typename... Args> struct OnlyPack {};
|
|
template <typename T, typename... Args> struct EmptyPack {};
|
|
|
|
int main(int argc, char const *argv[]) {
|
|
EmptyPack<int> emptyPack;
|
|
OnlyPack<int, char, double, D<int, int, bool>> onlyPack;
|
|
|
|
C<int, 16, 32> myC;
|
|
C<int, 16> myLesserC;
|
|
myC.member = 64;
|
|
(void)C<int, 16, 32>().argsAre_16_32();
|
|
(void)C<int, 16>().argsAre_16_32();
|
|
(void)(myC.member != 64);
|
|
D<int, int, bool> myD;
|
|
D<int, int> myLesserD; // breakpoint here
|
|
myD.member = 64;
|
|
(void)D<int, int, bool>().argsAre_Int_bool();
|
|
(void)D<int, int>().argsAre_Int_bool();
|
|
|
|
return 0; // break here
|
|
}
|