Author: Jaroslav Sevcik Date: 2020-07-16T09:01:01+02:00 New Revision: 93ec6cd684265161623b4ea67836f022cd18c224
URL: https://github.com/llvm/llvm-project/commit/93ec6cd684265161623b4ea67836f022cd18c224 DIFF: https://github.com/llvm/llvm-project/commit/93ec6cd684265161623b4ea67836f022cd18c224.diff LOG: [lldb] Desugar template specializations Template specializations are not handled in many of the TypeSystemClang methods. For example, GetNumChildren does not handle the TemplateSpecialization type class, so template specializations always look like empty objects. This patch just desugars template specializations in the existing RemoveWrappingTypes desugaring helper. Differential Revision: https://reviews.llvm.org/D83858 Added: lldb/test/API/lang/cpp/template-specialization-type/Makefile lldb/test/API/lang/cpp/template-specialization-type/TestTemplateSpecializationType.py lldb/test/API/lang/cpp/template-specialization-type/main.cpp Modified: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp Removed: ################################################################################ diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp index bc06ea8164d4..8825b473cd33 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -2499,6 +2499,7 @@ RemoveWrappingTypes(QualType type, ArrayRef<clang::Type::TypeClass> mask = {}) { case clang::Type::Decltype: case clang::Type::Elaborated: case clang::Type::Paren: + case clang::Type::TemplateSpecialization: case clang::Type::Typedef: case clang::Type::TypeOf: case clang::Type::TypeOfExpr: diff --git a/lldb/test/API/lang/cpp/template-specialization-type/Makefile b/lldb/test/API/lang/cpp/template-specialization-type/Makefile new file mode 100644 index 000000000000..99998b20bcb0 --- /dev/null +++ b/lldb/test/API/lang/cpp/template-specialization-type/Makefile @@ -0,0 +1,3 @@ +CXX_SOURCES := main.cpp + +include Makefile.rules diff --git a/lldb/test/API/lang/cpp/template-specialization-type/TestTemplateSpecializationType.py b/lldb/test/API/lang/cpp/template-specialization-type/TestTemplateSpecializationType.py new file mode 100644 index 000000000000..31f0081dc697 --- /dev/null +++ b/lldb/test/API/lang/cpp/template-specialization-type/TestTemplateSpecializationType.py @@ -0,0 +1,30 @@ +""" +Test value with a template specialization type. +""" +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class TemplateSpecializationTypeTestCase(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + def test_template_specialization_cast_children(self): + self.build() + lldbutil.run_to_source_breakpoint(self, '// break here', + lldb.SBFileSpec("main.cpp", False)) + + v = self.frame().EvaluateExpression("t") + self.assertEquals(2, v.GetNumChildren()) + self.assertEquals("42", v.GetChildAtIndex(0).GetValue()) + self.assertEquals("21", v.GetChildAtIndex(1).GetValue()) + + # Test a value of the TemplateSpecialization type. We turn + # RecordType into TemplateSpecializationType by casting and + # dereferencing a pointer to a record. + v = self.frame().EvaluateExpression("*((TestObj<int>*)&t)") + self.assertEquals(2, v.GetNumChildren()) + self.assertEquals("42", v.GetChildAtIndex(0).GetValue()) + self.assertEquals("21", v.GetChildAtIndex(1).GetValue()) diff --git a/lldb/test/API/lang/cpp/template-specialization-type/main.cpp b/lldb/test/API/lang/cpp/template-specialization-type/main.cpp new file mode 100644 index 000000000000..5ef9c4962c85 --- /dev/null +++ b/lldb/test/API/lang/cpp/template-specialization-type/main.cpp @@ -0,0 +1,9 @@ +template <typename T> struct TestObj { + int f; + T g; +}; + +int main() { + TestObj<int> t{42, 21}; + return t.f + t.g; // break here +} _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits