From d7f71add86c892ced324fc26cb0945911f3e26a5 Mon Sep 17 00:00:00 2001 From: Greg Clayton Date: Fri, 24 Jun 2016 23:48:00 +0000 Subject: Made templates that have Enumeration values as arguments work correctly. We were checking for integer types only before this. So I added the ability for CompilerType objects to check for integer and enum types. Then I searched for places that were using the CompilerType::IsIntegerType(...) function. Many of these places also wanted to be checking for enumeration types as well, so I have fixed those places. These are in the ABI plug-ins where we are figuring out which arguments would go in where in regisers/stack when making a function call, or determining where the return value would live. The real fix for this is to use clang to compiler a CGFunctionInfo and then modify the code to be able to take the IR and a calling convention and have the backend answer the questions correctly for us so we don't need to create a really bad copy of the ABI in each plug-in, but that is beyond the scope of this bug fix. Also added a test case to ensure this doesn't regress in the future. llvm-svn: 273750 --- .../lldbsuite/test/lang/cpp/template/main.cpp | 49 +++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) (limited to 'lldb/packages/Python/lldbsuite/test/lang/cpp/template/main.cpp') diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/template/main.cpp b/lldb/packages/Python/lldbsuite/test/lang/cpp/template/main.cpp index 10a4bec62e9..9c33a642091 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/cpp/template/main.cpp +++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/template/main.cpp @@ -17,9 +17,56 @@ public: } }; +//---------------------------------------------------------------------- +// Define a template class that we can specialize with an enumeration +//---------------------------------------------------------------------- +enum class EnumType +{ + Member, + Subclass +}; + +template class EnumTemplate; + +//---------------------------------------------------------------------- +// Specialization for use when "Arg" is "EnumType::Member" +//---------------------------------------------------------------------- +template <> +class EnumTemplate +{ +public: + EnumTemplate(int m) : + m_member(m) + { + } + + int getMember() const + { + return m_member; + } + +protected: + int m_member; +}; + +//---------------------------------------------------------------------- +// Specialization for use when "Arg" is "EnumType::Subclass" +//---------------------------------------------------------------------- +template <> +class EnumTemplate : + public EnumTemplate +{ +public: + EnumTemplate(int m) : EnumTemplate(m) + { + } +}; + int main(int argc, char **argv) { TestObj<1> testpos; TestObj<-1> testneg; - return testpos.getArg() - testneg.getArg(); // Breakpoint 1 + EnumTemplate member(123); + EnumTemplate subclass(123*2); + return testpos.getArg() - testneg.getArg() + member.getMember()*2 - subclass.getMember(); // Breakpoint 1 } -- cgit v1.2.3