summaryrefslogtreecommitdiff
path: root/absl
diff options
context:
space:
mode:
authorGravatar Chris Mihelich <cmihelic@google.com>2024-06-06 15:47:25 -0700
committerGravatar Copybara-Service <copybara-worker@google.com>2024-06-06 15:48:15 -0700
commit6e607350cccd7e5157ca4b522489920db45c8e8b (patch)
treed86789cea56561aac927e42fcb10c405a1deafb4 /absl
parent2a40eb6086cf10d1c3f148db6c5906b0aaa2ff90 (diff)
Demangle C++11 user-defined literal operator functions.
PiperOrigin-RevId: 641046309 Change-Id: Iaa2564a60035421969c2cd6074a457980083cbd2
Diffstat (limited to 'absl')
-rw-r--r--absl/debugging/internal/demangle.cc10
-rw-r--r--absl/debugging/internal/demangle_test.cc14
2 files changed, 22 insertions, 2 deletions
diff --git a/absl/debugging/internal/demangle.cc b/absl/debugging/internal/demangle.cc
index 42c10bbe..8b76ce01 100644
--- a/absl/debugging/internal/demangle.cc
+++ b/absl/debugging/internal/demangle.cc
@@ -14,8 +14,6 @@
// For reference check out:
// https://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangling
-//
-// Note that we only have partial C++11 support yet.
#include "absl/debugging/internal/demangle.h"
@@ -1044,6 +1042,7 @@ static bool ParseIdentifier(State *state, size_t length) {
// <operator-name> ::= nw, and other two letters cases
// ::= cv <type> # (cast)
+// ::= li <source-name> # C++11 user-defined literal
// ::= v <digit> <source-name> # vendor extended operator
static bool ParseOperatorName(State *state, int *arity) {
ComplexityGuard guard(state);
@@ -1063,6 +1062,13 @@ static bool ParseOperatorName(State *state, int *arity) {
}
state->parse_state = copy;
+ // Then user-defined literals.
+ if (ParseTwoCharToken(state, "li") && MaybeAppend(state, "operator\"\" ") &&
+ ParseSourceName(state)) {
+ return true;
+ }
+ state->parse_state = copy;
+
// Then vendor extended operators.
if (ParseOneCharToken(state, 'v') && ParseDigit(state, arity) &&
ParseSourceName(state)) {
diff --git a/absl/debugging/internal/demangle_test.cc b/absl/debugging/internal/demangle_test.cc
index 68ab8a3c..108642a8 100644
--- a/absl/debugging/internal/demangle_test.cc
+++ b/absl/debugging/internal/demangle_test.cc
@@ -1035,6 +1035,20 @@ TEST(Demangle, SizeofPackInvolvingAnAliasTemplate) {
EXPECT_STREQ("f<>()", tmp);
}
+TEST(Demangle, UserDefinedLiteral) {
+ char tmp[80];
+
+ // Source:
+ //
+ // unsigned long long operator""_lit(unsigned long long x) { return x; }
+ //
+ // LLVM demangling:
+ //
+ // operator"" _lit(unsigned long long)
+ EXPECT_TRUE(Demangle("_Zli4_lity", tmp, sizeof(tmp)));
+ EXPECT_STREQ("operator\"\" _lit()", tmp);
+}
+
TEST(Demangle, Spaceship) {
char tmp[80];