[llvm] [llvm-objdump] Support --mcpu=help/--mattr=help without -d (PR #165661)
Ruoyu Qiu via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 5 04:52:29 PST 2025
cabbaken wrote:
I have added some test cases and fix the behavior of 'mcpu=help + --triple' (won't emit error anymore).
I think you may have any thoughts on this approach (Because it looks a bit inelegant)
```
const bool PrintCpuHelp = (MCPU == "help" || is_contained(MAttrs, "help"));
const bool ShouldDump =
ArchiveHeaders || Disassemble || DwarfDumpType != DIDT_Null ||
DynamicRelocations || FileHeaders || PrivateHeaders || RawClangAST ||
Relocations || SectionHeaders || SectionContents || SymbolTable ||
DynamicSymbolTable || UnwindInfo || FaultMapSection || Offloading ||
(MachOOpt &&
(Bind || DataInCode || ChainedFixups || DyldInfo || DylibId ||
DylibsUsed || ExportsTrie || FirstPrivateHeader ||
FunctionStartsType != FunctionStartsMode::None || IndirectSymbols ||
InfoPlist || LazyBind || LinkOptHints || ObjcMetaData || Rebase ||
Rpaths || UniversalHeaders || WeakBind || !FilterSections.empty()));
if (!ShouldDump && !PrintCpuHelp) {
T->printHelp(ToolName);
return 2;
}
// If the target triple is derived from the files, we display help message
// when disassembling them.
if (!Disassemble && PrintCpuHelp) {
mcpuHelp();
if (!ShouldDump)
return EXIT_SUCCESS;
}
```
Unfortunately, I wasn't able to come up with a cleaner implementation at this time.
Regarding the test cases, I assume that other error scenarios are already handled in other files.
Do you consider these cases sufficient for this PR?
https://github.com/llvm/llvm-project/pull/165661
More information about the llvm-commits
mailing list