diff options
author | Chris Mihelich <cmihelic@google.com> | 2024-06-05 16:33:54 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2024-06-05 16:34:48 -0700 |
commit | 54e1f14c6f9b1a764ffdf8c1aea7e823f95f3d01 (patch) | |
tree | d7d22576bec1533a2592ebec7c0c96f57e957d53 /absl/debugging/internal/demangle_test.cc | |
parent | fe43a4cb564ef6dc731d52e8246c7ecbd1fd6bf5 (diff) | |
download | abseil-54e1f14c6f9b1a764ffdf8c1aea7e823f95f3d01.tar.gz abseil-54e1f14c6f9b1a764ffdf8c1aea7e823f95f3d01.tar.bz2 abseil-54e1f14c6f9b1a764ffdf8c1aea7e823f95f3d01.zip |
Demangle object new-expressions, [gs] nw ....
PiperOrigin-RevId: 640688552
Change-Id: I843e5aed55f90eeb89e007389390d0aba705a3fe
Diffstat (limited to 'absl/debugging/internal/demangle_test.cc')
-rw-r--r-- | absl/debugging/internal/demangle_test.cc | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/absl/debugging/internal/demangle_test.cc b/absl/debugging/internal/demangle_test.cc index 7d455651..747bc06c 100644 --- a/absl/debugging/internal/demangle_test.cc +++ b/absl/debugging/internal/demangle_test.cc @@ -1068,6 +1068,86 @@ TEST(Demangle, BracedListImplicitlyConstructingAClassObject) { EXPECT_STREQ("f<>()", tmp); } +TEST(Demangle, SimpleNewExpression) { + char tmp[80]; + + // Source: + // + // template <class T> decltype(T{*new T}) f() { return T{}; } + // template decltype(int{*new int}) f<int>(); + // + // Full LLVM demangling of the instantiation of f: + // + // decltype(int{*(new int)}) f<int>() + EXPECT_TRUE(Demangle("_Z1fIiEDTtlT_denw_S0_EEEv", tmp, sizeof(tmp))); + EXPECT_STREQ("f<>()", tmp); +} + +TEST(Demangle, NewExpressionWithEmptyParentheses) { + char tmp[80]; + + // Source: + // + // template <class T> decltype(T{*new T()}) f() { return T{}; } + // template decltype(int{*new int()}) f<int>(); + // + // Full LLVM demangling of the instantiation of f: + // + // decltype(int{*(new int)}) f<int>() + EXPECT_TRUE(Demangle("_Z1fIiEDTtlT_denw_S0_piEEEv", tmp, sizeof(tmp))); + EXPECT_STREQ("f<>()", tmp); +} + +TEST(Demangle, NewExpressionWithNonemptyParentheses) { + char tmp[80]; + + // Source: + // + // template <class T> decltype(T{*new T(42)}) f() { return T{}; } + // template decltype(int{*new int(42)}) f<int>(); + // + // Full LLVM demangling of the instantiation of f: + // + // decltype(int{*(new int(42))}) f<int>() + EXPECT_TRUE(Demangle("_Z1fIiEDTtlT_denw_S0_piLi42EEEEv", tmp, sizeof(tmp))); + EXPECT_STREQ("f<>()", tmp); +} + +TEST(Demangle, PlacementNewExpression) { + char tmp[80]; + + // Source: + // + // #include <new> + // + // template <class T> auto f(T t) -> decltype(T{*new (&t) T(42)}) { + // return t; + // } + // template auto f<int>(int t) -> decltype(int{*new (&t) int(42)}); + // + // Full LLVM demangling of the instantiation of f: + // + // decltype(int{*(new(&fp) int(42))}) f<int>(int) + EXPECT_TRUE(Demangle("_Z1fIiEDTtlT_denwadfp__S0_piLi42EEEES0_", + tmp, sizeof(tmp))); + EXPECT_STREQ("f<>()", tmp); +} + +TEST(Demangle, GlobalScopeNewExpression) { + char tmp[80]; + + // Source: + // + // template <class T> decltype(T{*::new T}) f() { return T{}; } + // template decltype(int{*::new int}) f<int>(); + // + // Full LLVM demangling of the instantiation of f: + // + // decltype(int{*(::new int)}) f<int>() + EXPECT_TRUE(Demangle("_Z1fIiEDTtlT_degsnw_S0_EEEv", tmp, sizeof(tmp))); + EXPECT_STREQ("f<>()", tmp); +} + TEST(Demangle, ReferenceQualifiedFunctionTypes) { char tmp[80]; |