[clang] [clang] Enable descriptions for --print-supported-extensions (PR #66715)

David Spickett via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 20 01:59:28 PDT 2023


================
@@ -600,11 +601,16 @@ StringRef ARM::getARMCPUForArch(const llvm::Triple &Triple, StringRef MArch) {
   llvm_unreachable("invalid arch name");
 }
 
-void ARM::PrintSupportedExtensions() {
-  outs() << "All available -march extensions for ARM\n\n";
+void ARM::PrintSupportedExtensions(llvm::StringMap<llvm::StringRef> llvmDescMap) {
+  outs() << "All available -march extensions for ARM\n\n"
+         << "    " << left_justify("Name", 20)
+         << (llvmDescMap.empty() ? "\n" : "Description\n");
+
   for (const auto &Ext : ARCHExtNames) {
     // Extensions without a feature cannot be used with -march.
     if (!Ext.Feature.empty())
-      outs() << '\t' << Ext.Name << "\n";
+      outs() << format("    %-20s", Ext.Name.str().c_str())
+             << format(llvmDescMap.empty() ? "\n" : "%s\n",
+                       llvmDescMap[Ext.Name].str().c_str());
----------------
DavidSpickett wrote:

I was about to say this crashes if the lookup fails, it might in asserts builds, but given this is a map it'll default construct the value which in this case is empty string. Which is fine.

So leave this as is and ignore my earlier comments about the lookup, I forgot that maps have this quirk to them.

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


More information about the cfe-commits mailing list