[llvm] [dsymutil] Add new argument allow_invalid_macho (PR #173503)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 24 10:16:54 PST 2025
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 origin/main HEAD --extensions cpp,h -- llvm/tools/dsymutil/DwarfLinkerForBinary.cpp llvm/tools/dsymutil/LinkUtils.h llvm/tools/dsymutil/MachOUtils.cpp llvm/tools/dsymutil/MachOUtils.h llvm/tools/dsymutil/dsymutil.cpp --diff_from_common_commit
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/tools/dsymutil/MachOUtils.cpp b/llvm/tools/dsymutil/MachOUtils.cpp
index deb2225dc..622d1524d 100644
--- a/llvm/tools/dsymutil/MachOUtils.cpp
+++ b/llvm/tools/dsymutil/MachOUtils.cpp
@@ -322,9 +322,10 @@ static void transferSegmentAndSections(
}
// Write the __DWARF segment load command to the output file.
-static bool createDwarfSegment(const MCAssembler& Asm,uint64_t VMAddr, uint64_t FileOffset,
- uint64_t FileSize, unsigned NumSections,
- MachObjectWriter &Writer, bool AllowInvalidMachO) {
+static bool createDwarfSegment(const MCAssembler &Asm, uint64_t VMAddr,
+ uint64_t FileOffset, uint64_t FileSize,
+ unsigned NumSections, MachObjectWriter &Writer,
+ bool AllowInvalidMachO) {
Writer.writeSegmentLoadCommand("__DWARF", NumSections, VMAddr,
alignTo(FileSize, 0x1000), FileOffset,
FileSize, /* MaxProt */ 7,
@@ -374,7 +375,8 @@ bool generateDsymCompanion(
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS, const DebugMap &DM,
MCStreamer &MS, raw_fd_ostream &OutFile,
const std::vector<MachOUtils::DwarfRelocationApplicationInfo>
- &RelocationsToApply, bool AllowInvalidMachO) {
+ &RelocationsToApply,
+ bool AllowInvalidMachO) {
auto &ObjectStreamer = static_cast<MCObjectStreamer &>(MS);
MCAssembler &MCAsm = ObjectStreamer.getAssembler();
auto &Writer = static_cast<MachObjectWriter &>(MCAsm.getWriter());
@@ -585,8 +587,9 @@ bool generateDsymCompanion(
}
// Write the load command for the __DWARF segment.
- if (!createDwarfSegment(MCAsm, DwarfVMAddr, DwarfSegmentStart, DwarfSegmentSize,
- NumDwarfSections, Writer, AllowInvalidMachO))
+ if (!createDwarfSegment(MCAsm, DwarfVMAddr, DwarfSegmentStart,
+ DwarfSegmentSize, NumDwarfSections, Writer,
+ AllowInvalidMachO))
return false;
assert(OutFile.tell() == LoadCommandSize + HeaderSize);
diff --git a/llvm/tools/dsymutil/MachOUtils.h b/llvm/tools/dsymutil/MachOUtils.h
index d276a21b6..ecbb36fea 100644
--- a/llvm/tools/dsymutil/MachOUtils.h
+++ b/llvm/tools/dsymutil/MachOUtils.h
@@ -59,7 +59,8 @@ bool generateDsymCompanion(
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS, const DebugMap &DM,
MCStreamer &MS, raw_fd_ostream &OutFile,
const std::vector<MachOUtils::DwarfRelocationApplicationInfo>
- &RelocationsToApply, bool AllowInvalidMachO);
+ &RelocationsToApply,
+ bool AllowInvalidMachO);
std::string getArchName(StringRef Arch);
} // namespace MachOUtils
diff --git a/llvm/tools/dsymutil/dsymutil.cpp b/llvm/tools/dsymutil/dsymutil.cpp
index 0a3af1bdb..bdf4f1317 100644
--- a/llvm/tools/dsymutil/dsymutil.cpp
+++ b/llvm/tools/dsymutil/dsymutil.cpp
@@ -315,8 +315,7 @@ static Expected<DsymutilOptions> getOptions(opt::InputArgList &Args) {
Options.LinkOpts.Fat64 = Args.hasArg(OPT_fat64);
Options.LinkOpts.KeepFunctionForStatic =
Args.hasArg(OPT_keep_func_for_static);
- Options.LinkOpts.AllowInvalidMachO =
- Args.hasArg(OPT_allow_invalid_macho);
+ Options.LinkOpts.AllowInvalidMachO = Args.hasArg(OPT_allow_invalid_macho);
if (opt::Arg *ReproducerPath = Args.getLastArg(OPT_use_reproducer)) {
Options.ReproMode = ReproducerMode::Use;
``````````
</details>
https://github.com/llvm/llvm-project/pull/173503
More information about the llvm-commits
mailing list