[Lldb-commits] [lldb] r317563 - Support scoped enums in the DWARF AST parser

Tamas Berghammer via lldb-commits lldb-commits at lists.llvm.org
Tue Nov 7 02:39:22 PST 2017


Author: tberghammer
Date: Tue Nov  7 02:39:22 2017
New Revision: 317563

URL: http://llvm.org/viewvc/llvm-project?rev=317563&view=rev
Log:
Support scoped enums in the DWARF AST parser

Subscribers: JDevlieghere

Differential Revision: https://reviews.llvm.org/D39545

Modified:
    lldb/trunk/include/lldb/Symbol/ClangASTContext.h
    lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/enum_types/TestCPP11EnumTypes.py
    lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
    lldb/trunk/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
    lldb/trunk/source/Symbol/ClangASTContext.cpp

Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=317563&r1=317562&r2=317563&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original)
+++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Tue Nov  7 02:39:22 2017
@@ -397,7 +397,8 @@ public:
   CompilerType CreateEnumerationType(const char *name,
                                      clang::DeclContext *decl_ctx,
                                      const Declaration &decl,
-                                     const CompilerType &integer_qual_type);
+                                     const CompilerType &integer_qual_type,
+                                     bool is_scoped);
 
   //------------------------------------------------------------------
   // Integer type functions

Modified: lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/enum_types/TestCPP11EnumTypes.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/enum_types/TestCPP11EnumTypes.py?rev=317563&r1=317562&r2=317563&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/enum_types/TestCPP11EnumTypes.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/enum_types/TestCPP11EnumTypes.py Tue Nov  7 02:39:22 2017
@@ -99,8 +99,8 @@ class CPP11EnumTypesTestCase(TestBase):
         # Look up information about the 'DayType' enum type.
         # Check for correct display.
         self.expect("image lookup -t DayType", DATA_TYPES_DISPLAYED_CORRECTLY,
-                    substrs=['enum DayType {',
-                             'Monday',
+                    patterns=['enum( struct| class) DayType {'],
+                    substrs=['Monday',
                              'Tuesday',
                              'Wednesday',
                              'Thursday',

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp?rev=317563&r1=317562&r2=317563&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp Tue Nov  7 02:39:22 2017
@@ -927,6 +927,7 @@ TypeSP DWARFASTParserClang::ParseTypeFro
         // Set a bit that lets us know that we are currently parsing this
         dwarf->GetDIEToType()[die.GetDIE()] = DIE_IS_BEING_PARSED;
 
+        bool is_scoped = false;
         DWARFFormValue encoding_form;
 
         const size_t num_attributes = die.GetAttributes(attributes);
@@ -963,6 +964,9 @@ TypeSP DWARFASTParserClang::ParseTypeFro
               case DW_AT_declaration:
                 is_forward_declaration = form_value.Boolean();
                 break;
+              case DW_AT_enum_class:
+                is_scoped = form_value.Boolean();
+                break;
               case DW_AT_allocated:
               case DW_AT_associated:
               case DW_AT_bit_stride:
@@ -1052,7 +1056,7 @@ TypeSP DWARFASTParserClang::ParseTypeFro
 
             clang_type = m_ast.CreateEnumerationType(
                 type_name_cstr, GetClangDeclContextContainingDIE(die, nullptr),
-                decl, enumerator_clang_type);
+                decl, enumerator_clang_type, is_scoped);
           } else {
             enumerator_clang_type =
                 m_ast.GetEnumerationIntegerType(clang_type.GetOpaqueQualType());

Modified: lldb/trunk/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp?rev=317563&r1=317562&r2=317563&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp Tue Nov  7 02:39:22 2017
@@ -109,7 +109,7 @@ lldb::TypeSP PDBASTParser::CreateLLDBTyp
         m_ast.GetBuiltinTypeForEncodingAndBitSize(encoding, bytes * 8);
 
     CompilerType ast_enum = m_ast.CreateEnumerationType(
-        name.c_str(), tu_decl_ctx, decl, builtin_type);
+        name.c_str(), tu_decl_ctx, decl, builtin_type, false);
     auto enum_values = enum_type->findAllChildren<PDBSymbolData>();
     while (auto enum_value = enum_values->getNext()) {
       if (enum_value->getDataKind() != PDB_DataKind::Constant)

Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=317563&r1=317562&r2=317563&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/ClangASTContext.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp Tue Nov  7 02:39:22 2017
@@ -2169,20 +2169,20 @@ CompilerType ClangASTContext::GetOrCreat
 CompilerType
 ClangASTContext::CreateEnumerationType(const char *name, DeclContext *decl_ctx,
                                        const Declaration &decl,
-                                       const CompilerType &integer_clang_type) {
+                                       const CompilerType &integer_clang_type,
+                                       bool is_scoped) {
   // TODO: Do something intelligent with the Declaration object passed in
   // like maybe filling in the SourceLocation with it...
   ASTContext *ast = getASTContext();
 
   // TODO: ask about these...
-  //    const bool IsScoped = false;
   //    const bool IsFixed = false;
 
   EnumDecl *enum_decl = EnumDecl::Create(
       *ast, decl_ctx, SourceLocation(), SourceLocation(),
       name && name[0] ? &ast->Idents.get(name) : nullptr, nullptr,
-      false,  // IsScoped
-      false,  // IsScopedUsingClassTag
+      is_scoped,
+      true,   // IsScopedUsingClassTag
       false); // IsFixed
 
   if (enum_decl) {




More information about the lldb-commits mailing list