Fixed a problem that would cause LLDB to crash
authorSean Callanan <scallanan@apple.com>
Wed, 6 Feb 2013 23:21:59 +0000 (23:21 +0000)
committerSean Callanan <scallanan@apple.com>
Wed, 6 Feb 2013 23:21:59 +0000 (23:21 +0000)
if it encountered bad debug information.  This
debug information had an Objective-C method whose
selector disagreed with the true number of arguments
to that method.

<rdar://problem/12992864>

llvm-svn: 174557

lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Symbol/ClangASTContext.cpp

index ca1ca13..a5c17e1 100644 (file)
@@ -6309,6 +6309,13 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu,
                                         LinkDeclContextToDIE(ClangASTContext::GetAsDeclContext(objc_method_decl), die);
                                         GetClangASTContext().SetMetadataAsUserID ((uintptr_t)objc_method_decl, MakeUserID(die->GetOffset()));
                                     }
+                                    else
+                                    {
+                                        GetObjectFile()->GetModule()->ReportError ("{0x%8.8x}: invaliad Objective-C method 0x%4.4x (%s), please file a bug and attach the file at the start of this error message",
+                                                                                   die->GetOffset(),
+                                                                                   tag,
+                                                                                   DW_TAG_value_to_name(tag));
+                                    }
                                 }
                             }
                             else if (is_cxx_method)
index a5c6b1a..0749c84 100644 (file)
@@ -2722,6 +2722,9 @@ ClangASTContext::AddMethodToObjCObjectType
     ObjCMethodDecl::ImplementationControl imp_control = ObjCMethodDecl::None;
 
     const unsigned num_args = method_function_prototype->getNumArgs();
+    
+    if (num_args != num_selectors_with_args)
+        return NULL; // some debug information is corrupt.  We are not going to deal with it.
 
     ObjCMethodDecl *objc_method_decl = ObjCMethodDecl::Create (*ast,
                                                                SourceLocation(), // beginLoc,