Skip to content

Commit 5a4f08d

Browse files
committed
small tweaks to make it work in otool
1 parent f94b3c7 commit 5a4f08d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

llvm/lib/MC/MCDisassembler/Disassembler.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,12 @@ size_t LLVMDisasmInstruction(LLVMDisasmContextRef DCR, uint8_t *Bytes,
277277
SmallVector<char, 64> InsnStr;
278278
raw_svector_ostream OS(InsnStr);
279279
formatted_raw_ostream FormattedOS(OS);
280+
281+
if (DC->getOptions() & LLVMDisassembler_Option_Color) {
282+
FormattedOS.enable_colors(true);
283+
IP->setUseColor(true);
284+
}
285+
280286
IP->printInst(&Inst, PC, AnnotationsStr, *DC->getSubtargetInfo(),
281287
FormattedOS);
282288

@@ -345,8 +351,6 @@ int LLVMSetDisasmOptions(LLVMDisasmContextRef DCR, uint64_t Options){
345351
}
346352
if (Options & LLVMDisassembler_Option_Color) {
347353
LLVMDisasmContext *DC = static_cast<LLVMDisasmContext *>(DCR);
348-
MCInstPrinter *IP = DC->getIP();
349-
IP->setUseColor(true);
350354
DC->addOptions(LLVMDisassembler_Option_Color);
351355
Options &= ~LLVMDisassembler_Option_Color;
352356
}

0 commit comments

Comments
 (0)