Skip to content

[lldb] Unwrap the type when dereferencing the value #3867

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -6500,7 +6500,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
}