Skip to content

Commit 8312433

Browse files
committed
[RISCV-LLDB] RISCV feature attribute support and allows overriding additional(default) feature #147990
Addressed review comments.
1 parent 5130289 commit 8312433

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1453,19 +1453,19 @@ void DisassemblerLLVMC::UpdateFeatureString(llvm::StringRef additional_features,
14531453
flag = flag.trim();
14541454
if (flag.empty())
14551455
continue;
1456-
// Check if disable (-c) is already present before adding default enable
1457-
// (+c), since enable (+c) takes precedence whether disable (-c) appears
1458-
// before or after in the feature string.
1456+
// By default, if both +flag and -flag are present in the feature string,
1457+
// disassembler keeps the feature enabled (+flag).
1458+
// To respect user intent, we make -flag(user) take priority over the
1459+
// default +flag coming from ELF.
1460+
bool add_flag = true;
14591461
if (flag.starts_with('+')) {
14601462
std::string disable_flag = "-" + flag.substr(1).str();
1461-
if (features.find(disable_flag) == std::string::npos) {
1462-
if (!features.empty() && flag.back() != ',') {
1463-
features = ',' + features;
1464-
}
1465-
features = flag.str() + features;
1463+
if (features.find(disable_flag) != std::string::npos) {
1464+
add_flag = false;
14661465
}
1467-
} else {
1468-
if (flag.back() != ',') {
1466+
}
1467+
if (add_flag) {
1468+
if (!features.empty()) {
14691469
features = ',' + features;
14701470
}
14711471
features = flag.str() + features;

0 commit comments

Comments
 (0)