[Lldb-commits] [lldb] r133375 - in /lldb/trunk: include/lldb/Symbol/ClangASTContext.h source/Symbol/ClangASTContext.cpp
Greg Clayton
gclayton at apple.com
Sat Jun 18 20:43:27 PDT 2011
Author: gclayton
Date: Sat Jun 18 22:43:27 2011
New Revision: 133375
URL: http://llvm.org/viewvc/llvm-project?rev=133375&view=rev
Log:
Fixed a case where LLDB would crash if we get C++ operators with invalid
operator counts due to bad debug DWARF debug info. We now verify the operator
has a valid number of params using the clang operator tables.
Modified:
lldb/trunk/include/lldb/Symbol/ClangASTContext.h
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=133375&r1=133374&r2=133375&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original)
+++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Sat Jun 18 22:43:27 2011
@@ -289,6 +289,10 @@
is_explicit);
}
+ static bool
+ CheckOverloadedOperatorKindParameterCount (uint32_t op_kind,
+ uint32_t num_params);
+
bool
FieldIsBitfield (clang::FieldDecl* field,
uint32_t& bitfield_bit_size);
Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=133375&r1=133374&r2=133375&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/ClangASTContext.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp Sat Jun 18 22:43:27 2011
@@ -1358,6 +1358,29 @@
return true;
}
+static inline bool
+check_op_param (bool unary, bool binary, uint32_t num_params)
+{
+ // The parameter count doens't include "this"
+ if (num_params == 0)
+ return unary;
+ if (num_params == 1)
+ return binary;
+ return false;
+}
+
+bool
+ClangASTContext::CheckOverloadedOperatorKindParameterCount (uint32_t op_kind, uint32_t num_params)
+{
+#define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) case OO_##Name: return check_op_param (Unary, Binary, num_params);
+ switch (op_kind)
+ {
+#include "clang/Basic/OperatorKinds.def"
+ default: break;
+ }
+ return false;
+}
+
CXXMethodDecl *
ClangASTContext::AddMethodToCXXRecordType
(
@@ -1439,6 +1462,13 @@
{
if (op_kind != NUM_OVERLOADED_OPERATORS)
{
+ // Check the number of operator parameters. Sometimes we have
+ // seen bad DWARF that doesn't correctly describe operators and
+ // if we try to create a methed and add it to the class, clang
+ // will assert and crash, so we need to make sure things are
+ // acceptable.
+ if (!ClangASTContext::CheckOverloadedOperatorKindParameterCount (op_kind, num_params))
+ return NULL;
cxx_method_decl = CXXMethodDecl::Create (*ast,
cxx_record_decl,
SourceLocation(),
More information about the lldb-commits
mailing list