[clang] [lldb] [lldb] Analyze enum promotion type during parsing (PR #115005)

2024-11-05 Thread Ilia Kuklin via cfe-commits
https://github.com/kuilpd created https://github.com/llvm/llvm-project/pull/115005 The information about an enum's best promotion type is discarded after compilation and is not present in debug info. This patch repeats the same analysis of each enum value as in the front-end to determine the b

[clang] [lldb] [lldb] Analyze enum promotion type during parsing (PR #115005)

2024-11-05 Thread Ilia Kuklin via cfe-commits
kuilpd wrote: My thought process for this patch: https://github.com/llvm/llvm-project/issues/86989#issuecomment-2438116468 https://github.com/llvm/llvm-project/pull/115005 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/

[clang] [lldb] [lldb] Analyze enum promotion type during parsing (PR #115005)

2024-11-05 Thread Ilia Kuklin via cfe-commits
https://github.com/kuilpd updated https://github.com/llvm/llvm-project/pull/115005 >From 5290832b802d98b9d293b6910c0837911ec490c4 Mon Sep 17 00:00:00 2001 From: Ilia Kuklin Date: Mon, 4 Nov 2024 14:33:45 +0500 Subject: [PATCH 1/4] [lldb] Analyze enum promotion type during parsing --- clang/in

[clang] [lldb] [lldb] Analyze enum promotion type during parsing (PR #115005)

2024-11-05 Thread Ilia Kuklin via cfe-commits
https://github.com/kuilpd updated https://github.com/llvm/llvm-project/pull/115005 >From 5290832b802d98b9d293b6910c0837911ec490c4 Mon Sep 17 00:00:00 2001 From: Ilia Kuklin Date: Mon, 4 Nov 2024 14:33:45 +0500 Subject: [PATCH 1/4] [lldb] Analyze enum promotion type during parsing --- clang/in

[clang] [lldb] [lldb] Analyze enum promotion type during parsing (PR #115005)

2024-11-05 Thread Ilia Kuklin via cfe-commits
kuilpd wrote: > Not that this shouldn't be fixed, just weighing of the amount of complexity > added here versus the benefit. I don't really know how useful it is in general to know the actual promotion type of the enum, I guess only for using enum values in expressions without explicit castin

[clang] [lldb] [lldb] Analyze enum promotion type during parsing (PR #115005)

2024-11-14 Thread Ilia Kuklin via cfe-commits
kuilpd wrote: Ping https://github.com/llvm/llvm-project/pull/115005 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [lldb] [lldb] Analyze enum promotion type during parsing (PR #115005)

2024-12-05 Thread Ilia Kuklin via cfe-commits
kuilpd wrote: So, is this patch worth pursuing or is it too much code for a too specific use case? https://github.com/llvm/llvm-project/pull/115005 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo

[clang] [clang][Sema] Move computing enum width and type to a separate function (PR #120965)

2024-12-24 Thread Ilia Kuklin via cfe-commits
@@ -20008,6 +20008,87 @@ bool Sema::IsValueInFlagEnum(const EnumDecl *ED, const llvm::APInt &Val, return !(FlagMask & Val) || (AllowMask && !(FlagMask & ~Val)); } +bool Sema::ComputeBestEnumProperties(ASTContext &Context, EnumDecl *Enum, +

[clang] [clang][Sema] Move computing enum bits into a separate function (PR #126096)

2025-02-06 Thread Ilia Kuklin via cfe-commits
kuilpd wrote: > > This is just moving stuff around so that seems fine. Though, I wonder, > > could we just pass e.g. an `ArrayRef` to `computeEnumBits()`? The > > LLDB pr you linked seems to have an `SmallVector`, so > > that should be possible (I think it does require a `reinterpret_cast` fro

[clang] [clang][Sema] Move computing enum bits into a separate function (PR #126096)

2025-02-06 Thread Ilia Kuklin via cfe-commits
kuilpd wrote: The code needs to be called from LLDB as well (#115005), so this is an NFC patch to move it to `ASTContext.h`, plus this cleans up a bit the code in `Sema::ActOnEnumBody`. `isRepresentableIntegerValue` also had to be moved to `ASTContext.h`, but since it requires `ASTContext` as

[clang] [clang][Sema] Move computing enum bits into a separate function (PR #126096)

2025-02-06 Thread Ilia Kuklin via cfe-commits
https://github.com/kuilpd created https://github.com/llvm/llvm-project/pull/126096 Move the code that computes `NumNegativeBits` and `NumPositiveBits` for an enum to a separate function in `ASTContext.h` >From bf58b01066421af318a7a69a3ac1632e69b29301 Mon Sep 17 00:00:00 2001 From: Ilia Kuklin

[clang] [clang][Sema] Move computing enum bits into a separate function (PR #126096)

2025-02-06 Thread Ilia Kuklin via cfe-commits
https://github.com/kuilpd edited https://github.com/llvm/llvm-project/pull/126096 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][Sema] Move computing enum bits into a separate function (PR #126096)

2025-02-11 Thread Ilia Kuklin via cfe-commits
https://github.com/kuilpd closed https://github.com/llvm/llvm-project/pull/126096 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [lldb] [lldb] Analyze enum promotion type during parsing (PR #115005)

2025-01-30 Thread Ilia Kuklin via cfe-commits
https://github.com/kuilpd updated https://github.com/llvm/llvm-project/pull/115005 >From 4d797371598960baf7729d05590aa1a8c7077694 Mon Sep 17 00:00:00 2001 From: Ilia Kuklin Date: Mon, 4 Nov 2024 14:33:45 +0500 Subject: [PATCH 01/10] [lldb] Analyze enum promotion type during parsing --- clang/

[clang] [lldb] [lldb] Analyze enum promotion type during parsing (PR #115005)

2025-01-30 Thread Ilia Kuklin via cfe-commits
@@ -2367,11 +2369,38 @@ size_t DWARFASTParserClang::ParseChildEnumerators( } if (name && name[0] && got_value) { - m_ast.AddEnumerationValueToEnumerationType( + auto ECD = m_ast.AddEnumerationValueToEnumerationType( clang_type, decl, name, enum_val

[clang] [lldb] [lldb] Analyze enum promotion type during parsing (PR #115005)

2025-01-31 Thread Ilia Kuklin via cfe-commits
@@ -2367,11 +2369,36 @@ size_t DWARFASTParserClang::ParseChildEnumerators( } if (name && name[0] && got_value) { - m_ast.AddEnumerationValueToEnumerationType( + auto ECD = m_ast.AddEnumerationValueToEnumerationType( kuilpd wrote: Alright, wi

[clang] [lldb] [lldb] Analyze enum promotion type during parsing (PR #115005)

2025-01-31 Thread Ilia Kuklin via cfe-commits
@@ -2367,11 +2369,36 @@ size_t DWARFASTParserClang::ParseChildEnumerators( } if (name && name[0] && got_value) { - m_ast.AddEnumerationValueToEnumerationType( + auto ECD = m_ast.AddEnumerationValueToEnumerationType( kuilpd wrote: It's used i

[clang] [lldb] [lldb] Analyze enum promotion type during parsing (PR #115005)

2025-01-31 Thread Ilia Kuklin via cfe-commits
https://github.com/kuilpd updated https://github.com/llvm/llvm-project/pull/115005 >From 4d797371598960baf7729d05590aa1a8c7077694 Mon Sep 17 00:00:00 2001 From: Ilia Kuklin Date: Mon, 4 Nov 2024 14:33:45 +0500 Subject: [PATCH 01/12] [lldb] Analyze enum promotion type during parsing --- clang/

[clang] [lldb] [lldb] Analyze enum promotion type during parsing (PR #115005)

2025-01-31 Thread Ilia Kuklin via cfe-commits
@@ -2367,11 +2369,36 @@ size_t DWARFASTParserClang::ParseChildEnumerators( } if (name && name[0] && got_value) { - m_ast.AddEnumerationValueToEnumerationType( + auto ECD = m_ast.AddEnumerationValueToEnumerationType( kuilpd wrote: Well... I t

[clang] [lldb] [lldb] Analyze enum promotion type during parsing (PR #115005)

2025-01-31 Thread Ilia Kuklin via cfe-commits
@@ -2367,11 +2369,36 @@ size_t DWARFASTParserClang::ParseChildEnumerators( } if (name && name[0] && got_value) { - m_ast.AddEnumerationValueToEnumerationType( + auto ECD = m_ast.AddEnumerationValueToEnumerationType( kuilpd wrote: > > Iterati

[clang] [lldb] [lldb] Analyze enum promotion type during parsing (PR #115005)

2025-01-31 Thread Ilia Kuklin via cfe-commits
@@ -2367,11 +2369,36 @@ size_t DWARFASTParserClang::ParseChildEnumerators( } if (name && name[0] && got_value) { - m_ast.AddEnumerationValueToEnumerationType( + auto ECD = m_ast.AddEnumerationValueToEnumerationType( kuilpd wrote: Yes, but I

[clang] [lldb] [lldb] Analyze enum promotion type during parsing (PR #115005)

2024-12-20 Thread Ilia Kuklin via cfe-commits
https://github.com/kuilpd updated https://github.com/llvm/llvm-project/pull/115005 >From 5290832b802d98b9d293b6910c0837911ec490c4 Mon Sep 17 00:00:00 2001 From: Ilia Kuklin Date: Mon, 4 Nov 2024 14:33:45 +0500 Subject: [PATCH 1/6] [lldb] Analyze enum promotion type during parsing --- clang/in

[clang] [lldb] [lldb] Analyze enum promotion type during parsing (PR #115005)

2024-12-20 Thread Ilia Kuklin via cfe-commits
@@ -2299,11 +2301,103 @@ size_t DWARFASTParserClang::ParseChildEnumerators( } if (name && name[0] && got_value) { - m_ast.AddEnumerationValueToEnumerationType( + auto ECD = m_ast.AddEnumerationValueToEnumerationType( clang_type, decl, name, enum_va

[clang] [lldb] [lldb] Analyze enum promotion type during parsing (PR #115005)

2024-12-20 Thread Ilia Kuklin via cfe-commits
@@ -8544,7 +8524,8 @@ clang::EnumConstantDecl *TypeSystemClang::AddEnumerationValueToEnumerationType( bool is_signed = false; underlying_type.IsIntegerType(is_signed); - llvm::APSInt value(enum_value_bit_size, is_signed); + // APSInt constructor's sign argument is isUns

[clang] [lldb] [lldb] Analyze enum promotion type during parsing (PR #115005)

2025-01-27 Thread Ilia Kuklin via cfe-commits
https://github.com/kuilpd updated https://github.com/llvm/llvm-project/pull/115005 >From 4d797371598960baf7729d05590aa1a8c7077694 Mon Sep 17 00:00:00 2001 From: Ilia Kuklin Date: Mon, 4 Nov 2024 14:33:45 +0500 Subject: [PATCH 1/6] [lldb] Analyze enum promotion type during parsing --- clang/in

[clang] [lldb] [lldb] Analyze enum promotion type during parsing (PR #115005)

2025-01-27 Thread Ilia Kuklin via cfe-commits
@@ -2367,11 +2369,38 @@ size_t DWARFASTParserClang::ParseChildEnumerators( } if (name && name[0] && got_value) { - m_ast.AddEnumerationValueToEnumerationType( + auto ECD = m_ast.AddEnumerationValueToEnumerationType( clang_type, decl, name, enum_val

[clang] [lldb] [lldb] Analyze enum promotion type during parsing (PR #115005)

2025-01-27 Thread Ilia Kuklin via cfe-commits
https://github.com/kuilpd edited https://github.com/llvm/llvm-project/pull/115005 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [lldb] [lldb] Analyze enum promotion type during parsing (PR #115005)

2025-01-27 Thread Ilia Kuklin via cfe-commits
https://github.com/kuilpd updated https://github.com/llvm/llvm-project/pull/115005 >From 4d797371598960baf7729d05590aa1a8c7077694 Mon Sep 17 00:00:00 2001 From: Ilia Kuklin Date: Mon, 4 Nov 2024 14:33:45 +0500 Subject: [PATCH 1/7] [lldb] Analyze enum promotion type during parsing --- clang/in

[clang] [lldb] [lldb] Analyze enum promotion type during parsing (PR #115005)

2025-01-27 Thread Ilia Kuklin via cfe-commits
@@ -2367,11 +2369,38 @@ size_t DWARFASTParserClang::ParseChildEnumerators( } if (name && name[0] && got_value) { - m_ast.AddEnumerationValueToEnumerationType( + auto ECD = m_ast.AddEnumerationValueToEnumerationType( clang_type, decl, name, enum_val

[clang] [lldb] [lldb] Analyze enum promotion type during parsing (PR #115005)

2025-01-27 Thread Ilia Kuklin via cfe-commits
kuilpd wrote: @Michael137 Reused the code I merged in #120965 to get the best promotion type. https://github.com/llvm/llvm-project/pull/115005 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-

[clang] [lldb] [lldb] Analyze enum promotion type during parsing (PR #115005)

2025-01-27 Thread Ilia Kuklin via cfe-commits
https://github.com/kuilpd updated https://github.com/llvm/llvm-project/pull/115005 >From 4d797371598960baf7729d05590aa1a8c7077694 Mon Sep 17 00:00:00 2001 From: Ilia Kuklin Date: Mon, 4 Nov 2024 14:33:45 +0500 Subject: [PATCH 1/8] [lldb] Analyze enum promotion type during parsing --- clang/in

[clang] [lldb] [lldb] Analyze enum promotion type during parsing (PR #115005)

2025-01-27 Thread Ilia Kuklin via cfe-commits
@@ -3903,6 +3903,7 @@ class EnumDecl : public TagDecl { void setInstantiationOfMemberEnum(ASTContext &C, EnumDecl *ED, TemplateSpecializationKind TSK); +public: kuilpd wrote: I left this in so that that I could simply do

[clang] [clang][Sema] Move computing enum width and type to a separate function (PR #120965)

2025-01-14 Thread Ilia Kuklin via cfe-commits
https://github.com/kuilpd updated https://github.com/llvm/llvm-project/pull/120965 >From ab8dcaef120233d0145508aaa4bf45eec22cadf1 Mon Sep 17 00:00:00 2001 From: Ilia Kuklin Date: Mon, 23 Dec 2024 17:49:32 +0500 Subject: [PATCH 1/4] [clang][Sema] Move calculating enum width and type to a separa

[clang] [clang][Sema] Move computing enum width and type to a separate function (PR #120965)

2025-01-14 Thread Ilia Kuklin via cfe-commits
kuilpd wrote: Tried moving the code to `EnumDecl`, but it didn't work as well as I thought, so moved it to `ASTContext` after all. Don't really know where exactly to place it inside `ASTContext.h`, though. https://github.com/llvm/llvm-project/pull/120965 ___

[clang] [clang][Sema] Move computing enum width and type to a separate function (PR #120965)

2024-12-23 Thread Ilia Kuklin via cfe-commits
kuilpd wrote: As of now LLDB doesn't calculate enum's best promotion type when reading it from DWARF info. This change would allow to reuse the code from Sema without copying it to LLDB, which I'm working on in #115005 This function however has too many arguments right now, and also needs to

[clang] [clang][Sema] Move computing enum width and type to a separate function (PR #120965)

2024-12-23 Thread Ilia Kuklin via cfe-commits
https://github.com/kuilpd created https://github.com/llvm/llvm-project/pull/120965 Move the code that calculates BestWidth, BestType and BestPromotionType for an enum to a separate function which can be called from outside of Sema. >From ab8dcaef120233d0145508aaa4bf45eec22cadf1 Mon Sep 17 00:

[clang] [clang][Sema] Move computing enum width and type to a separate function (PR #120965)

2024-12-23 Thread Ilia Kuklin via cfe-commits
https://github.com/kuilpd updated https://github.com/llvm/llvm-project/pull/120965 >From ab8dcaef120233d0145508aaa4bf45eec22cadf1 Mon Sep 17 00:00:00 2001 From: Ilia Kuklin Date: Mon, 23 Dec 2024 17:49:32 +0500 Subject: [PATCH 1/2] [clang][Sema] Move calculating enum width and type to a separa

[clang] [clang][Sema] Move computing enum width and type to a separate function (PR #120965)

2024-12-23 Thread Ilia Kuklin via cfe-commits
https://github.com/kuilpd updated https://github.com/llvm/llvm-project/pull/120965 >From ab8dcaef120233d0145508aaa4bf45eec22cadf1 Mon Sep 17 00:00:00 2001 From: Ilia Kuklin Date: Mon, 23 Dec 2024 17:49:32 +0500 Subject: [PATCH 1/2] [clang][Sema] Move calculating enum width and type to a separa

[clang] [clang][Sema] Move computing enum width and type to a separate function (PR #120965)

2024-12-23 Thread Ilia Kuklin via cfe-commits
@@ -20008,6 +20008,87 @@ bool Sema::IsValueInFlagEnum(const EnumDecl *ED, const llvm::APInt &Val, return !(FlagMask & Val) || (AllowMask && !(FlagMask & ~Val)); } +bool Sema::ComputeBestEnumProperties(ASTContext &Context, EnumDecl *Enum, +

[clang] [clang][Sema] Move computing enum width and type to a separate function (PR #120965)

2025-01-14 Thread Ilia Kuklin via cfe-commits
https://github.com/kuilpd updated https://github.com/llvm/llvm-project/pull/120965 >From ab8dcaef120233d0145508aaa4bf45eec22cadf1 Mon Sep 17 00:00:00 2001 From: Ilia Kuklin Date: Mon, 23 Dec 2024 17:49:32 +0500 Subject: [PATCH 1/5] [clang][Sema] Move calculating enum width and type to a separa

[clang] [clang][Sema] Move computing enum width and type to a separate function (PR #120965)

2025-01-16 Thread Ilia Kuklin via cfe-commits
kuilpd wrote: Updated code, fixed nits. @Fznamznon Does this look good to you too? https://github.com/llvm/llvm-project/pull/120965 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][Sema] Move computing enum width and type to a separate function (PR #120965)

2025-01-10 Thread Ilia Kuklin via cfe-commits
@@ -20008,6 +20008,87 @@ bool Sema::IsValueInFlagEnum(const EnumDecl *ED, const llvm::APInt &Val, return !(FlagMask & Val) || (AllowMask && !(FlagMask & ~Val)); } +bool Sema::ComputeBestEnumProperties(ASTContext &Context, EnumDecl *Enum, +

[clang] [clang][Sema] Move computing best enum types to a separate function (PR #120965)

2025-01-17 Thread Ilia Kuklin via cfe-commits
https://github.com/kuilpd closed https://github.com/llvm/llvm-project/pull/120965 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][Sema] Move computing best enum types to a separate function (PR #120965)

2025-01-17 Thread Ilia Kuklin via cfe-commits
https://github.com/kuilpd edited https://github.com/llvm/llvm-project/pull/120965 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][Sema] Move computing enum width and type to a separate function (PR #120965)

2025-01-17 Thread Ilia Kuklin via cfe-commits
https://github.com/kuilpd edited https://github.com/llvm/llvm-project/pull/120965 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [lldb] [lldb] Analyze enum promotion type during parsing (PR #115005)

2025-02-12 Thread Ilia Kuklin via cfe-commits
https://github.com/kuilpd updated https://github.com/llvm/llvm-project/pull/115005 >From dd65babbf4c73a0b2fc2e4aa47a9a346bd5a9adf Mon Sep 17 00:00:00 2001 From: Ilia Kuklin Date: Mon, 4 Nov 2024 14:33:45 +0500 Subject: [PATCH 01/14] [lldb] Analyze enum promotion type during parsing --- clang/

[clang] [lldb] [lldb] Analyze enum promotion type during parsing (PR #115005)

2025-02-13 Thread Ilia Kuklin via cfe-commits
https://github.com/kuilpd updated https://github.com/llvm/llvm-project/pull/115005 >From dd65babbf4c73a0b2fc2e4aa47a9a346bd5a9adf Mon Sep 17 00:00:00 2001 From: Ilia Kuklin Date: Mon, 4 Nov 2024 14:33:45 +0500 Subject: [PATCH 01/15] [lldb] Analyze enum promotion type during parsing --- clang/

[clang] [lldb] [lldb] Analyze enum promotion type during parsing (PR #115005)

2025-02-13 Thread Ilia Kuklin via cfe-commits
kuilpd wrote: @Michael137 Thank you for seeing this through! https://github.com/llvm/llvm-project/pull/115005 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [lldb] [lldb] Analyze enum promotion type during parsing (PR #115005)

2025-02-08 Thread Ilia Kuklin via cfe-commits
https://github.com/kuilpd updated https://github.com/llvm/llvm-project/pull/115005 >From 4d797371598960baf7729d05590aa1a8c7077694 Mon Sep 17 00:00:00 2001 From: Ilia Kuklin Date: Mon, 4 Nov 2024 14:33:45 +0500 Subject: [PATCH 01/13] [lldb] Analyze enum promotion type during parsing --- clang/

[clang] [lldb] [lldb] Analyze enum promotion type during parsing (PR #115005)

2025-02-08 Thread Ilia Kuklin via cfe-commits
kuilpd wrote: @Michael137 Changed the first argument of `computeEnumBits` to an `ArrayRef` to avoid the template and so it can be still seamlessly used from Sema. On LLDB side, I had to create a `SmallVector` and put enum constants there at the point of their creation (`AddEnumerationValueToEn

[clang] [lldb] [lldb] Analyze enum promotion type during parsing (PR #115005)

2025-02-13 Thread Ilia Kuklin via cfe-commits
https://github.com/kuilpd closed https://github.com/llvm/llvm-project/pull/115005 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [lldb] [lldb] Analyze enum promotion type during parsing (PR #115005)

2025-02-13 Thread Ilia Kuklin via cfe-commits
kuilpd wrote: > But only for dSYMs. Looking at the `dSYM`, none of the enums are actually > preserved in the debug-info. You have to actually use the enum types in > source to get dsymutil to preserve them. I'll fix it Ah, I see. Thank you for handling this! https://github.com/llvm/llvm-proje