[llvm] 85a5360 - [llvm-objdump] Remove "No" prefixes on variables

Nico Weber via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 20 12:30:25 PDT 2021


Author: Nico Weber
Date: 2021-04-20T15:29:07-04:00
New Revision: 85a5360b964ceac19d45a4433305c987ea3c5580

URL: https://github.com/llvm/llvm-project/commit/85a5360b964ceac19d45a4433305c987ea3c5580
DIFF: https://github.com/llvm/llvm-project/commit/85a5360b964ceac19d45a4433305c987ea3c5580.diff

LOG: [llvm-objdump] Remove "No" prefixes on variables

...to remove double negation in the code. Requested in D100583.

No behavior change.

Differential Revision: https://reviews.llvm.org/D100849

Added: 
    

Modified: 
    llvm/tools/llvm-objdump/MachODump.cpp
    llvm/tools/llvm-objdump/MachODump.h
    llvm/tools/llvm-objdump/llvm-objdump.cpp
    llvm/tools/llvm-objdump/llvm-objdump.h

Removed: 
    


################################################################################
diff  --git a/llvm/tools/llvm-objdump/MachODump.cpp b/llvm/tools/llvm-objdump/MachODump.cpp
index 3574c45b31bc..77d74fc848e2 100644
--- a/llvm/tools/llvm-objdump/MachODump.cpp
+++ b/llvm/tools/llvm-objdump/MachODump.cpp
@@ -72,7 +72,7 @@ bool objdump::WeakBind;
 static bool UseDbg;
 static std::string DSYMFile;
 bool objdump::FullLeadingAddr;
-bool objdump::NoLeadingHeaders;
+bool objdump::LeadingHeaders;
 bool objdump::UniversalHeaders;
 static bool ArchiveMemberOffsets;
 bool objdump::IndirectSymbols;
@@ -85,7 +85,7 @@ bool objdump::DylibId;
 bool objdump::Verbose;
 bool objdump::ObjcMetaData;
 std::string objdump::DisSymName;
-bool objdump::NoSymbolicOperands;
+bool objdump::SymbolicOperands;
 static std::vector<std::string> ArchFlags;
 
 static bool ArchAll = false;
@@ -101,7 +101,7 @@ void objdump::parseMachOOptions(const llvm::opt::InputArgList &InputArgs) {
   UseDbg = InputArgs.hasArg(OBJDUMP_g);
   DSYMFile = InputArgs.getLastArgValue(OBJDUMP_dsym_EQ).str();
   FullLeadingAddr = InputArgs.hasArg(OBJDUMP_full_leading_addr);
-  NoLeadingHeaders = InputArgs.hasArg(OBJDUMP_no_leading_headers);
+  LeadingHeaders = !InputArgs.hasArg(OBJDUMP_no_leading_headers);
   UniversalHeaders = InputArgs.hasArg(OBJDUMP_universal_headers);
   ArchiveMemberOffsets = InputArgs.hasArg(OBJDUMP_archive_member_offsets);
   IndirectSymbols = InputArgs.hasArg(OBJDUMP_indirect_symbols);
@@ -114,7 +114,7 @@ void objdump::parseMachOOptions(const llvm::opt::InputArgList &InputArgs) {
   Verbose = !InputArgs.hasArg(OBJDUMP_non_verbose);
   ObjcMetaData = InputArgs.hasArg(OBJDUMP_objc_meta_data);
   DisSymName = InputArgs.getLastArgValue(OBJDUMP_dis_symname).str();
-  NoSymbolicOperands = InputArgs.hasArg(OBJDUMP_no_symbolic_operands);
+  SymbolicOperands = !InputArgs.hasArg(OBJDUMP_no_symbolic_operands);
   ArchFlags = InputArgs.getAllArgValues(OBJDUMP_arch_EQ);
 }
 
@@ -233,19 +233,19 @@ static uint64_t DumpDataInCode(const uint8_t *bytes, uint64_t Length,
   default:
   case MachO::DICE_KIND_DATA:
     if (Length >= 4) {
-      if (!NoShowRawInsn)
+      if (ShowRawInsn)
         dumpBytes(makeArrayRef(bytes, 4), outs());
       Value = bytes[3] << 24 | bytes[2] << 16 | bytes[1] << 8 | bytes[0];
       outs() << "\t.long " << Value;
       Size = 4;
     } else if (Length >= 2) {
-      if (!NoShowRawInsn)
+      if (ShowRawInsn)
         dumpBytes(makeArrayRef(bytes, 2), outs());
       Value = bytes[1] << 8 | bytes[0];
       outs() << "\t.short " << Value;
       Size = 2;
     } else {
-      if (!NoShowRawInsn)
+      if (ShowRawInsn)
         dumpBytes(makeArrayRef(bytes, 2), outs());
       Value = bytes[0];
       outs() << "\t.byte " << Value;
@@ -257,14 +257,14 @@ static uint64_t DumpDataInCode(const uint8_t *bytes, uint64_t Length,
       outs() << "\t@ data in code kind = " << Kind << "\n";
     break;
   case MachO::DICE_KIND_JUMP_TABLE8:
-    if (!NoShowRawInsn)
+    if (ShowRawInsn)
       dumpBytes(makeArrayRef(bytes, 1), outs());
     Value = bytes[0];
     outs() << "\t.byte " << format("%3u", Value) << "\t@ KIND_JUMP_TABLE8\n";
     Size = 1;
     break;
   case MachO::DICE_KIND_JUMP_TABLE16:
-    if (!NoShowRawInsn)
+    if (ShowRawInsn)
       dumpBytes(makeArrayRef(bytes, 2), outs());
     Value = bytes[1] << 8 | bytes[0];
     outs() << "\t.short " << format("%5u", Value & 0xffff)
@@ -273,7 +273,7 @@ static uint64_t DumpDataInCode(const uint8_t *bytes, uint64_t Length,
     break;
   case MachO::DICE_KIND_JUMP_TABLE32:
   case MachO::DICE_KIND_ABS_JUMP_TABLE32:
-    if (!NoShowRawInsn)
+    if (ShowRawInsn)
       dumpBytes(makeArrayRef(bytes, 4), outs());
     Value = bytes[3] << 24 | bytes[2] << 16 | bytes[1] << 8 | bytes[0];
     outs() << "\t.long " << Value;
@@ -1743,7 +1743,7 @@ static void DumpSectionContents(StringRef Filename, MachOObjectFile *O,
         uint32_t sect_size = BytesStr.size();
         uint64_t sect_addr = Section.getAddress();
 
-        if (!NoLeadingHeaders)
+        if (LeadingHeaders)
           outs() << "Contents of (" << SegName << "," << SectName
                  << ") section\n";
 
@@ -1763,7 +1763,7 @@ static void DumpSectionContents(StringRef Filename, MachOObjectFile *O,
           }
 #ifdef HAVE_LIBXAR
           if (SegName == "__LLVM" && SectName == "__bundle") {
-            DumpBitcodeSection(O, sect, sect_size, verbose, !NoSymbolicOperands,
+            DumpBitcodeSection(O, sect, sect_size, verbose, SymbolicOperands,
                                ArchiveHeaders, "");
             continue;
           }
@@ -1776,20 +1776,20 @@ static void DumpSectionContents(StringRef Filename, MachOObjectFile *O,
             outs() << "zerofill section and has no contents in the file\n";
             break;
           case MachO::S_CSTRING_LITERALS:
-            DumpCstringSection(O, sect, sect_size, sect_addr, !NoLeadingAddr);
+            DumpCstringSection(O, sect, sect_size, sect_addr, LeadingAddr);
             break;
           case MachO::S_4BYTE_LITERALS:
-            DumpLiteral4Section(O, sect, sect_size, sect_addr, !NoLeadingAddr);
+            DumpLiteral4Section(O, sect, sect_size, sect_addr, LeadingAddr);
             break;
           case MachO::S_8BYTE_LITERALS:
-            DumpLiteral8Section(O, sect, sect_size, sect_addr, !NoLeadingAddr);
+            DumpLiteral8Section(O, sect, sect_size, sect_addr, LeadingAddr);
             break;
           case MachO::S_16BYTE_LITERALS:
-            DumpLiteral16Section(O, sect, sect_size, sect_addr, !NoLeadingAddr);
+            DumpLiteral16Section(O, sect, sect_size, sect_addr, LeadingAddr);
             break;
           case MachO::S_LITERAL_POINTERS:
             DumpLiteralPointerSection(O, Section, sect, sect_size, sect_addr,
-                                      !NoLeadingAddr);
+                                      LeadingAddr);
             break;
           case MachO::S_MOD_INIT_FUNC_POINTERS:
           case MachO::S_MOD_TERM_FUNC_POINTERS:
@@ -1826,7 +1826,7 @@ static void DumpInfoPlistSectionContents(StringRef Filename,
     DataRefImpl Ref = Section.getRawDataRefImpl();
     StringRef SegName = O->getSectionFinalSegmentName(Ref);
     if (SegName == "__TEXT" && SectName == "__info_plist") {
-      if (!NoLeadingHeaders)
+      if (LeadingHeaders)
         outs() << "Contents of (" << SegName << "," << SectName << ") section\n";
       StringRef BytesStr =
           unwrapOrError(Section.getContents(), O->getFileName());
@@ -1886,7 +1886,7 @@ static void ProcessMachO(StringRef Name, MachOObjectFile *MachOOF,
       Bind || SymbolTable || LazyBind || WeakBind || IndirectSymbols ||
       DataInCode || FunctionStarts || LinkOptHints || DylibsUsed || DylibId ||
       ObjcMetaData || (!FilterSections.empty())) {
-    if (!NoLeadingHeaders) {
+    if (LeadingHeaders) {
       outs() << Name;
       if (!ArchiveMemberName.empty())
         outs() << '(' << ArchiveMemberName << ')';
@@ -7458,13 +7458,13 @@ static void DisassembleMachO(StringRef Filename, MachOObjectFile *MachOOF,
       return;
     }
     // Set up the block of info used by the Symbolizer call backs.
-    SymbolizerInfo.verbose = !NoSymbolicOperands;
+    SymbolizerInfo.verbose = SymbolicOperands;
     SymbolizerInfo.O = MachOOF;
     SymbolizerInfo.S = Sections[SectIdx];
     SymbolizerInfo.AddrMap = &AddrMap;
     SymbolizerInfo.Sections = &Sections;
     // Same for the ThumbSymbolizer
-    ThumbSymbolizerInfo.verbose = !NoSymbolicOperands;
+    ThumbSymbolizerInfo.verbose = SymbolicOperands;
     ThumbSymbolizerInfo.O = MachOOF;
     ThumbSymbolizerInfo.S = Sections[SectIdx];
     ThumbSymbolizerInfo.AddrMap = &AddrMap;
@@ -7589,7 +7589,7 @@ static void DisassembleMachO(StringRef Filename, MachOObjectFile *MachOOF,
           outs() << SymName << ":\n";
 
         uint64_t PC = SectAddress + Index;
-        if (!NoLeadingAddr) {
+        if (LeadingAddr) {
           if (FullLeadingAddr) {
             if (MachOOF->is64Bit())
               outs() << format("%016" PRIx64, PC);
@@ -7599,7 +7599,7 @@ static void DisassembleMachO(StringRef Filename, MachOObjectFile *MachOOF,
             outs() << format("%8" PRIx64 ":", PC);
           }
         }
-        if (!NoShowRawInsn || Arch == Triple::arm)
+        if (ShowRawInsn || Arch == Triple::arm)
           outs() << "\t";
 
         if (DumpAndSkipDataInCode(PC, Bytes.data() + Index, Dices, Size))
@@ -7616,7 +7616,7 @@ static void DisassembleMachO(StringRef Filename, MachOObjectFile *MachOOF,
           gotInst = DisAsm->getInstruction(Inst, Size, Bytes.slice(Index), PC,
                                            Annotations);
         if (gotInst) {
-          if (!NoShowRawInsn || Arch == Triple::arm) {
+          if (ShowRawInsn || Arch == Triple::arm) {
             dumpBytes(makeArrayRef(Bytes.data() + Index, Size), outs());
           }
           formatted_raw_ostream FormattedOS(outs());
@@ -7686,7 +7686,7 @@ static void DisassembleMachO(StringRef Filename, MachOObjectFile *MachOOF,
         raw_svector_ostream Annotations(AnnotationsBytes);
         if (DisAsm->getInstruction(Inst, InstSize, Bytes.slice(Index), PC,
                                    Annotations)) {
-          if (!NoLeadingAddr) {
+          if (LeadingAddr) {
             if (FullLeadingAddr) {
               if (MachOOF->is64Bit())
                 outs() << format("%016" PRIx64, PC);
@@ -7696,7 +7696,7 @@ static void DisassembleMachO(StringRef Filename, MachOObjectFile *MachOOF,
               outs() << format("%8" PRIx64 ":", PC);
             }
           }
-          if (!NoShowRawInsn || Arch == Triple::arm) {
+          if (ShowRawInsn || Arch == Triple::arm) {
             outs() << "\t";
             dumpBytes(makeArrayRef(Bytes.data() + Index, InstSize), outs());
           }

diff  --git a/llvm/tools/llvm-objdump/MachODump.h b/llvm/tools/llvm-objdump/MachODump.h
index bfe3fd71c954..1d514617e7ee 100644
--- a/llvm/tools/llvm-objdump/MachODump.h
+++ b/llvm/tools/llvm-objdump/MachODump.h
@@ -33,11 +33,11 @@ namespace objdump {
 void parseMachOOptions(const llvm::opt::InputArgList &InputArgs);
 
 // MachO specific options
-extern cl::OptionCategory MachOCat;
 extern bool Bind;
 extern bool DataInCode;
-extern bool DylibsUsed;
+extern std::string DisSymName;
 extern bool DylibId;
+extern bool DylibsUsed;
 extern bool ExportsTrie;
 extern bool FirstPrivateHeader;
 extern bool FullLeadingAddr;
@@ -45,14 +45,13 @@ extern bool FunctionStarts;
 extern bool IndirectSymbols;
 extern bool InfoPlist;
 extern bool LazyBind;
+extern bool LeadingHeaders;
 extern bool LinkOptHints;
-extern bool NoLeadingHeaders;
-extern bool NoSymbolicOperands;
-extern bool Verbose;
 extern bool ObjcMetaData;
-extern std::string DisSymName;
 extern bool Rebase;
+extern bool SymbolicOperands;
 extern bool UniversalHeaders;
+extern bool Verbose;
 extern bool WeakBind;
 
 Error getMachORelocationValueString(const object::MachOObjectFile *Obj,

diff  --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp
index 186fce824b94..265cb528a252 100644
--- a/llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -193,8 +193,8 @@ static bool PrintLines;
 static bool MachOOpt;
 std::string objdump::MCPU;
 std::vector<std::string> objdump::MAttrs;
-bool objdump::NoShowRawInsn;
-bool objdump::NoLeadingAddr;
+bool objdump::ShowRawInsn;
+bool objdump::LeadingAddr;
 static bool RawClangAST;
 bool objdump::Relocations;
 bool objdump::PrintImmHex;
@@ -432,7 +432,7 @@ namespace {
 /// Get the column at which we want to start printing the instruction
 /// disassembly, taking into account anything which appears to the left of it.
 unsigned getInstStartColumn(const MCSubtargetInfo &STI) {
-  return NoShowRawInsn ? 16 : STI.getTargetTriple().isX86() ? 40 : 24;
+  return !ShowRawInsn ? 16 : STI.getTargetTriple().isX86() ? 40 : 24;
 }
 
 /// Stores a single expression representing the location of a source-level
@@ -998,9 +998,9 @@ class PrettyPrinter {
     LVP.printBetweenInsts(OS, false);
 
     size_t Start = OS.tell();
-    if (!NoLeadingAddr)
+    if (LeadingAddr)
       OS << format("%8" PRIx64 ":", Address.Address);
-    if (!NoShowRawInsn) {
+    if (ShowRawInsn) {
       OS << ' ';
       dumpBytes(Bytes, OS);
     }
@@ -1031,9 +1031,9 @@ class HexagonPrettyPrinter : public PrettyPrinter {
                  formatted_raw_ostream &OS) {
     uint32_t opcode =
       (Bytes[3] << 24) | (Bytes[2] << 16) | (Bytes[1] << 8) | Bytes[0];
-    if (!NoLeadingAddr)
+    if (LeadingAddr)
       OS << format("%8" PRIx64 ":", Address);
-    if (!NoShowRawInsn) {
+    if (ShowRawInsn) {
       OS << "\t";
       dumpBytes(Bytes.slice(0, 4), OS);
       OS << format("\t%08" PRIx32, opcode);
@@ -1168,9 +1168,9 @@ class BPFPrettyPrinter : public PrettyPrinter {
                  LiveVariablePrinter &LVP) override {
     if (SP && (PrintSource || PrintLines))
       SP->printSourceLine(OS, Address, ObjectFilename, LVP);
-    if (!NoLeadingAddr)
+    if (LeadingAddr)
       OS << format("%8" PRId64 ":", Address.Address / 8);
-    if (!NoShowRawInsn) {
+    if (ShowRawInsn) {
       OS << "\t";
       dumpBytes(Bytes, OS);
     }
@@ -1735,7 +1735,7 @@ static void disassembleObject(const Target *TheTarget, const ObjectFile *Obj,
       }
 
       outs() << '\n';
-      if (!NoLeadingAddr)
+      if (LeadingAddr)
         outs() << format(Is64Bits ? "%016" PRIx64 " " : "%08" PRIx64 " ",
                          SectionAddr + Start + VMAAdjustment);
       if (Obj->isXCOFF() && SymbolDescription) {
@@ -2853,7 +2853,7 @@ static void parseOtoolOptions(const llvm::opt::InputArgList &InputArgs) {
   DataInCode = InputArgs.hasArg(OTOOL_G);
   FirstPrivateHeader = InputArgs.hasArg(OTOOL_h);
   IndirectSymbols = InputArgs.hasArg(OTOOL_I);
-  NoShowRawInsn = !InputArgs.hasArg(OTOOL_j);
+  ShowRawInsn = InputArgs.hasArg(OTOOL_j);
   PrivateHeaders = InputArgs.hasArg(OTOOL_l);
   DylibsUsed = InputArgs.hasArg(OTOOL_L);
   MCPU = InputArgs.getLastArgValue(OTOOL_mcpu_EQ).str();
@@ -2867,12 +2867,12 @@ static void parseOtoolOptions(const llvm::opt::InputArgList &InputArgs) {
   }
   if (InputArgs.hasArg(OTOOL_t))
     FilterSections.push_back("__TEXT,__text");
-  Verbose = (InputArgs.hasArg(OTOOL_v) || InputArgs.hasArg(OTOOL_V) ||
-             InputArgs.hasArg(OTOOL_o));
-  NoSymbolicOperands = !InputArgs.hasArg(OTOOL_V);
+  Verbose = InputArgs.hasArg(OTOOL_v) || InputArgs.hasArg(OTOOL_V) ||
+            InputArgs.hasArg(OTOOL_o);
+  SymbolicOperands = InputArgs.hasArg(OTOOL_V);
   if (InputArgs.hasArg(OTOOL_x))
     FilterSections.push_back(",__text");
-  NoLeadingAddr = NoLeadingHeaders = InputArgs.hasArg(OTOOL_X);
+  LeadingAddr = LeadingHeaders = !InputArgs.hasArg(OTOOL_X);
 
   InputFilenames = InputArgs.getAllArgValues(OTOOL_INPUT);
   if (InputFilenames.empty())
@@ -2914,8 +2914,8 @@ static void parseObjdumpOptions(const llvm::opt::InputArgList &InputArgs) {
   MachOOpt = InputArgs.hasArg(OBJDUMP_macho);
   MCPU = InputArgs.getLastArgValue(OBJDUMP_mcpu_EQ).str();
   MAttrs = commaSeparatedValues(InputArgs, OBJDUMP_mattr_EQ);
-  NoShowRawInsn = InputArgs.hasArg(OBJDUMP_no_show_raw_insn);
-  NoLeadingAddr = InputArgs.hasArg(OBJDUMP_no_leading_addr);
+  ShowRawInsn = !InputArgs.hasArg(OBJDUMP_no_show_raw_insn);
+  LeadingAddr = !InputArgs.hasArg(OBJDUMP_no_leading_addr);
   RawClangAST = InputArgs.hasArg(OBJDUMP_raw_clang_ast);
   Relocations = InputArgs.hasArg(OBJDUMP_reloc);
   PrintImmHex =

diff  --git a/llvm/tools/llvm-objdump/llvm-objdump.h b/llvm/tools/llvm-objdump/llvm-objdump.h
index 601568d579be..e51946b3d08e 100644
--- a/llvm/tools/llvm-objdump/llvm-objdump.h
+++ b/llvm/tools/llvm-objdump/llvm-objdump.h
@@ -36,10 +36,9 @@ extern bool Disassemble;
 extern bool DisassembleAll;
 extern DIDumpType DwarfDumpType;
 extern std::vector<std::string> FilterSections;
+extern bool LeadingAddr;
 extern std::vector<std::string> MAttrs;
 extern std::string MCPU;
-extern bool NoShowRawInsn;
-extern bool NoLeadingAddr;
 extern std::string Prefix;
 extern uint32_t PrefixStrip;
 extern bool PrintImmHex;
@@ -47,6 +46,7 @@ extern bool PrivateHeaders;
 extern bool Relocations;
 extern bool SectionHeaders;
 extern bool SectionContents;
+extern bool ShowRawInsn;
 extern bool SymbolDescription;
 extern bool SymbolTable;
 extern std::string TripleName;


        


More information about the llvm-commits mailing list