[lldb] Add SubstTemplateTypeParm to RemoveWrappingTypes
Like the other type sugar removed by RemoveWrappingTypes, SubstTemplateTypeParm is just pure sugar that should be ignored. If we don't ignore it (as we do now), LLDB will fail to read values from record fields that have a SubstTemplateTypeParm type. Only way to produce such a type in LLDB is to either use the `import-std-module` setting to get a template into the expression parser or just create your own template directly in the expression parser which is what we do in the test. Reviewed By: jarin Differential Revision: https://reviews.llvm.org/D85132
This commit is contained in:
parent
4f3559db1f
commit
950f1bf976
|
|
@ -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::SubstTemplateTypeParm:
|
||||
case clang::Type::TemplateSpecialization:
|
||||
case clang::Type::Typedef:
|
||||
case clang::Type::TypeOf:
|
||||
|
|
|
|||
|
|
@ -0,0 +1,34 @@
|
|||
"""
|
||||
Test SubstTemplateTypeParam types which are produced as type sugar
|
||||
when template type parameters are used for example as field types.
|
||||
"""
|
||||
|
||||
import lldb
|
||||
import lldbsuite.test.lldbutil as lldbutil
|
||||
from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test import decorators
|
||||
|
||||
class TestCase(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
|
||||
def test_typedef(self):
|
||||
target = self.dbg.GetDummyTarget()
|
||||
|
||||
# Declare a template class with a field that uses the template type
|
||||
# parameter.
|
||||
opts = lldb.SBExpressionOptions()
|
||||
opts.SetTopLevel(True)
|
||||
result = target.EvaluateExpression("template <typename T> struct X { T f; };", opts)
|
||||
# FIXME: This fails with "Couldn't find $__lldb_expr() in the module"
|
||||
# but it should succeed. The fact that this code has nothing to run
|
||||
# shouldn't be an error.
|
||||
# self.assertSuccess(result.GetError())
|
||||
|
||||
# Instantiate and produce a value with that template as the type.
|
||||
# The field in the value will have a SubstTemplateTypeParam that
|
||||
# should behave like a normal field.
|
||||
result = target.EvaluateExpression("X<int> x; x.f = 123; x")
|
||||
self.assertEqual(result.GetNumChildren(), 1)
|
||||
self.assertEqual(result.GetChildAtIndex(0).GetTypeName(), "int")
|
||||
self.assertEqual(result.GetChildAtIndex(0).GetValue(), "123")
|
||||
Loading…
Reference in New Issue