<div dir="ltr"><span style="font-size:12.8px">+        self.expect('frame variable f.op', DATA_TYPES_DISPLAYED_</span><span style="font-size:12.8px">CORRECTLY, substrs = ['ops *', 'f.op', '<b>0x0000000000000000</b>'])</span><br style="font-size:12.8px"><span style="font-size:12.8px">+        self.expect('frame variable *f.op', DATA_TYPES_DISPLAYED_</span><span style="font-size:12.8px">CORRECTLY, substrs = ['ops', '*f.op', '<parent is NULL>'])</span><br style="font-size:12.8px"><span style="font-size:12.8px">+        self.expect('expr f.op', DATA_TYPES_DISPLAYED_</span><span style="font-size:12.8px">CORRECTLY, substrs = ['ops *', '$', '<b>0x0000000000000000</b>'])</span><br style="font-size:12.8px"><span style="font-size:12.8px">+        self.expect('expr *f.op', DATA_TYPES_DISPLAYED_</span><span style="font-size:12.8px">CORRECTLY, substrs = ['error:'], error = True)</span><br><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">These break on 32 bit machines I think. We should probably use something like 0x0+.</span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Apr 29, 2016 at 1:48 PM, Greg Clayton via lldb-commits <span dir="ltr"><<a href="mailto:lldb-commits@lists.llvm.org" target="_blank">lldb-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: gclayton<br>
Date: Fri Apr 29 15:48:39 2016<br>
New Revision: 268098<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=268098&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=268098&view=rev</a><br>
Log:<br>
Make sure LLDB can deal with forward declarations to enums without crashing or asserting.<br>
<br>
<rdar://problem/23776428><br>
<br>
<br>
Modified:<br>
    lldb/trunk/packages/Python/lldbsuite/test/lang/c/enum_types/TestEnumTypes.py<br>
    lldb/trunk/packages/Python/lldbsuite/test/lang/c/enum_types/main.c<br>
    lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp<br>
    lldb/trunk/source/Symbol/ClangASTContext.cpp<br>
<br>
Modified: lldb/trunk/packages/Python/lldbsuite/test/lang/c/enum_types/TestEnumTypes.py<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/c/enum_types/TestEnumTypes.py?rev=268098&r1=268097&r2=268098&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/c/enum_types/TestEnumTypes.py?rev=268098&r1=268097&r2=268098&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/packages/Python/lldbsuite/test/lang/c/enum_types/TestEnumTypes.py (original)<br>
+++ lldb/trunk/packages/Python/lldbsuite/test/lang/c/enum_types/TestEnumTypes.py Fri Apr 29 15:48:39 2016<br>
@@ -63,7 +63,14 @@ class EnumTypesTestCase(TestBase):<br>
                         'Sunday',<br>
                         'kNumDays',<br>
                         '5'];<br>
