[Lldb-commits] [lldb] [lldb][test] DWARFASTParserClangTests: extract test setup into helper structure (PR #170132)
Adrian Prantl via lldb-commits
lldb-commits at lists.llvm.org
Tue Dec 2 16:38:41 PST 2025
================
@@ -42,6 +42,52 @@ class DWARFASTParserClangStub : public DWARFASTParserClang {
return keys;
}
};
+
+/// Helper structure for DWARFASTParserClang tests that want to parse DWARF
+/// generated using yaml2obj. On construction parses the supplied YAML data
+/// into a DWARF module and thereafter vends a DWARFASTParserClang and
+/// TypeSystemClang that are guaranteed to live for the duration of this object.
+class DWARFASTParserClangYAMLTester {
+public:
+ DWARFASTParserClangYAMLTester(llvm::StringRef yaml_data)
+ : m_module_tester(yaml_data) {}
+
+ DWARFDIE GetCUDIE() {
+ DWARFUnit *unit = m_module_tester.GetDwarfUnit();
+ assert(unit);
+
+ const DWARFDebugInfoEntry *cu_entry = unit->DIE().GetDIE();
+ assert(cu_entry->Tag() == DW_TAG_compile_unit);
+
+ return DWARFDIE(unit, cu_entry);
+ }
+
+ DWARFASTParserClang &GetParser() {
+ auto *parser = GetTypeSystem().GetDWARFParser();
+
+ assert(llvm::isa_and_nonnull<DWARFASTParserClang>(parser));
+
+ return *llvm::dyn_cast<DWARFASTParserClang>(parser);
----------------
adrian-prantl wrote:
Could this just be a non-dynamic `cast<>`?
https://github.com/llvm/llvm-project/pull/170132
More information about the lldb-commits
mailing list