Skip to content

[lldb][TypeSystemClang] Pass around enum value as uint64_t #125244

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -2329,8 +2329,7 @@ size_t DWARFASTParserClang::ParseChildEnumerators(
continue;

const char *name = nullptr;
bool got_value = false;
int64_t enum_value = 0;
std::optional<uint64_t> enum_value;
Declaration decl;

for (size_t i = 0; i < attributes.Size(); ++i) {
Expand All @@ -2339,7 +2338,6 @@ size_t DWARFASTParserClang::ParseChildEnumerators(
if (attributes.ExtractFormValueAtIndex(i, form_value)) {
switch (attr) {
case DW_AT_const_value:
got_value = true;
if (is_signed)
enum_value = form_value.Signed();
else
Expand Down Expand Up @@ -2368,9 +2366,9 @@ size_t DWARFASTParserClang::ParseChildEnumerators(
}
}

if (name && name[0] && got_value) {
if (name && name[0] && enum_value) {
m_ast.AddEnumerationValueToEnumerationType(
clang_type, decl, name, enum_value, enumerator_byte_size * 8);
clang_type, decl, name, *enum_value, enumerator_byte_size * 8);
++enumerators_added;
}
}
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1155,7 +1155,7 @@ bool PDBASTParser::AddEnumValue(CompilerType enum_type,
Variant v = enum_value.getValue();
std::string name =
std::string(MSVCUndecoratedNameParser::DropScope(enum_value.getName()));
int64_t raw_value;
uint64_t raw_value;
switch (v.Type) {
case PDB_VariantType::Int8:
raw_value = v.Value.Int8;
Expand Down
10 changes: 4 additions & 6 deletions lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8541,12 +8541,10 @@ clang::EnumConstantDecl *TypeSystemClang::AddEnumerationValueToEnumerationType(

clang::EnumConstantDecl *TypeSystemClang::AddEnumerationValueToEnumerationType(
const CompilerType &enum_type, const Declaration &decl, const char *name,
int64_t enum_value, uint32_t enum_value_bit_size) {
CompilerType underlying_type = GetEnumerationIntegerType(enum_type);
bool is_signed = false;
underlying_type.IsIntegerType(is_signed);

llvm::APSInt value(enum_value_bit_size, !is_signed);
uint64_t enum_value, uint32_t enum_value_bit_size) {
assert(enum_type.IsEnumerationType());
llvm::APSInt value(enum_value_bit_size,
!enum_type.IsEnumerationIntegerTypeSigned());
Copy link
Member Author

Choose a reason for hiding this comment

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

this is a drive-by cleanup

value = enum_value;

return AddEnumerationValueToEnumerationType(enum_type, decl, name, value);
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,7 @@ class TypeSystemClang : public TypeSystem {
// Modifying Enumeration types
clang::EnumConstantDecl *AddEnumerationValueToEnumerationType(
const CompilerType &enum_type, const Declaration &decl, const char *name,
int64_t enum_value, uint32_t enum_value_bit_size);
uint64_t enum_value, uint32_t enum_value_bit_size);
clang::EnumConstantDecl *AddEnumerationValueToEnumerationType(
const CompilerType &enum_type, const Declaration &decl, const char *name,
const llvm::APSInt &value);
Expand Down