Commit cfac0a35 by Chris Mihelich Committed by Copybara-Service

Demangle the C++ spaceship operator (ss, operator<=>).

PiperOrigin-RevId: 636634618
Change-Id: I812115d2a33dc71446a14deadc6af019eef6dfd7
parent a3c25aec
...@@ -81,6 +81,7 @@ static const AbbrevPair kOperatorList[] = { ...@@ -81,6 +81,7 @@ static const AbbrevPair kOperatorList[] = {
{"rs", ">>", 2}, {"rs", ">>", 2},
{"lS", "<<=", 2}, {"lS", "<<=", 2},
{"rS", ">>=", 2}, {"rS", ">>=", 2},
{"ss", "<=>", 2},
{"eq", "==", 2}, {"eq", "==", 2},
{"ne", "!=", 2}, {"ne", "!=", 2},
{"lt", "<", 2}, {"lt", "<", 2},
......
...@@ -349,6 +349,28 @@ TEST(Demangle, SizeofPacks) { ...@@ -349,6 +349,28 @@ TEST(Demangle, SizeofPacks) {
EXPECT_STREQ("g<>()", tmp); EXPECT_STREQ("g<>()", tmp);
} }
TEST(Demangle, Spaceship) {
char tmp[80];
// #include <compare>
//
// struct S { auto operator<=>(const S&) const = default; };
// auto (S::*f) = &S::operator<=>; // make sure S::operator<=> is emitted
//
// template <class T> auto g(T x, T y) -> decltype(x <=> y) {
// return x <=> y;
// }
// template auto g<S>(S x, S y) -> decltype(x <=> y);
// S::operator<=>(S const&) const
EXPECT_TRUE(Demangle("_ZNK1SssERKS_", tmp, sizeof(tmp)));
EXPECT_STREQ("S::operator<=>()", tmp);
// decltype(fp <=> fp0) g<S>(S, S)
EXPECT_TRUE(Demangle("_Z1gI1SEDTssfp_fp0_ET_S2_", tmp, sizeof(tmp)));
EXPECT_STREQ("g<>()", tmp);
}
// Test one Rust symbol to exercise Demangle's delegation path. Rust demangling // Test one Rust symbol to exercise Demangle's delegation path. Rust demangling
// itself is more thoroughly tested in demangle_rust_test.cc. // itself is more thoroughly tested in demangle_rust_test.cc.
TEST(Demangle, DelegatesToDemangleRustSymbolEncoding) { TEST(Demangle, DelegatesToDemangleRustSymbolEncoding) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment