dwarfdump: Avoid parsing units unnecessarily

NFC-ish (the parsing of the units is not a functional change - no
errors/warnings are emitted during the shallow parsing - though without
parsing them here, the "max version" would be wrong (still zero) later
on, so in those cases the units do need to be parsed)

llvm-svn: 343884
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
index 5d9f5a3..118a2eb 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
@@ -328,21 +328,20 @@
                  DObj->getAbbrevDWOSection()))
     getDebugAbbrevDWO()->dump(OS);
 
-  auto dumpDebugInfo = [&](bool IsExplicit, const char *Name,
-                           DWARFSection Section, unit_iterator_range Units) {
-    if (shouldDump(IsExplicit, Name, DIDT_ID_DebugInfo, Section.Data)) {
-      if (DumpOffset)
-        getDIEForOffset(DumpOffset.getValue())
-            .dump(OS, 0, DumpOpts.noImplicitRecursion());
-      else
-        for (const auto &U : Units)
-          U->dump(OS, DumpOpts);
-    }
+  auto dumpDebugInfo = [&](unit_iterator_range Units) {
+    if (DumpOffset)
+      getDIEForOffset(DumpOffset.getValue())
+          .dump(OS, 0, DumpOpts.noImplicitRecursion());
+    else
+      for (const auto &U : Units)
+        U->dump(OS, DumpOpts);
   };
-  dumpDebugInfo(Explicit, ".debug_info", DObj->getInfoSection(),
-                info_section_units());
-  dumpDebugInfo(ExplicitDWO, ".debug_info.dwo", DObj->getInfoDWOSection(),
-                dwo_info_section_units());
+  if (shouldDump(Explicit, ".debug_info", DIDT_ID_DebugInfo,
+                 DObj->getInfoSection().Data))
+    dumpDebugInfo(info_section_units());
+  if (shouldDump(ExplicitDWO, ".debug_info.dwo", DIDT_ID_DebugInfo,
+                 DObj->getInfoDWOSection().Data))
+    dumpDebugInfo(dwo_info_section_units());
 
   auto dumpDebugType = [&](const char *Name, unit_iterator_range Units) {
     OS << '\n' << Name << " contents:\n";
@@ -543,7 +542,7 @@
     dumpStringOffsetsSection(OS, "debug_str_offsets.dwo", *DObj,
                              DObj->getStringOffsetDWOSection(),
                              DObj->getStringDWOSection(), dwo_units(),
-                             isLittleEndian(), getMaxVersion());
+                             isLittleEndian(), getMaxDWOVersion());
 
   if (shouldDump(Explicit, ".gnu_index", DIDT_ID_GdbIndex,
                  DObj->getGdbIndexSection())) {