[PATCH] D82768: [llvm-install-name-tool] Guard isLoadCommandWithPayloadString

Sameer Arora via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 29 07:31:29 PDT 2020


sameerarora101 created this revision.
sameerarora101 added reviewers: jhenderson, alexshap, gchatelet, smeenai, Ktwu.
Herald added subscribers: llvm-commits, MaskRay.
Herald added a reviewer: rupprecht.
Herald added a project: LLVM.

`isLoadCommandWithPayloadString` is only used by asserts and is thus
never used in release mode. To avoid the warning `warning: unused
function 'isLoadCommandWithPayloadString'`, I have guarded the function
with `#ifdef NDEBUG ... #endif`


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82768

Files:
  llvm/tools/llvm-objcopy/MachO/MachOObjcopy.cpp


Index: llvm/tools/llvm-objcopy/MachO/MachOObjcopy.cpp
===================================================================
--- llvm/tools/llvm-objcopy/MachO/MachOObjcopy.cpp
+++ llvm/tools/llvm-objcopy/MachO/MachOObjcopy.cpp
@@ -22,6 +22,7 @@
 using SectionPred = std::function<bool(const std::unique_ptr<Section> &Sec)>;
 using LoadCommandPred = std::function<bool(const LoadCommand &LC)>;
 
+#ifndef NDEBUG
 static bool isLoadCommandWithPayloadString(const LoadCommand &LC) {
   // TODO: Add support for LC_REEXPORT_DYLIB, LC_LOAD_UPWARD_DYLIB and
   // LC_LAZY_LOAD_DYLIB
@@ -30,6 +31,7 @@
          LC.MachOLoadCommand.load_command_data.cmd == MachO::LC_LOAD_DYLIB ||
          LC.MachOLoadCommand.load_command_data.cmd == MachO::LC_LOAD_WEAK_DYLIB;
 }
+#endif
 
 static StringRef getLoadCommandPayloadString(const LoadCommand &LC) {
   assert(isLoadCommandWithPayloadString(LC) &&


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82768.274107.patch
Type: text/x-patch
Size: 885 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200629/eea82ca6/attachment-0001.bin>


More information about the llvm-commits mailing list