Skip to content

Commit 92f439c

Browse files
authored
[lldb] Negate is_signed variable for argument isUnsigned in TypeSystemClang.cpp (#120794)
1 parent 5f98dd5 commit 92f439c

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8534,7 +8534,7 @@ clang::EnumConstantDecl *TypeSystemClang::AddEnumerationValueToEnumerationType(
85348534
bool is_signed = false;
85358535
underlying_type.IsIntegerType(is_signed);
85368536

8537-
llvm::APSInt value(enum_value_bit_size, is_signed);
8537+
llvm::APSInt value(enum_value_bit_size, !is_signed);
85388538
value = enum_value;
85398539

85408540
return AddEnumerationValueToEnumerationType(enum_type, decl, name, value);

lldb/unittests/Symbol/TestTypeSystemClang.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,16 @@ TEST_F(TestTypeSystemClang, TestGetEnumIntegerTypeBasicTypes) {
313313
}
314314
}
315315

316+
TEST_F(TestTypeSystemClang, TestEnumerationValueSign) {
317+
CompilerType enum_type = m_ast->CreateEnumerationType(
318+
"my_enum_signed", m_ast->GetTranslationUnitDecl(),
319+
OptionalClangModuleID(), Declaration(),
320+
m_ast->GetBasicType(lldb::eBasicTypeSignedChar), false);
321+
auto *enum_decl = m_ast->AddEnumerationValueToEnumerationType(
322+
enum_type, Declaration(), "minus_one", -1, 8);
323+
EXPECT_TRUE(enum_decl->getInitVal().isSigned());
324+
}
325+
316326
TEST_F(TestTypeSystemClang, TestOwningModule) {
317327
auto holder =
318328
std::make_unique<clang_utils::TypeSystemClangHolder>("module_ast");

0 commit comments

Comments
 (0)