Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 10 additions & 0 deletions lldb/unittests/Symbol/TestTypeSystemClang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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, nullptr, "minus_one", -1, 8);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit:

Suggested change
auto *enum_decl = m_ast->AddEnumerationValueToEnumerationType(
enum_type, nullptr, "minus_one", -1, 8);
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");
Expand Down
Loading