diff options
| author | Greg Clayton <gclayton@apple.com> | 2011-06-19 03:43:27 +0000 |
|---|---|---|
| committer | Greg Clayton <gclayton@apple.com> | 2011-06-19 03:43:27 +0000 |
| commit | 090d098fc263713b84999b37d6ac95a90cccd789 (patch) | |
| tree | e5c89b1aef9f8926b2fdafb098f18e006c67a538 /lldb/source | |
| parent | 1869aa35ca59494b3fe26f31e53d8145111c2e38 (diff) | |
| download | bcm5719-llvm-090d098fc263713b84999b37d6ac95a90cccd789.tar.gz bcm5719-llvm-090d098fc263713b84999b37d6ac95a90cccd789.zip | |
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.
llvm-svn: 133375
Diffstat (limited to 'lldb/source')
| -rw-r--r-- | lldb/source/Symbol/ClangASTContext.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp index 524f4da6f82..6e426f119b6 100644 --- a/lldb/source/Symbol/ClangASTContext.cpp +++ b/lldb/source/Symbol/ClangASTContext.cpp @@ -1358,6 +1358,29 @@ IsOperator (const char *name, OverloadedOperatorKind &op_kind) 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 @@ ClangASTContext::AddMethodToCXXRecordType { 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(), |