-<br>
+<br>
+        # Make sure a pointer to an anonymous enum type does crash LLDB and displays correctly using<br>
+        # frame variable and expression commands<br>
+        self.expect('frame variable f.op', DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ['ops *', 'f.op', '0x0000000000000000'])<br>
+        self.expect('frame variable *f.op', DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ['ops', '*f.op', '<parent is NULL>'])<br>
+        self.expect('expr f.op', DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ['ops *', '$', '0x0000000000000000'])<br>
+        self.expect('expr *f.op', DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ['error:'], error = True)<br>
+<br>
         bkpt = self.target().FindBreakpointByID(bkpt_id)<br>
         for enum_value in enum_values:<br>
             self.expect("frame variable day", 'check for valid enumeration value',<br>
<br>
Modified: lldb/trunk/packages/Python/lldbsuite/test/lang/c/enum_types/main.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/c/enum_types/main.c?rev=268098&r1=268097&r2=268098&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/c/enum_types/main.c?rev=268098&r1=268097&r2=268098&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/packages/Python/lldbsuite/test/lang/c/enum_types/main.c (original)<br>
+++ lldb/trunk/packages/Python/lldbsuite/test/lang/c/enum_types/main.c Fri Apr 29 15:48:39 2016<br>
@@ -8,6 +8,15 @@<br>
 //===----------------------------------------------------------------------===//<br>
 #include <stdio.h><br>
<br>
+#include <stdio.h><br>
+<br>
+// Forward declare an enumeration (only works in C, not C++)<br>
+typedef enum ops ops;<br>
+<br>
+struct foo {<br>
+       ops *op;<br>
+};<br>
+<br>
 int main (int argc, char const *argv[])<br>
 {<br>
     enum days {<br>
@@ -21,6 +30,8 @@ int main (int argc, char const *argv[])<br>
         kNumDays<br>
     };<br>
     enum days day;<br>
+    struct foo f;<br>
+       f.op = NULL;<br>
     for (day = Monday - 1; day <= kNumDays + 1; day++)<br>
     {<br>
         printf("day as int is %i\n", (int)day); // Set break point at this line.<br>
<br>
Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp?rev=268098&r1=268097&r2=268098&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp?rev=268098&r1=268097&r2=268098&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp (original)<br>
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp Fri Apr 29 15:48:39 2016<br>
@@ -1011,9 +1011,18 @@ DWARFASTParserClang::ParseTypeFromDWARF<br>
                             }<br>
<br>
                             if (!enumerator_clang_type)<br>
-                                enumerator_clang_type = m_ast.GetBuiltinTypeForDWARFEncodingAndBitSize (NULL,<br>
-                                                                                                        DW_ATE_signed,<br>
-                                                                                                        byte_size * 8);<br>
+                            {<br>
+                                if (byte_size > 0)<br>
+                                {<br>
+                                    enumerator_clang_type = m_ast.GetBuiltinTypeForDWARFEncodingAndBitSize(NULL,<br>
+                                                                                                           DW_ATE_signed,<br>
+                                                                                                           byte_size * 8);<br>
+                                }<br>
+                                else<br>
+                                {<br>
+                                    enumerator_clang_type = m_ast.GetBasicType(eBasicTypeInt);<br>
+                                }<br>
+                            }<br>
<br>
                             clang_type = m_ast.CreateEnumerationType (type_name_cstr,<br>
                                                                       GetClangDeclContextContainingDIE (die, nullptr),<br>
<br>
Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=268098&r1=268097&r2=268098&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=268098&r1=268097&r2=268098&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/source/Symbol/ClangASTContext.cpp (original)<br>
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp Fri Apr 29 15:48:39 2016<br>
@@ -8545,24 +8545,28 @@ ClangASTContext::CompleteTagDeclarationD<br>
                     clang::ASTContext *ast = lldb_ast->getASTContext();<br>
<br>
                     /// TODO This really needs to be fixed.<br>
-<br>
-                    unsigned NumPositiveBits = 1;<br>
-                    unsigned NumNegativeBits = 0;<br>
-<br>
-                    clang::QualType promotion_qual_type;<br>
-                    // If the enum integer type is less than an integer in bit width,<br>
-                    // then we must promote it to an integer size.<br>
-                    if (ast->getTypeSize(enum_decl->getIntegerType()) < ast->getTypeSize(ast->IntTy))<br>
+<br>
+                    QualType integer_type(enum_decl->getIntegerType());<br>
+                    if (!integer_type.isNull())<br>
                     {<br>
-                        if (enum_decl->getIntegerType()->isSignedIntegerType())<br>
-                            promotion_qual_type = ast->IntTy;<br>
+                        unsigned NumPositiveBits = 1;<br>
+                        unsigned NumNegativeBits = 0;<br>
+<br>
+                        clang::QualType promotion_qual_type;<br>
+                        // If the enum integer type is less than an integer in bit width,<br>
+                        // then we must promote it to an integer size.<br>
+                        if (ast->getTypeSize(enum_decl->getIntegerType()) < ast->getTypeSize(ast->IntTy))<br>
+                        {<br>
+                            if (enum_decl->getIntegerType()->isSignedIntegerType())<br>
+                                promotion_qual_type = ast->IntTy;<br>
+                            else<br>
+                                promotion_qual_type = ast->UnsignedIntTy;<br>
+                        }<br>
                         else<br>
-                            promotion_qual_type = ast->UnsignedIntTy;<br>
+                            promotion_qual_type = enum_decl->getIntegerType();<br>
+<br>
+                        enum_decl->completeDefinition(enum_decl->getIntegerType(), promotion_qual_type, NumPositiveBits, NumNegativeBits);<br>
                     }<br>
-                    else<br>
-                        promotion_qual_type = enum_decl->getIntegerType();<br>
-<br>
-                    enum_decl->completeDefinition(enum_decl->getIntegerType(), promotion_qual_type, NumPositiveBits, NumNegativeBits);<br>
                 }<br>
                 return true;<br>
             }<br>
<br>
<br>
_______________________________________________<br>
lldb-commits mailing list<br>
<a href="mailto:lldb-commits@lists.llvm.org">lldb-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits</a><br>
</blockquote></div><br></div>