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

Michael Buch via lldb-commits lldb-commits at lists.llvm.org
Thu Jan 30 10:28:22 PST 2025


================
@@ -2367,11 +2369,36 @@ size_t DWARFASTParserClang::ParseChildEnumerators(
     }
 
     if (name && name[0] && got_value) {
-      m_ast.AddEnumerationValueToEnumerationType(
+      auto ECD = m_ast.AddEnumerationValueToEnumerationType(
----------------
Michael137 wrote:

I do think you can move the iteration into a helper function on clang ASTContext. It would look something like this:
```
// In ASTContext class
template<typename RangeT>                                                  
bool computeEnumBits(unsigned &NumNegativeBits, unsigned &NumPositiveBits, 
                     RangeT Elements);
```
Then in `SemaDecl.cpp` you would call it as follows:
```
unsigned NumNegativeBits;                                                                            
unsigned NumPositiveBits;                                                                            
bool MembersRepresentableByInt =
    Context.computeEnumBits(NumNegativeBits, NumPositiveBits, Elements);
```
And in LLDB in `CompleteTagDeclarationDefinition`, you would call it like so:
```
ast.computeEnumBits(NumNegativeBits, NumPositiveBits, enum_decl->enumerators());
                                                                                
enum_decl->completeDefinition(enum_decl->getIntegerType(),                      
                              promotion_qual_type, NumPositiveBits,             
                              NumNegativeBits);                                 
```

Wdyt? And please do the Clang-side changes in a separate NFC PR

https://github.com/llvm/llvm-project/pull/115005


More information about the lldb-commits mailing list