diff options
| author | Jorge Gorbe Moya <jgorbe@google.com> | 2022-09-02 16:13:13 -0700 |
|---|---|---|
| committer | Jorge Gorbe Moya <jgorbe@google.com> | 2022-09-13 12:50:55 -0700 |
| commit | ef3fa232b338fd73475656ed61847295b0beef24 (patch) | |
| tree | ee0681d912ea64977cde42a66f6208a01869be60 /lldb/source/API/SBTypeNameSpecifier.cpp | |
| parent | 2e8863b6a11f12d31490bc054da4d47c6adc8143 (diff) | |
[Formatters][NFCI] Replace 'is_regex' arguments with an enum.
Modify `SBTypeNameSpecifier` and `lldb_private::TypeMatcher` so they
have an enum value for the type of matching to perform instead of an
`m_is_regex` boolean value.
This change paves the way for introducing formatter matching based on
the result of a python callback in addition to the existing name-based
matching. See the RFC thread at
https://discourse.llvm.org/t/rfc-python-callback-for-data-formatters-type-matching/64204
for more details.
Differential Revision: https://reviews.llvm.org/D133240
Diffstat (limited to 'lldb/source/API/SBTypeNameSpecifier.cpp')
| -rw-r--r-- | lldb/source/API/SBTypeNameSpecifier.cpp | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/lldb/source/API/SBTypeNameSpecifier.cpp b/lldb/source/API/SBTypeNameSpecifier.cpp index bc83a1d664d0..d1dc2953c9b9 100644 --- a/lldb/source/API/SBTypeNameSpecifier.cpp +++ b/lldb/source/API/SBTypeNameSpecifier.cpp @@ -20,8 +20,15 @@ using namespace lldb_private; SBTypeNameSpecifier::SBTypeNameSpecifier() { LLDB_INSTRUMENT_VA(this); } SBTypeNameSpecifier::SBTypeNameSpecifier(const char *name, bool is_regex) - : m_opaque_sp(new TypeNameSpecifierImpl(name, is_regex)) { + : SBTypeNameSpecifier(name, is_regex ? eFormatterMatchRegex + : eFormatterMatchExact) { LLDB_INSTRUMENT_VA(this, name, is_regex); +} + +SBTypeNameSpecifier::SBTypeNameSpecifier(const char *name, + FormatterMatchType match_type) + : m_opaque_sp(new TypeNameSpecifierImpl(name, match_type)) { + LLDB_INSTRUMENT_VA(this, name, match_type); if (name == nullptr || (*name) == 0) m_opaque_sp.reset(); @@ -72,13 +79,20 @@ SBType SBTypeNameSpecifier::GetType() { return SBType(); } +FormatterMatchType SBTypeNameSpecifier::GetMatchType() { + LLDB_INSTRUMENT_VA(this); + if (!IsValid()) + return eFormatterMatchExact; + return m_opaque_sp->GetMatchType(); +} + bool SBTypeNameSpecifier::IsRegex() { LLDB_INSTRUMENT_VA(this); if (!IsValid()) return false; - return m_opaque_sp->IsRegex(); + return m_opaque_sp->GetMatchType() == eFormatterMatchRegex; } bool SBTypeNameSpecifier::GetDescription( @@ -116,7 +130,7 @@ bool SBTypeNameSpecifier::IsEqualTo(lldb::SBTypeNameSpecifier &rhs) { if (!IsValid()) return !rhs.IsValid(); - if (IsRegex() != rhs.IsRegex()) + if (GetMatchType() != rhs.GetMatchType()) return false; if (GetName() == nullptr || rhs.GetName() == nullptr) return false; |
