aboutsummaryrefslogtreecommitdiff
path: root/lldb
diff options
context:
space:
mode:
authorMichael Buch <michaelbuch12@gmail.com>2022-07-17 12:16:39 +0100
committerMichael Buch <michaelbuch12@gmail.com>2022-07-21 14:21:12 +0100
commit6703812688b84100a159ec793f677952ea8e3eba (patch)
treed5cd2c818036651f6f367cb26b12dee1ea00f6ea /lldb
parentAMDGPU: Refine user-sgpr-init16-bug (diff)
downloadllvm-project-6703812688b84100a159ec793f677952ea8e3eba.tar.gz
llvm-project-6703812688b84100a159ec793f677952ea8e3eba.tar.bz2
llvm-project-6703812688b84100a159ec793f677952ea8e3eba.zip
[LLDB][DataFormatter] Add support for std::__map_const_iterator
This patch adds support for formatting `std::map::const_iterator`. It's just a matter of adding `const_` to the existing regex. **Testing** * Added test case to existing API tests Differential Revision: https://reviews.llvm.org/D129962
Diffstat (limited to 'lldb')
-rw-r--r--lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp2
-rw-r--r--lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py10
-rw-r--r--lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/map/main.cpp7
3 files changed, 17 insertions, 2 deletions
diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index db87aae6656b..23ce1654fb83 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -909,7 +909,7 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
cpp_category_sp,
lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEndCreator,
"std::map iterator synthetic children",
- ConstString("^std::__[[:alnum:]]+::__map_iterator<.+>$"), stl_synth_flags,
+ ConstString("^std::__[[:alnum:]]+::__map_(const_)?iterator<.+>$"), stl_synth_flags,
true);
AddCXXSynthetic(
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py
index e0111ea189f9..097a1e649d43 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py
@@ -116,6 +116,16 @@ class LibcxxMapDataFormatterTestCase(TestBase):
substrs=['first =',
'second ='])
+ # (Non-)const key/val iterators
+ self.expect_expr("it", result_children=[
+ ValueCheck(name="first", value="0"),
+ ValueCheck(name="second", value="0")
+ ])
+ self.expect_expr("const_it", result_children=[
+ ValueCheck(name="first", value="0"),
+ ValueCheck(name="second", value="0")
+ ])
+
# check that MightHaveChildren() gets it right
self.assertTrue(
self.frame().FindVariable("ii").MightHaveChildren(),
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/map/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/map/main.cpp
index da6eca985d20..43ce6aeefd2a 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/map/main.cpp
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/map/main.cpp
@@ -24,7 +24,12 @@ int main()
ii[0] = 0; // Set break point at this line.
ii[1] = 1;
- thefoo_rw(1); // Set break point at this line.
+
+ intint_map::iterator it = ii.begin();
+ intint_map::const_iterator const_it = ii.cbegin();
+ std::printf("%d %d\n", it->second, const_it->second);
+
+ thefoo_rw(1); // Set break point at this line.
ii[2] = 0;
ii[3] = 1;
thefoo_rw(1); // Set break point at this line.