[llvm] Modify llvm-gsymutil to ignore invalid file indexes. (PR #70876)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 31 17:13:11 PDT 2023
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff 604eff60abfce09f956c3b0b1414f8d0d04b5d47 7593ea78fc10c7d5b87c4cae6a1443659435cf26 -- llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp llvm/unittests/DebugInfo/GSYM/GSYMTest.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp b/llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp
index 92d1ce148c23..ecd3572c7e42 100644
--- a/llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp
+++ b/llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp
@@ -65,8 +65,8 @@ struct llvm::gsym::CUInfo {
/// the first client that asks for a compile unit file index will end up
/// doing the conversion, and subsequent clients will get the cached GSYM
/// index.
- std::optional<uint32_t>
- DWARFToGSYMFileIndex(GsymCreator &Gsym, uint32_t DwarfFileIdx) {
+ std::optional<uint32_t> DWARFToGSYMFileIndex(GsymCreator &Gsym,
+ uint32_t DwarfFileIdx) {
if (!LineTable || DwarfFileIdx >= FileCache.size())
return std::nullopt;
uint32_t &GsymFileIdx = FileCache[DwarfFileIdx];
@@ -320,11 +320,11 @@ static void convertFunctionLineTable(raw_ostream *Log, CUInfo &CUI,
// If we had a DW_AT_decl_file, but got no file then we need to emit a
// warning.
if (Log) {
- const uint64_t DwarfFileIdx =
- dwarf::toUnsigned(Die.findRecursively(dwarf::DW_AT_decl_file),
- UINT32_MAX);
+ const uint64_t DwarfFileIdx = dwarf::toUnsigned(
+ Die.findRecursively(dwarf::DW_AT_decl_file), UINT32_MAX);
*Log << "error: function DIE at " << HEX32(Die.getOffset())
- << " has an invalid file index " << DwarfFileIdx << " in its "
+ << " has an invalid file index " << DwarfFileIdx
+ << " in its "
"DW_AT_decl_file attribute, unable to create a single line "
"entry from the DW_AT_decl_file/DW_AT_decl_line attributes.\n";
}
@@ -344,7 +344,8 @@ static void convertFunctionLineTable(raw_ostream *Log, CUInfo &CUI,
for (uint32_t RowIndex : RowVector) {
// Take file number and line/column from the row.
const DWARFDebugLine::Row &Row = CUI.LineTable->Rows[RowIndex];
- std::optional<uint32_t> OptFileIdx = CUI.DWARFToGSYMFileIndex(Gsym, Row.File);
+ std::optional<uint32_t> OptFileIdx =
+ CUI.DWARFToGSYMFileIndex(Gsym, Row.File);
if (!OptFileIdx) {
if (Log) {
*Log << "error: function DIE at " << HEX32(Die.getOffset()) << " has "
diff --git a/llvm/unittests/DebugInfo/GSYM/GSYMTest.cpp b/llvm/unittests/DebugInfo/GSYM/GSYMTest.cpp
index 5956324ca7e0..29f7b2a81d9c 100644
--- a/llvm/unittests/DebugInfo/GSYM/GSYMTest.cpp
+++ b/llvm/unittests/DebugInfo/GSYM/GSYMTest.cpp
@@ -4158,7 +4158,6 @@ TEST(GSYMTest, TestEmptyLinkageName) {
EXPECT_TRUE(errors.find("error:") == std::string::npos);
}
-
TEST(GSYMTest, TestHandlingOfInvalidFileIndexes) {
// Test that llvm-gsymutil can handle invalid file indexes in the following
// cases:
@@ -4186,7 +4185,8 @@ TEST(GSYMTest, TestHandlingOfInvalidFileIndexes) {
// DW_AT_call_line (11)
//
// 0x00000047: DW_TAG_inlined_subroutine
- // DW_AT_name ("inline_inside_parent_with_invalid_call_file")
+ // DW_AT_name
+ // ("inline_inside_parent_with_invalid_call_file")
// DW_AT_low_pc (0x0000000000001010)
// DW_AT_high_pc (0x0000000000001015)
// DW_AT_call_file ("/tmp/main.cpp")
@@ -4202,7 +4202,8 @@ TEST(GSYMTest, TestHandlingOfInvalidFileIndexes) {
// DW_AT_call_line (13)
//
// 0x00000082: DW_TAG_inlined_subroutine
- // DW_AT_name ("inline_inside_parent_with_valid_call_file")
+ // DW_AT_name
+ // ("inline_inside_parent_with_valid_call_file")
// DW_AT_low_pc (0x0000000000001020)
// DW_AT_high_pc (0x0000000000001025)
// DW_AT_call_file ("/tmp/main.cpp")
@@ -4237,7 +4238,8 @@ TEST(GSYMTest, TestHandlingOfInvalidFileIndexes) {
// 0x0000000000001010 11 0 10 0 0 is_stmt
// 0x0000000000001020 11 0 1 0 0 is_stmt
// 0x0000000000001030 12 0 1 0 0 is_stmt
- // 0x0000000000001050 12 0 1 0 0 is_stmt end_sequence
+ // 0x0000000000001050 12 0 1 0 0 is_stmt
+ // end_sequence
StringRef yamldata = R"(
debug_str:
@@ -4499,17 +4501,17 @@ TEST(GSYMTest, TestHandlingOfInvalidFileIndexes) {
// Make sure we don't see spurious errors in the output:
std::vector<std::string> ExpectedLogErrors = {
- "error: function DIE at 0x00000015 has a line entry with invalid DWARF "
- "file index, this entry will be removed:",
- "error: inlined function DIE at 0x0000002a has an invalid file index 10 "
- "in its DW_AT_call_file attribute, this inline entry and all children "
- "will be removed.",
- "error: function DIE at 0x000000b8 has an invalid file index 10 in its "
- "DW_AT_decl_file attribute, unable to create a single line entry from the "
- "DW_AT_decl_file/DW_AT_decl_line attributes."
- };
+ "error: function DIE at 0x00000015 has a line entry with invalid DWARF "
+ "file index, this entry will be removed:",
+ "error: inlined function DIE at 0x0000002a has an invalid file index 10 "
+ "in its DW_AT_call_file attribute, this inline entry and all children "
+ "will be removed.",
+ "error: function DIE at 0x000000b8 has an invalid file index 10 in its "
+ "DW_AT_decl_file attribute, unable to create a single line entry from "
+ "the "
+ "DW_AT_decl_file/DW_AT_decl_line attributes."};
// Make sure all expected errors are in the error stream for the two invalid
// inlined functions that we removed due to invalid range scoping.
- for (const auto &Error: ExpectedLogErrors)
+ for (const auto &Error : ExpectedLogErrors)
EXPECT_TRUE(OS.str().find(Error) != std::string::npos);
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/70876
More information about the llvm-commits
mailing list