summaryrefslogtreecommitdiff
path: root/absl/debugging/internal
diff options
context:
space:
mode:
authorGravatar Chris Mihelich <cmihelic@google.com>2024-06-04 12:17:51 -0700
committerGravatar Copybara-Service <copybara-worker@google.com>2024-06-04 12:18:33 -0700
commit36d1644be1fe815cef318e52a3ef4c8f5c50ea01 (patch)
tree862625c06e6e2e67868207ebf9aa35df48ae0c0f /absl/debugging/internal
parentb0e72168e573bae16dc523525e40d4eaf20d475e (diff)
Demangle il ... E syntax (braced list other than direct-list-initialization).
PiperOrigin-RevId: 640242497 Change-Id: I5574281110ddb27a6ee8d902dae90be6be6c0886
Diffstat (limited to 'absl/debugging/internal')
-rw-r--r--absl/debugging/internal/demangle.cc9
-rw-r--r--absl/debugging/internal/demangle_test.cc60
2 files changed, 69 insertions, 0 deletions
diff --git a/absl/debugging/internal/demangle.cc b/absl/debugging/internal/demangle.cc
index d338c646..99461f3f 100644
--- a/absl/debugging/internal/demangle.cc
+++ b/absl/debugging/internal/demangle.cc
@@ -1951,6 +1951,7 @@ static bool ParseBracedExpression(State *state) {
// ::= cv <type> <expression> # type (expression)
// ::= cv <type> _ <expression>* E # type (expr-list)
// ::= tl <type> <braced-expression>* E
+// ::= il <braced-expression>* E
// ::= dc <type> <expression>
// ::= sc <type> <expression>
// ::= cc <type> <expression>
@@ -2021,6 +2022,14 @@ static bool ParseExpression(State *state) {
}
state->parse_state = copy;
+ // <expression> ::= il <braced-expression>* E
+ if (ParseTwoCharToken(state, "il") &&
+ ZeroOrMore(ParseBracedExpression, state) &&
+ ParseOneCharToken(state, 'E')) {
+ return true;
+ }
+ state->parse_state = copy;
+
// dynamic_cast, static_cast, const_cast, reinterpret_cast.
//
// <expression> ::= (dc | sc | cc | rc) <type> <expression>
diff --git a/absl/debugging/internal/demangle_test.cc b/absl/debugging/internal/demangle_test.cc
index aea3f4f5..6010bd87 100644
--- a/absl/debugging/internal/demangle_test.cc
+++ b/absl/debugging/internal/demangle_test.cc
@@ -876,6 +876,66 @@ TEST(Demangle, DirectListInitialization) {
EXPECT_STREQ("j<>()", tmp);
}
+TEST(Demangle, SimpleInitializerLists) {
+ char tmp[80];
+
+ // Common preamble of source-code examples in this test function:
+ //
+ // #include <initializer_list>
+ //
+ // template <class T> void g(std::initializer_list<T>) {}
+
+ // Source:
+ //
+ // template <class T> auto f() -> decltype(g<T>({})) {}
+ // template auto f<int>() -> decltype(g<int>({}));
+ //
+ // Full LLVM demangling of the instantiation of f:
+ //
+ // decltype(g<int>({})) f<int>()
+ EXPECT_TRUE(Demangle("_Z1fIiEDTcl1gIT_EilEEEv", tmp, sizeof(tmp)));
+ EXPECT_STREQ("f<>()", tmp);
+
+ // Source:
+ //
+ // template <class T> auto f(T x) -> decltype(g({x})) {}
+ // template auto f<int>(int x) -> decltype(g({x}));
+ //
+ // Full LLVM demangling of the instantiation of f:
+ //
+ // decltype(g({fp})) f<int>(int)
+ EXPECT_TRUE(Demangle("_Z1fIiEDTcl1gilfp_EEET_", tmp, sizeof(tmp)));
+ EXPECT_STREQ("f<>()", tmp);
+
+ // Source:
+ //
+ // template <class T> auto f(T x, T y) -> decltype(g({x, y})) {}
+ // template auto f<int>(int x, int y) -> decltype(g({x, y}));
+ //
+ // Full LLVM demangling of the instantiation of f:
+ //
+ // decltype(g({fp, fp0})) f<int>(int, int)
+ EXPECT_TRUE(Demangle("_Z1fIiEDTcl1gilfp_fp0_EEET_S1_", tmp, sizeof(tmp)));
+ EXPECT_STREQ("f<>()", tmp);
+}
+
+TEST(Demangle, BracedListImplicitlyConstructingAClassObject) {
+ char tmp[80];
+
+ // Source:
+ //
+ // struct S { int v; };
+ // void g(S) {}
+ // template <class T> auto f(T x) -> decltype(g({.v = x})) {}
+ // template auto f<int>(int x) -> decltype(g({.v = x}));
+ //
+ // Full LLVM demangling of the instantiation of f:
+ //
+ // decltype(g({.v = fp})) f<int>(int)
+ EXPECT_TRUE(Demangle("_Z1fIiEDTcl1gildi1vfp_EEET_", tmp, sizeof(tmp)));
+ EXPECT_STREQ("f<>()", tmp);
+}
+
TEST(Demangle, ReferenceQualifiedFunctionTypes) {
char tmp[80];