diff options
author | Chris Mihelich <cmihelic@google.com> | 2024-06-04 12:17:51 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2024-06-04 12:18:33 -0700 |
commit | 36d1644be1fe815cef318e52a3ef4c8f5c50ea01 (patch) | |
tree | 862625c06e6e2e67868207ebf9aa35df48ae0c0f /absl/debugging/internal/demangle_test.cc | |
parent | b0e72168e573bae16dc523525e40d4eaf20d475e (diff) |
Demangle il ... E syntax (braced list other than direct-list-initialization).
PiperOrigin-RevId: 640242497
Change-Id: I5574281110ddb27a6ee8d902dae90be6be6c0886
Diffstat (limited to 'absl/debugging/internal/demangle_test.cc')
-rw-r--r-- | absl/debugging/internal/demangle_test.cc | 60 |
1 files changed, 60 insertions, 0 deletions
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]; |