[Lldb-commits] [lldb] [lldb] Fix feature format in DisassemblerLLVMC constructor (PR #184355)
Georgiy Samoylov via lldb-commits
lldb-commits at lists.llvm.org
Tue Mar 3 06:58:52 PST 2026
https://github.com/sga-sc created https://github.com/llvm/llvm-project/pull/184355
At this moment feature string in `DisassemblerLLVMC` constructor for example for RISC-V architecture can be something like `+m,+f,+d,+a,+m,`. Last comma at this string is redundant judging by this comment https://github.com/llvm/llvm-project/blob/c9d065abc15846deb95a23fb0b3e1855d3d26314/llvm/include/llvm/TargetParser/SubtargetFeature.h#L167-L174
This patch is also needed for successful test passing in https://github.com/llvm/llvm-project/pull/180943
>From 8501306a6f482387458aad224cf45ea348d4c1ff Mon Sep 17 00:00:00 2001
From: Georgiy Samoylov <g.samoylov at syntacore.com>
Date: Tue, 3 Mar 2026 16:11:01 +0300
Subject: [PATCH] [lldb] Delete last comma from features
---
.../Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp b/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
index 6384b5e1bb57c..36329e40ab8a2 100644
--- a/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
+++ b/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
@@ -1617,6 +1617,10 @@ DisassemblerLLVMC::DisassemblerLLVMC(const ArchSpec &arch,
}
}
+ // We should delete the last comma from string
+ if (!features_str.empty() && features_str.back() == ',')
+ features_str.pop_back();
+
// We use m_disasm_up.get() to tell whether we are valid or not, so if this
// isn't good for some reason, we won't be valid and FindPlugin will fail and
// we won't get used.
@@ -1638,9 +1642,9 @@ DisassemblerLLVMC::DisassemblerLLVMC(const ArchSpec &arch,
/* Create alternate disassembler for MIPS16 and microMIPS */
uint32_t arch_flags = arch.GetFlags();
if (arch_flags & ArchSpec::eMIPSAse_mips16)
- features_str += "+mips16,";
+ features_str += ",+mips16";
else if (arch_flags & ArchSpec::eMIPSAse_micromips)
- features_str += "+micromips,";
+ features_str += ",+micromips";
m_alternate_disasm_up = MCDisasmInstance::Create(
triple_str, cpu, features_str.c_str(), flavor, *this);
More information about the lldb-commits
mailing list