Skip to content

Commit

Permalink
Merge "Add support for non-virtual thunk."
Browse files Browse the repository at this point in the history
  • Loading branch information
cferris1000 authored and Gerrit Code Review committed Nov 2, 2017
2 parents 3d879b1 + 5a72ea0 commit 0d323c1
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
21 changes: 21 additions & 0 deletions demangle/DemangleTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,27 @@ TEST(DemangleTest, BooleanLiterals) {
demangler.Parse("_ZN3oneE3twoI5threeI4fourELb0ELb1EE"));
}

TEST(DemangleTest, non_virtual_thunk) {
Demangler demangler;

ASSERT_EQ("non-virtual thunk to one", demangler.Parse("_ZThn0_N3oneE"));
ASSERT_EQ("non-virtual thunk to two", demangler.Parse("_ZThn0_3two"));
ASSERT_EQ("non-virtual thunk to three", demangler.Parse("_ZTh0_5three"));
ASSERT_EQ("non-virtual thunk to four", demangler.Parse("_ZTh_4four"));
ASSERT_EQ("non-virtual thunk to five", demangler.Parse("_ZTh0123456789_4five"));
ASSERT_EQ("non-virtual thunk to six", demangler.Parse("_ZThn0123456789_3six"));

ASSERT_EQ("_ZThn0N3oneE", demangler.Parse("_ZThn0N3oneE"));
ASSERT_EQ("_ZThn03two", demangler.Parse("_ZThn03two"));
ASSERT_EQ("_ZTh05three", demangler.Parse("_ZTh05three"));
ASSERT_EQ("_ZTh4four", demangler.Parse("_ZTh4four"));
ASSERT_EQ("_ZTh01234567894five", demangler.Parse("_ZTh01234567894five"));
ASSERT_EQ("_ZThn01234567893six", demangler.Parse("_ZThn01234567893six"));
ASSERT_EQ("_ZT_N3oneE", demangler.Parse("_ZT_N3oneE"));
ASSERT_EQ("_ZT0_N3oneE", demangler.Parse("_ZT0_N3oneE"));
ASSERT_EQ("_ZTH_N3oneE", demangler.Parse("_ZTH_N3oneE"));
}

TEST(DemangleTest, demangle) {
std::string str;

Expand Down
26 changes: 25 additions & 1 deletion demangle/Demangler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ const char* Demangler::ParseFunctionName(const char* name) {
saves_.pop_back();
}

function_name_ = cur_state_.str;
function_name_ += cur_state_.str;
while (!cur_state_.suffixes.empty()) {
function_suffix_ += cur_state_.suffixes.back();
cur_state_.suffixes.pop_back();
Expand Down Expand Up @@ -786,6 +786,30 @@ const char* Demangler::ParseFunctionTemplateArguments(const char* name) {
}

const char* Demangler::FindFunctionName(const char* name) {
if (*name == 'T') {
// non-virtual thunk, verify that it matches one of these patterns:
// Thn[0-9]+_
// Th[0-9]+_
// Thn_
// Th_
name++;
if (*name != 'h') {
return nullptr;
}
name++;
if (*name == 'n') {
name++;
}
while (std::isdigit(*name)) {
name++;
}
if (*name != '_') {
return nullptr;
}
function_name_ = "non-virtual thunk to ";
return name + 1;
}

if (*name == 'N') {
parse_funcs_.push_back(&Demangler::ParseArgumentsAtTopLevel);
parse_func_ = &Demangler::ParseFunctionName;
Expand Down

0 comments on commit 0d323c1

Please sign in to comment.