[Lldb-commits] [PATCH] D66398: 2/2: Fix `TestDataFormatterStdList` regression
Jan Kratochvil via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Thu Aug 22 04:52:47 PDT 2019
jankratochvil updated this revision to Diff 216585.
jankratochvil edited the summary of this revision.
jankratochvil added a comment.
It just makes now the regexes unambiguous.
Repository:
rLLDB LLDB
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D66398/new/
https://reviews.llvm.org/D66398
Files:
lldb/include/lldb/DataFormatters/FormattersContainer.h
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py
lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
Index: lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
===================================================================
--- lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -486,8 +486,11 @@
cpp_category_sp,
lldb_private::formatters::LibcxxStdListSyntheticFrontEndCreator,
"libc++ std::list synthetic children",
- ConstString("^std::__[[:alnum:]]+::list<.+>(( )?&)?$"), stl_deref_flags,
- true);
+ // A POSIX variant of: "^std::__(?!cxx11:)[[:alnum:]]+::list<.+>(( )?&)?$"
+ // so that it does not clash with: "^std::(__cxx11::)?list<.+>(( )?&)?$"
+ ConstString("^std::__([A-Zabd-z0-9]|cx?[A-Za-wyz0-9]|cxx1?[A-Za-z02-9]|"
+ "cxx11[[:alnum:]])[[:alnum:]]*::list<.+>(( )?&)?$"),
+ stl_deref_flags, true);
AddCXXSynthetic(
cpp_category_sp,
lldb_private::formatters::LibcxxStdMapSyntheticFrontEndCreator,
@@ -583,11 +586,14 @@
"libc++ std::list summary provider",
ConstString("^std::__[[:alnum:]]+::forward_list<.+>(( )?&)?$"),
stl_summary_flags, true);
- AddCXXSummary(cpp_category_sp,
- lldb_private::formatters::LibcxxContainerSummaryProvider,
- "libc++ std::list summary provider",
- ConstString("^std::__[[:alnum:]]+::list<.+>(( )?&)?$"),
- stl_summary_flags, true);
+ AddCXXSummary(
+ cpp_category_sp, lldb_private::formatters::LibcxxContainerSummaryProvider,
+ "libc++ std::list summary provider",
+ // A POSIX variant of: "^std::__(?!cxx11:)[[:alnum:]]+::list<.+>(( )?&)?$"
+ // so that it does not clash with: "^std::(__cxx11::)?list<.+>(( )?&)?$"
+ ConstString("^std::__([A-Zabd-z0-9]|cx?[A-Za-wyz0-9]|cxx1?[A-Za-z02-9]|"
+ "cxx11[[:alnum:]])[[:alnum:]]*::list<.+>(( )?&)?$"),
+ stl_summary_flags, true);
AddCXXSummary(cpp_category_sp,
lldb_private::formatters::LibcxxContainerSummaryProvider,
"libc++ std::map summary provider",
Index: lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py
+++ lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py
@@ -130,6 +130,10 @@
self.expect("frame variable int_array",
substrs=['1,2'])
+ # "int []" gets converted by FixArrayTypeNameWithRegex into "int \[[0-9]+\]"
+ # which becomes ambiguous for some string against "int \[[0-9]\]".
+ self.runCmd("type summary clear")
+
self.runCmd(
'type summary add --summary-string \"${var[0-1]}\" "int []"')
Index: lldb/include/lldb/DataFormatters/FormattersContainer.h
===================================================================
--- lldb/include/lldb/DataFormatters/FormattersContainer.h
+++ lldb/include/lldb/DataFormatters/FormattersContainer.h
@@ -296,14 +296,24 @@
llvm::StringRef key_str = key.GetStringRef();
std::lock_guard<std::recursive_mutex> guard(m_format_map.mutex());
MapIterator pos, end = m_format_map.map().end();
+ MapIterator found = end;
for (pos = m_format_map.map().begin(); pos != end; pos++) {
lldb::RegularExpressionSP regex = pos->first;
if (regex->Execute(key_str)) {
- value = pos->second;
- return true;
+ if (found != end) {
+ llvm::errs() << "Two regexes (\"" << found->first->GetText()
+ << "\" and \"" << regex->GetText()
+ << "\") ambiguously match the same string \"" << key_str
+ << "\".\n";
+ return false;
+ }
+ found = pos;
}
}
- return false;
+ if (found == end)
+ return false;
+ value = found->second;
+ return true;
}
bool GetExact_Impl(ConstString key, MapValueType &value,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66398.216585.patch
Type: text/x-patch
Size: 4171 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20190822/ef9c80c5/attachment-0001.bin>
More information about the lldb-commits
mailing list