diff options
| author | Jaroslav Sevcik <jarin@google.com> | 2020-01-10 11:44:14 +0100 |
|---|---|---|
| committer | Raphael Isemann <teemperor@gmail.com> | 2020-01-10 11:45:24 +0100 |
| commit | 902974277d507a149e33487d32e4ba58c41451b6 (patch) | |
| tree | 6c0a515cb60bdd1e63ce038b2a36bcd35d84777d /lldb/source/DataFormatters/FormatManager.cpp | |
| parent | f3849f739e52510871d11361125f0ef239f11603 (diff) | |
| download | bcm5719-llvm-902974277d507a149e33487d32e4ba58c41451b6.tar.gz bcm5719-llvm-902974277d507a149e33487d32e4ba58c41451b6.zip | |
Data formatters: Look through array element typedefs
Summary:
Motivation: When formatting an array of typedefed chars, we would like to display the array as a string.
The string formatter currently does not trigger because the formatter lookup does not resolve typedefs for array elements (this behavior is inconsistent with pointers, for those we do look through pointee typedefs). This patch tries to make the array formatter lookup somewhat consistent with the pointer formatter lookup.
Reviewers: teemperor, clayborg
Reviewed By: teemperor, clayborg
Subscribers: clayborg, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D72133
Diffstat (limited to 'lldb/source/DataFormatters/FormatManager.cpp')
| -rw-r--r-- | lldb/source/DataFormatters/FormatManager.cpp | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/lldb/source/DataFormatters/FormatManager.cpp b/lldb/source/DataFormatters/FormatManager.cpp index 08fc56a72ea..d5db3ee75bf 100644 --- a/lldb/source/DataFormatters/FormatManager.cpp +++ b/lldb/source/DataFormatters/FormatManager.cpp @@ -230,11 +230,33 @@ void FormatManager::GetPossibleMatches( if (non_ptr_type.IsTypedefType()) { CompilerType deffed_pointed_type = non_ptr_type.GetTypedefedType().GetPointerType(); + const bool stripped_typedef = true; GetPossibleMatches( valobj, deffed_pointed_type, reason | lldb_private::eFormatterChoiceCriterionNavigatedTypedefs, use_dynamic, entries, did_strip_ptr, did_strip_ref, - true); // this is not exactly the usual meaning of stripping typedefs + stripped_typedef); // this is not exactly the usual meaning of + // stripping typedefs + } + } + + // For arrays with typedef-ed elements, we add a candidate with the typedef + // stripped. + uint64_t array_size; + if (compiler_type.IsArrayType(nullptr, &array_size, nullptr)) { + CompilerType element_type = compiler_type.GetArrayElementType(); + if (element_type.IsTypedefType()) { + // Get the stripped element type and compute the stripped array type + // from it. + CompilerType deffed_array_type = + element_type.GetTypedefedType().GetArrayType(array_size); + const bool stripped_typedef = true; + GetPossibleMatches( + valobj, deffed_array_type, + reason | lldb_private::eFormatterChoiceCriterionNavigatedTypedefs, + use_dynamic, entries, did_strip_ptr, did_strip_ref, + stripped_typedef); // this is not exactly the usual meaning of + // stripping typedefs } } |

