Skip to content

Commit 5c17049

Browse files
committed
Address reviewer feedback.
- Do .str() around the full string concatenation - Reorganize test
1 parent d2f1eee commit 5c17049

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

llvm/lib/ObjectYAML/MachOEmitter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,8 @@ void MachOWriter::writeLoadCommands(raw_ostream &OS) {
305305
if (NameCStr)
306306
Name = NameCStr;
307307
else
308-
Name =
309-
"(0x" + Twine::utohexstr(LC.Data.load_command_data.cmd).str() + ")";
308+
Name = ("(0x" + Twine::utohexstr(LC.Data.load_command_data.cmd) + ")")
309+
.str();
310310

311311
WithColor::warning() << "load command " << i << " " << Name
312312
<< " cmdsize too small ("

llvm/test/ObjectYAML/MachO/load-cmdsize-too-small.yaml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
## Test that yaml2obj handles load commands with cmdsize smaller than the
22
## actual structure size without crashing (due to integer underflow).
33

4+
## Test with a known load command (LC_SEGMENT_64).
45
# RUN: yaml2obj %s --docnum=1 -o %t1 2>&1 | FileCheck %s --check-prefix=WARNING-KNOWN
56
# RUN: not llvm-readobj --file-headers %t1 2>&1 | FileCheck %s --check-prefix=MALFORMED
67

7-
# RUN: yaml2obj %s --docnum=2 -o %t2 2>&1 | FileCheck %s --check-prefix=WARNING-UNKNOWN
8-
98
# WARNING-KNOWN: warning: load command 0 LC_SEGMENT_64 cmdsize too small (56 bytes) for actual size (72 bytes)
109

1110
# MALFORMED: error: {{.*}}: truncated or malformed object (load command 0 LC_SEGMENT_64 cmdsize too small)
12-
13-
# WARNING-UNKNOWN: warning: load command 0 (0xdeadbeef) cmdsize too small (8 bytes) for actual size (20 bytes)
14-
15-
## Test with a known load command (LC_SEGMENT_64)
1611
--- !mach-o
1712
FileHeader:
1813
magic: 0xFEEDFACF
@@ -37,7 +32,10 @@ LoadCommands:
3732
flags: 0
3833
...
3934

40-
## Test with an unknown load command value
35+
## Test with an unknown load command value.
36+
# RUN: yaml2obj %s --docnum=2 -o %t2 2>&1 | FileCheck %s --check-prefix=WARNING-UNKNOWN
37+
38+
# WARNING-UNKNOWN: warning: load command 0 (0xdeadbeef) cmdsize too small (8 bytes) for actual size (20 bytes)
4139
--- !mach-o
4240
FileHeader:
4341
magic: 0xFEEDFACF

0 commit comments

Comments
 (0)