llvm-project/lldb/unittests
Raphael Isemann 4d489e9f91 Reland [lldb] Unify type name matching in FormattersContainer II
This was originally reverted because the m_valid member in TypeMatcher was
unused in builds with disabled asserts. Now the member is gone and the default
constructor is deleted (thanks Eric for the idea!).

Summary:

FormattersContainer stores LLDB's formatters. It's implemented as a templated
map-like data structures that supports any kind of value type and only allows
ConstString and RegularExpression as the key types. The keys are used for
matching type names (e.g., the ConstString key `std::vector` matches the type
with the same name while RegularExpression keys match any type where the
RegularExpression instance matches).

The fact that a single FormattersContainer can only match either by string
comparison or regex matching (depending on the KeyType) causes us to always have
two FormatterContainer instances in all the formatting code. This also leads to
us having every type name matching logic in LLDB twice. For example,
TypeCategory has to implement every method twice (one string matching one, one
regex matching one).

This patch changes FormattersContainer to instead have a single `TypeMatcher`
key that wraps the logic for string-based and regex-based type matching and is
now the only possible KeyType for the FormattersContainer. This means that a
single FormattersContainer can now match types with both regex and string
comparison.

To summarize the changes in this patch:
* Remove all the `*_Impl` methods from `FormattersContainer`
* Instead call the FormatMap functions from `FormattersContainer` with a
  `TypeMatcher` type that does the respective matching.
* Replace `ConstString` with `TypeMatcher` in the few places that directly
  interact with `FormattersContainer`.

I'm working on some follow up patches that I split up because they deserve their
own review:

* Unify FormatMap and FormattersContainer (they are nearly identical now).
* Delete the duplicated half of all the type matching code that can now use one
  interface.
* Propagate TypeMatcher through all the formatter code interfaces instead of
  always offering two functions for everything.

There is one ugly design part that I couldn't get rid of yet and that is that we
have to support getting back the string used to construct a `TypeMatcher` later
on. The reason for this is that LLDB only supports referencing existing type
matchers by just typing their respective input string again (without even
supplying if it's a regex or not).

Reviewers: davide, mib

Reviewed By: mib

Subscribers: mgorny, JDevlieghere

Differential Revision: https://reviews.llvm.org/D84151
2020-07-23 18:17:42 +02:00
..
API [lldb/CMake] Set the PYTHON_RPATH for the unit tests 2020-04-30 11:05:50 -07:00
Breakpoint [lldb][NFC] Fix all formatting errors in .cpp file headers 2020-01-24 08:52:55 +01:00
Core [lldb/Module] Allow for the creation of memory-only modules 2020-07-14 08:45:44 -07:00
DataFormatter Reland [lldb] Unify type name matching in FormattersContainer II 2020-07-23 18:17:42 +02:00
Disassembler [lldb/Plugins] Rename lldbPluginDisassemblerLLVM (NFC) 2020-02-17 19:14:01 -08:00
Editline [lldb] Rename Master/Slave to Primary/Secondary (NFC) 2020-06-15 15:38:28 -07:00
Expression [DWARFYAML] Make the length field of compilation units optional. NFC. 2020-07-22 12:16:19 +08:00
Host [lldb] Rename Master/Slave to Primary/Secondary (NFC) 2020-06-15 15:38:28 -07:00
Instruction Fix UB in EmulateInstructionARM64.cpp 2020-06-01 18:11:50 -07:00
Interpreter [lldb] Make TestOptionValueFileColonLine work on Windows 2020-07-20 23:15:03 -07:00
Language [lldb] Reactivate Objective-C++ plugin 2020-06-19 19:16:46 +02:00
ObjectFile [lldb/ObjectFileMachO] Fetch shared cache images from our own shared cache 2020-07-16 10:37:37 -07:00
Platform [lldb/Test] Fix unit test suffixes and add a CMake error. 2020-06-12 14:18:27 -07:00
Process [lldb/Test] Fix unit test suffixes and add a CMake error. 2020-06-12 14:18:27 -07:00
ScriptInterpreter [lldb/ScriptInterpreter] Fix Windows error C2371: 'pid_t': redefinition 2020-06-25 17:15:29 -07:00
Signals [lldb][NFC] Fix all formatting errors in .cpp file headers 2020-01-24 08:52:55 +01:00
Symbol [lldb/Module] Allow for the creation of memory-only modules 2020-07-14 08:45:44 -07:00
SymbolFile Fix Windows build 2020-07-22 11:01:25 -07:00
Target [lldb] Store StackFrameRecognizers in the target instead of a global list 2020-07-17 09:26:27 +02:00
TestingSupport [DWARFYAML] Refactor emitDebugInfo() to make the length be inferred. 2020-07-23 23:00:19 +08:00
Thread [lldb/Test] Fix unittest name 2020-06-12 14:01:14 -07:00
UnwindAssembly Bug where insn-based unwind plans on arm64 could be wrong 2020-04-14 16:57:25 -07:00
Utility [lldb/Utility] Simplify Scalar::SetValueFromData 2020-07-20 15:56:56 +02:00
debugserver [lldb] Make RNBSocketTest compile again after socket modernization 2020-04-23 17:00:02 +02:00
tools [lldb] Change Communication::SetConnection to take a unique_ptr 2020-04-02 14:42:25 +02:00
CMakeLists.txt Reapply "Try enabling -Wsuggest-override again, using add_compile_options instead of add_compile_definitions for disabling it in unittests/ directories." 2020-07-22 17:50:19 -07:00
gtest_common.h [lldb] Update header guards to be consistent and compliant with LLVM (NFC) 2020-02-17 23:15:40 -08:00