Fix a few demangler issues.
Specifically:
* rvalue references.
* St does not require N...E delimiters (explicit special case in the spec).
* ".cfi" suffixes.
Bug: http://b/67678053
Test: ran tests
Change-Id: If8cabad448b46b165eefc6c5487996428c9c6975
diff --git a/demangle/DemangleTest.cpp b/demangle/DemangleTest.cpp
index 46a6f76..1787031 100644
--- a/demangle/DemangleTest.cpp
+++ b/demangle/DemangleTest.cpp
@@ -509,6 +509,29 @@
ASSERT_EQ("_ZTH_N3oneE", demangler.Parse("_ZTH_N3oneE"));
}
+TEST(DemangleTest, r_value_reference) {
+ Demangler demangler;
+ ASSERT_EQ(
+ "android::SurfaceComposerClient::Transaction::merge(android::SurfaceComposerClient::"
+ "Transaction&&)",
+ demangler.Parse("_ZN7android21SurfaceComposerClient11Transaction5mergeEOS1_"));
+}
+
+TEST(DemangleTest, initial_St) {
+ Demangler demangler;
+ EXPECT_EQ("std::state", demangler.Parse("_ZSt5state"));
+ EXPECT_EQ("std::_In::ward", demangler.Parse("_ZNSt3_In4wardE"));
+ EXPECT_EQ("std::__terminate(void (*)())", demangler.Parse("_ZSt11__terminatePFvvE"));
+}
+
+TEST(DemangleTest, cfi) {
+ Demangler demangler;
+ EXPECT_EQ("nfa_sys_ptim_timer_update(tPTIM_CB*)",
+ demangler.Parse("_Z25nfa_sys_ptim_timer_updateP8tPTIM_CB"));
+ EXPECT_EQ("nfa_sys_ptim_timer_update(tPTIM_CB*) [clone .cfi]",
+ demangler.Parse("_Z25nfa_sys_ptim_timer_updateP8tPTIM_CB.cfi"));
+}
+
TEST(DemangleTest, demangle) {
std::string str;
diff --git a/demangle/Demangler.cpp b/demangle/Demangler.cpp
index af2816c..7a3aa81 100644
--- a/demangle/Demangler.cpp
+++ b/demangle/Demangler.cpp
@@ -580,6 +580,10 @@
}
return name + 1;
+ case 'O':
+ cur_state_.suffixes.push_back("&&");
+ return name + 1;
+
case 'K':
case 'V': {
const char* suffix;
@@ -701,6 +705,9 @@
cur_state_.str.clear();
}
return name;
+ } else if (strcmp(name, ".cfi") == 0) {
+ function_suffix_ += " [clone .cfi]";
+ return name + 4;
}
}
return nullptr;
@@ -816,6 +823,16 @@
return name + 1;
}
+ if (*name == 'S') {
+ name++;
+ if (*name == 't') {
+ function_name_ = "std::";
+ name++;
+ } else {
+ return nullptr;
+ }
+ }
+
if (std::isdigit(*name)) {
name = GetStringFromLength(name, &function_name_);
} else if (*name == 'L' && std::isdigit(name[1])) {