[lldb] Add tests which simulate the various std::string layouts
Checking whether a formatter change does not break some of the supported string layouts is difficult because it requires tracking down and/or building different versions and build configurations of the library. The purpose of this patch is to avoid that by providing an in-tree simulation of the string class. It is a reduced version of the real string class, obtained by elimitating all non-trivial code, leaving just the internal data structures used by the data formatter. Different versions of the class can be simulated through preprocessor defines. The test (ab)uses the fact that our formatters kick in for any double-underscore sub-namespace of `std`, so it avoids colliding with the real string class by declaring the test class in the std::__lldb namespace. I do not consider this to be a replacement for the existing data formatter tests, as producing this kind of a test is not trivial, and it is easy to make a mistake in the process. However, it's also not realistic to expect that every person changing the data formatter will test it against all versions of the real class, so I think it can be useful as a first line of defence. Adding support for new layouts can become particularly unwieldy, but this complexity will also be reflected in the actual code, so if we find ourselves needing to support too many variants, we may need to start dropping support for old ones, or come up with a completely different strategy. Differential Revision: https://reviews.llvm.org/D124155
Loading
Please sign in to comment