diff options
author | David Blaikie <dblaikie@gmail.com> | 2021-12-14 11:45:23 -0800 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2021-12-14 14:50:43 -0800 |
commit | 71e5488a195dde08a76e923814e036c68033869f (patch) | |
tree | 889a5c28280970750ff228720bf4f31fab62098f /llvm/unittests/DebugInfo | |
parent | 5740bb801a14efd5239a0e521395c09e71e61f5c (diff) | |
download | llvm-71e5488a195dde08a76e923814e036c68033869f.zip llvm-71e5488a195dde08a76e923814e036c68033869f.tar.gz llvm-71e5488a195dde08a76e923814e036c68033869f.tar.bz2 |
DebugInfo: Migrate callers from getAsCString to dwarf::toString
This makes a bunch of these call sites independent of a follow-up change
I'm making to have getAsCString return Expected<const char*> for more
descriptive error messages so that the failures there can be
communicated up to DWARFVerifier (or other callers who want to provide
more verbose diagnostics) so DWARFVerifier doesn't have to re-implement
the string lookup logic and error checking.
Diffstat (limited to 'llvm/unittests/DebugInfo')
-rw-r--r-- | llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp | 2 | ||||
-rw-r--r-- | llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp | 4 | ||||
-rw-r--r-- | llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp | 19 |
3 files changed, 10 insertions, 15 deletions
diff --git a/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp b/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp index a4e6b56..68d0600 100644 --- a/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp +++ b/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp @@ -1504,7 +1504,7 @@ TEST(DWARFDebugInfo, TestAttributeIterators) { ASSERT_NE(E, I); EXPECT_EQ(I->Attr, DW_AT_name); - auto ActualCUPath = I->Value.getAsCString(); + auto ActualCUPath = toString(I->Value); EXPECT_EQ(CUPath, *ActualCUPath); ASSERT_NE(E, ++I); diff --git a/llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp b/llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp index c01a20e91..a8502df 100644 --- a/llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp +++ b/llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp @@ -170,11 +170,11 @@ void checkDefaultPrologue(uint16_t Version, DwarfFormat Format, EXPECT_EQ(Prologue.StandardOpcodeLengths, ExpectedLengths); ASSERT_EQ(Prologue.IncludeDirectories.size(), 1u); ASSERT_EQ(Prologue.IncludeDirectories[0].getForm(), DW_FORM_string); - EXPECT_STREQ(*Prologue.IncludeDirectories[0].getAsCString(), "a dir"); + EXPECT_STREQ(*toString(Prologue.IncludeDirectories[0]), "a dir"); ASSERT_EQ(Prologue.FileNames.size(), 1u); ASSERT_EQ(Prologue.FileNames[0].Name.getForm(), DW_FORM_string); ASSERT_EQ(Prologue.FileNames[0].DirIdx, 0u); - EXPECT_STREQ(*Prologue.FileNames[0].Name.getAsCString(), "a file"); + EXPECT_STREQ(*toString(Prologue.FileNames[0].Name), "a file"); } #ifdef _AIX diff --git a/llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp b/llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp index 1f7e922..e294239 100644 --- a/llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp +++ b/llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp @@ -336,15 +336,13 @@ static void writeCString(StringRef Str, AsmPrinter &Asm) { static void writeV2IncludeAndFileTable(const DWARFDebugLine::Prologue &Prologue, AsmPrinter &Asm) { - for (auto Include : Prologue.IncludeDirectories) { - assert(Include.getAsCString() && "expected a string form for include dir"); - writeCString(*Include.getAsCString(), Asm); - } + for (auto Include : Prologue.IncludeDirectories) + writeCString(*toString(Include), Asm); + Asm.emitInt8(0); for (auto File : Prologue.FileNames) { - assert(File.Name.getAsCString() && "expected a string form for file name"); - writeCString(*File.Name.getAsCString(), Asm); + writeCString(*toString(File.Name), Asm); Asm.emitULEB128(File.DirIdx); Asm.emitULEB128(File.ModTime); Asm.emitULEB128(File.Length); @@ -360,10 +358,8 @@ static void writeV5IncludeAndFileTable(const DWARFDebugLine::Prologue &Prologue, Asm.emitULEB128(DW_LNCT_path); Asm.emitULEB128(DW_FORM_string); Asm.emitULEB128(Prologue.IncludeDirectories.size()); - for (auto Include : Prologue.IncludeDirectories) { - assert(Include.getAsCString() && "expected a string form for include dir"); - writeCString(*Include.getAsCString(), Asm); - } + for (auto Include : Prologue.IncludeDirectories) + writeCString(*toString(Include), Asm); Asm.emitInt8(2); // file_name_entry_format_count. Asm.emitULEB128(DW_LNCT_path); @@ -372,8 +368,7 @@ static void writeV5IncludeAndFileTable(const DWARFDebugLine::Prologue &Prologue, Asm.emitULEB128(DW_FORM_data1); Asm.emitULEB128(Prologue.FileNames.size()); for (auto File : Prologue.FileNames) { - assert(File.Name.getAsCString() && "expected a string form for file name"); - writeCString(*File.Name.getAsCString(), Asm); + writeCString(*toString(File.Name), Asm); Asm.emitInt8(File.DirIdx); } } |