[llvm] [llvm-nm][GOFF] Display archive attributes in GOFF archives through --print-armap (PR #214527)

James Henderson via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 14 02:11:18 PDT 2026


================
@@ -2046,38 +2046,38 @@ static bool checkMachOAndArchFlags(SymbolicFile *O, StringRef Filename) {
 }
 
 /// Decode the low 3 bits of a z/OS archive symbol attribute word into a
-/// human-readable string, e.g. "[64-bit + XPLink]".
+/// human-readable description written to OS, e.g. "[64-bit + XPLink]".
 /// Any bits above the known 3-bit mask produce a trailing "?" flag.
-static std::string decodeZOSAttributes(uint32_t Attrs) {
+static void decodeZOSAttributes(raw_ostream &OS, uint32_t Attrs) {
   bool Unknown = (Attrs & ~Archive::Symbol::ZOSKnownAttrMask) != 0;
   bool Is64Bit = (Attrs & Archive::Symbol::ZOSAttr64Bit) != 0;
   bool IsXPLink = (Attrs & Archive::Symbol::ZOSAttrXPLink) != 0;
   bool IsWSA = (Attrs & Archive::Symbol::ZOSAttrWSA) != 0;
 
-  std::string Result = "[";
+  OS << "[";
   bool NeedPlus = false;
-  auto append = [&](const char *S) {
+  auto Append = [&](const char *S) {
     if (NeedPlus)
-      Result += " + ";
-    Result += S;
+      OS << " + ";
+    OS << S;
     NeedPlus = true;
   };
   if (Is64Bit)
-    append("64-bit");
+    Append("64-bit");
   if (IsXPLink)
-    append("XPLink");
+    Append("XPLink");
   if (IsWSA)
-    append("WSA");
+    Append("WSA");
   if (Unknown)
-    append("?");
+    Append("?");
   if (!NeedPlus)
-    append("none");
-  Result += "]";
-  return Result;
+    Append("none");
+  OS << "]";
 }
 
 static void printArchiveMap(iterator_range<Archive::symbol_iterator> &Map,
-                            StringRef Filename, bool PrintZOSAttrs = false) {
+                            StringRef Filename,
+                            Archive::Kind Kind = Archive::K_GNU) {
----------------
jh7370 wrote:

I'd prefer it if this didn't have a default argument - that's just a recipe for forgetting to provide the value and getting the wrong one, which could be a source of bugs in the future. It's not like this is used heavily, plus the `Kind` is easily available.

https://github.com/llvm/llvm-project/pull/214527


More information about the llvm-commits mailing list