Skip to content

Commit 2b8cc65

Browse files
committed
:createMCStreamer: delete InstPrinter on error
1 parent d1badf5 commit 2b8cc65

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

llvm/lib/CodeGen/CodeGenTargetMachineImpl.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,12 @@ CodeGenTargetMachineImpl::createMCStreamer(raw_pwrite_stream &Out,
166166
getTargetTriple(),
167167
Options.MCOptions.OutputAsmVariant.value_or(MAI.getAssemblerDialect()),
168168
MAI, MII, MRI);
169-
for (StringRef Opt : Options.MCOptions.InstPrinterOptions)
170-
if (!InstPrinter->applyTargetSpecificCLOption(Opt))
169+
for (StringRef Opt : Options.MCOptions.InstPrinterOptions) {
170+
if (!InstPrinter->applyTargetSpecificCLOption(Opt)) {
171+
delete InstPrinter;
171172
return createStringError("invalid InstPrinter option '" + Opt + "'");
173+
}
174+
}
172175

173176
// Create a code emitter if asked to show the encoding.
174177
std::unique_ptr<MCCodeEmitter> MCE;

0 commit comments

Comments
 (0)