[lldb] Negate is_signed variable for argument isUnsigned in TypeSystemClang.cpp (#120794)

This commit is contained in:
Ilia Kuklin 2024-12-23 18:40:09 +05:00 committed by GitHub
parent 5f98dd5dd5
commit 92f439c4b7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 1 deletions

View File

@ -8534,7 +8534,7 @@ clang::EnumConstantDecl *TypeSystemClang::AddEnumerationValueToEnumerationType(
bool is_signed = false;
underlying_type.IsIntegerType(is_signed);
llvm::APSInt value(enum_value_bit_size, is_signed);
llvm::APSInt value(enum_value_bit_size, !is_signed);
value = enum_value;
return AddEnumerationValueToEnumerationType(enum_type, decl, name, value);

View File

@ -313,6 +313,16 @@ TEST_F(TestTypeSystemClang, TestGetEnumIntegerTypeBasicTypes) {
}
}
TEST_F(TestTypeSystemClang, TestEnumerationValueSign) {
CompilerType enum_type = m_ast->CreateEnumerationType(
"my_enum_signed", m_ast->GetTranslationUnitDecl(),
OptionalClangModuleID(), Declaration(),
m_ast->GetBasicType(lldb::eBasicTypeSignedChar), false);
auto *enum_decl = m_ast->AddEnumerationValueToEnumerationType(
enum_type, Declaration(), "minus_one", -1, 8);
EXPECT_TRUE(enum_decl->getInitVal().isSigned());
}
TEST_F(TestTypeSystemClang, TestOwningModule) {
auto holder =
std::make_unique<clang_utils::TypeSystemClangHolder>("module_ast");