Index: include/lldb/API/SBValue.h =================================================================== --- include/lldb/API/SBValue.h +++ include/lldb/API/SBValue.h @@ -352,7 +352,10 @@ bool TypeIsPointerType (); - + + bool + TypeIsReferenceType(); + lldb::SBType GetType(); Index: include/lldb/Core/ValueObject.h =================================================================== --- include/lldb/Core/ValueObject.h +++ include/lldb/Core/ValueObject.h @@ -412,7 +412,10 @@ virtual bool IsPointerType (); - + + virtual bool + IsReferenceType(); + virtual bool IsArrayType (); Index: scripts/interface/SBValue.i =================================================================== --- scripts/interface/SBValue.i +++ scripts/interface/SBValue.i @@ -332,7 +332,10 @@ bool TypeIsPointerType (); - + + bool + TypeIsReferenceType(); + lldb::SBTarget GetTarget(); Index: source/API/SBValue.cpp =================================================================== --- source/API/SBValue.cpp +++ source/API/SBValue.cpp @@ -1324,6 +1324,24 @@ return is_ptr_type; } +bool +SBValue::TypeIsReferenceType() +{ + bool is_ref_type = false; + + ValueLocker locker; + lldb::ValueObjectSP value_sp(GetSP(locker)); + if (value_sp) + is_ref_type = value_sp->IsReferenceType(); + + Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + if (log) + log->Printf("SBValue(%p)::TypeIsReferenceType() => %i", + static_cast(value_sp.get()), is_ref_type); + + return is_ref_type; +} + void * SBValue::GetOpaqueType() { Index: source/Core/ValueObject.cpp =================================================================== --- source/Core/ValueObject.cpp +++ source/Core/ValueObject.cpp @@ -2035,6 +2035,12 @@ } bool +ValueObject::IsReferenceType() +{ + return GetClangType().IsReferenceType(); +} + +bool ValueObject::IsArrayType () { return GetClangType().IsArrayType (NULL, NULL, NULL); Index: test/python_api/value/Makefile =================================================================== --- test/python_api/value/Makefile +++ test/python_api/value/Makefile @@ -1,5 +1,5 @@ LEVEL = ../../make -C_SOURCES := main.c +CXX_SOURCES := main.cpp include $(LEVEL)/Makefile.rules Index: test/python_api/value/TestValueAPI.py =================================================================== --- test/python_api/value/TestValueAPI.py +++ test/python_api/value/TestValueAPI.py @@ -36,8 +36,7 @@ TestBase.setUp(self) # We'll use the test method name as the exe_name. self.exe_name = self.testMethodName - # Find the line number to of function 'c'. - self.line = line_number('main.c', '// Break at this line') + self.line = line_number('main.cpp', '// Break at this line') def value_api(self, exe_name): """Exercise some SBValue APIs.""" @@ -48,7 +47,7 @@ self.assertTrue(target, VALID_TARGET) # Create the breakpoint inside function 'main'. - breakpoint = target.BreakpointCreateByLocation('main.c', self.line) + breakpoint = target.BreakpointCreateByLocation('main.cpp', self.line) self.assertTrue(breakpoint, VALID_BREAKPOINT) # Now launch the process, and do not stop at entry point. @@ -107,6 +106,17 @@ self.expect(symbol.GetName(), exe=False, startstr = 'g_my_int') + # Get variable 'my_int_ref'. + value = frame0.FindVariable('my_int_ref') + self.assertTrue(value, VALID_VARIABLE) + self.DebugSBValue(value) + + # SBValue::TypeIsPointerType() should return false. + self.assertFalse(value.TypeIsPointerType()) + + # SBValue::TypeIsReferenceType() should return true. + self.assertTrue(value.TypeIsReferenceType()) + # Get variable 'str_ptr'. value = frame0.FindVariable('str_ptr') self.assertTrue(value, VALID_VARIABLE) Index: test/python_api/value/main.cpp =================================================================== --- test/python_api/value/main.cpp +++ test/python_api/value/main.cpp @@ -43,10 +43,12 @@ struct MyStruct s = { 11, 22 }; int *my_int_ptr = &g_my_int; printf("my_int_ptr points to location %p\n", my_int_ptr); + int &my_int_ref = g_my_int; + printf("my_int_ref refers to location %p\n", &my_int_ref); const char **str_ptr = days_of_week; for (i = 0; i < 7; ++i) printf("%s\n", str_ptr[i]); // Break at this line // and do str_ptr_val.GetChildAtIndex(5, lldb.eNoDynamicValues, True). - + return 0; }