Skip to content

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

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 3 commits into from
Dec 23, 2024

Conversation

kuilpd
Copy link
Contributor

@kuilpd kuilpd commented Dec 20, 2024

No description provided.

@kuilpd kuilpd added the lldb label Dec 20, 2024
@kuilpd kuilpd requested a review from Michael137 December 20, 2024 21:16
@kuilpd kuilpd requested a review from JDevlieghere as a code owner December 20, 2024 21:16
@llvmbot
Copy link
Member

llvmbot commented Dec 20, 2024

@llvm/pr-subscribers-lldb

Author: Ilia Kuklin (kuilpd)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/120794.diff

1 Files Affected:

  • (modified) lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp (+1-1)
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 3ec25a2e8aa2df..06c04c992efc09 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -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);

@kuilpd
Copy link
Contributor Author

kuilpd commented Dec 20, 2024

This change doesn't really affect anything in lldb yet, but will be used and tested afterwards in #115005

Copy link
Member

@Michael137 Michael137 left a comment

Choose a reason for hiding this comment

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

LGTM

Can we add a test for this in lldb/unittests/Symbol/TestTypeSystemClang.cpp? We could call this API and then use EnumConstantDecl::getInitVal to retrieve the APSInt and make sure it's unsigned

Comment on lines 321 to 322
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);

Copy link
Member

@Michael137 Michael137 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks! (one minor nit in the test)

@kuilpd kuilpd merged commit 92f439c into llvm:main Dec 23, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants