:createMCStreamer: delete InstPrinter on error

This commit is contained in:
Fangrui Song 2025-04-09 19:57:38 -07:00
parent d1badf5635
commit 2b8cc651dc

View File

@ -166,9 +166,12 @@ CodeGenTargetMachineImpl::createMCStreamer(raw_pwrite_stream &Out,
getTargetTriple(),
Options.MCOptions.OutputAsmVariant.value_or(MAI.getAssemblerDialect()),
MAI, MII, MRI);
for (StringRef Opt : Options.MCOptions.InstPrinterOptions)
if (!InstPrinter->applyTargetSpecificCLOption(Opt))
for (StringRef Opt : Options.MCOptions.InstPrinterOptions) {
if (!InstPrinter->applyTargetSpecificCLOption(Opt)) {
delete InstPrinter;
return createStringError("invalid InstPrinter option '" + Opt + "'");
}
}
// Create a code emitter if asked to show the encoding.
std::unique_ptr<MCCodeEmitter> MCE;