[llvm] [llvm-objdump] Support --mcpu=help/--mattr=help without -d (PR #165661)

James Henderson via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 10 00:03:44 PST 2025


================
@@ -3533,6 +3533,33 @@ commaSeparatedValues(const llvm::opt::InputArgList &InputArgs, int ID) {
   return Values;
 }
 
+static void mcpuHelp() {
+  std::string Error;
+  Triple TheTriple;
+
+  if (!TripleName.empty()) {
+    TheTriple.setTriple(TripleName);
+  } else {
+    // We can guarantee that InputFilenames won't be empty.
+    Expected<OwningBinary<Binary>> OBinary = createBinary(InputFilenames[0]);
+    // OwningBinary<Binary> OBinary =
+    if (!OBinary)
+      reportError(InputFilenames[0],
+                  "A target triple was not specified and could "
----------------
jh7370 wrote:

You can use `toString` (https://github.com/llvm/llvm-project/blob/56e092c089ed6194b617593eadea45787a29564f/llvm/include/llvm/Support/Error.h#L1070) to convert the contents of an Error into a string representation, which can then be used as part of a wider error/warning message. In this case, something like:
```
reportError("triple was not specified and could not "
                   "be inferred from the input file: " + toString(E),
                   InputFilenames[0]);
```
would do the job, I think.

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


More information about the llvm-commits mailing list