[Lldb-commits] [lldb] r252001 - With the new modules debugging, we have seen cases where clang is not emitting full definitions for types that are member variables of classes. If we try to make a class with a member where the type of the class in a forward declaration, clang will assert and crash and bring down the IDE. This is not acceptable so we need to work around it. We work around it by making sure that if we have a member that is an instance (not a pointer or reference) of a class/struct/union, that it is a comp...

Greg Clayton via lldb-commits lldb-commits at lists.llvm.org
Tue Nov 3 14:40:07 PST 2015


Author: gclayton
Date: Tue Nov  3 16:40:07 2015
New Revision: 252001

URL: http://llvm.org/viewvc/llvm-project?rev=252001&view=rev
Log:
With the new modules debugging, we have seen cases where clang is not emitting full definitions for types that are member variables of classes. If we try to make a class with a member where the type of the class in a forward declaration, clang will assert and crash and bring down the IDE. This is not acceptable so we need to work around it. We work around it by making sure that if we have a member that is an instance (not a pointer or reference) of a class/struct/union, that it is a complete type. If it isn't then we emit an error to let the user know to file a bug against the compiler, and then we make the class complete, but empty. We also do this for base classes elsewhere. We use the DWARF to help layout the type, so we will get all instance variables correct, but we just won't have visibility into this instance variable.


Modified:
    lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp

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=252001&r1=252000&r2=252001&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp Tue Nov  3 16:40:07 2015
@@ -2777,6 +2777,23 @@ DWARFASTParserClang::ParseChildMembers (
                                     }
                                 }
 
+                                if (ClangASTContext::IsCXXClassType(member_clang_type) && member_clang_type.GetCompleteType() == false)
+                                {
+                                    module_sp->ReportError ("DWARF DIE at 0x%8.8x (class %s) has a member variable 0x%8.8x (%s) whose type is a forward declaration, not a complete definition.\nPlease file a bug against the compiler and include the preprocessed output for %s",
+                                                            parent_die.GetOffset(),
+                                                            parent_die.GetName(),
+                                                            die.GetOffset(),
+                                                            name,
+                                                            sc.comp_unit ? sc.comp_unit->GetPath().c_str() : "the source file");
+                                    // We have no choice other than to pretend that the member class
+                                    // is complete. If we don't do this, clang will crash when trying
+                                    // to layout the class. Since we provide layout assistance, all
+                                    // ivars in this class and other classes will be fine, this is
+                                    // the best we can do short of crashing.
+                                    ClangASTContext::StartTagDeclarationDefinition(member_clang_type);
+                                    ClangASTContext::CompleteTagDeclarationDefinition(member_clang_type);
+                                }
+
                                 field_decl = ClangASTContext::AddFieldToRecordType (class_clang_type,
                                                                                     name,
                                                                                     member_clang_type,




More information about the lldb-commits mailing list