Skip to content

Commit

Permalink
Merge pull request llvm#3801 from shafik/82009764_unwrap_type_when_de…
Browse files Browse the repository at this point in the history
…fef_the_value

[lldb] Unwrap the type when dereferencing the value
  • Loading branch information
shafik authored Jan 15, 2022
2 parents b4fe124 + e494ec0 commit a6644b3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6519,7 +6519,8 @@ CompilerType TypeSystemClang::GetChildCompilerTypeAtIndex(
case clang::Type::RValueReference:
if (idx_is_valid) {
const clang::ReferenceType *reference_type =
llvm::cast<clang::ReferenceType>(GetQualType(type).getTypePtr());
llvm::cast<clang::ReferenceType>(
RemoveWrappingTypes(GetQualType(type)).getTypePtr());
CompilerType pointee_clang_type =
GetType(reference_type->getPointeeType());
if (transparent_pointers && pointee_clang_type.IsAggregateType()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@ def test(self):
# Same as above for rvalue references.
rref_val = self.expect_var_path("r_ref", type="TTT &&")
self.assertEqual(rref_val.Dereference().GetType().GetName(), "TTT")

# Typedef to a reference should dereference to the underlying type.
td_val = self.expect_var_path("td_to_ref_type", type="td_int_ref")
self.assertEqual(td_val.Dereference().GetType().GetName(), "int")
5 changes: 5 additions & 0 deletions lldb/test/API/lang/cpp/dereferencing_references/main.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
typedef int TTT;
typedef int &td_int_ref;

int main() {
int i = 0;
// references to typedefs
TTT &l_ref = i;
TTT &&r_ref = static_cast<TTT &&>(i);
// typedef of a reference
td_int_ref td_to_ref_type = i;

return l_ref; // break here
}

0 comments on commit a6644b3

Please sign in to comment.