diff options
author | Chris Mihelich <cmihelic@google.com> | 2024-05-29 04:12:22 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2024-05-29 04:13:24 -0700 |
commit | 1f5a9cdc4354faccda4227235ea1acb77d9a4466 (patch) | |
tree | d1c4479d55d5bbf773e8f231c5ec2b85c376c7c6 /absl/debugging/internal/demangle_test.cc | |
parent | 457fdbf960b541743de0a08956b20f2421073284 (diff) | |
download | abseil-1f5a9cdc4354faccda4227235ea1acb77d9a4466.tar.gz abseil-1f5a9cdc4354faccda4227235ea1acb77d9a4466.tar.bz2 abseil-1f5a9cdc4354faccda4227235ea1acb77d9a4466.zip |
Demangle static_cast and friends.
PiperOrigin-RevId: 638232699
Change-Id: I134905927ba72eaa5eaf821bb5535942746a3672
Diffstat (limited to 'absl/debugging/internal/demangle_test.cc')
-rw-r--r-- | absl/debugging/internal/demangle_test.cc | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/absl/debugging/internal/demangle_test.cc b/absl/debugging/internal/demangle_test.cc index 96051d31..2c582415 100644 --- a/absl/debugging/internal/demangle_test.cc +++ b/absl/debugging/internal/demangle_test.cc @@ -706,6 +706,76 @@ TEST(Demangle, ReferenceQualifiedFunctionTypes) { EXPECT_STREQ("f()", tmp); } +TEST(Demangle, DynamicCast) { + char tmp[80]; + + // Source: + // + // template <class T> auto f(T* p) -> decltype(dynamic_cast<const T*>(p)) { + // return p; + // } + // struct S {}; + // void g(S* p) { f(p); } + // + // Full LLVM demangling of the instantiation of f: + // + // decltype(dynamic_cast<S const*>(fp)) f<S>(S*) + EXPECT_TRUE(Demangle("_Z1fI1SEDTdcPKT_fp_EPS1_", tmp, sizeof(tmp))); + EXPECT_STREQ("f<>()", tmp); +} + +TEST(Demangle, StaticCast) { + char tmp[80]; + + // Source: + // + // template <class T> auto f(T* p) -> decltype(static_cast<const T*>(p)) { + // return p; + // } + // void g(int* p) { f(p); } + // + // Full LLVM demangling of the instantiation of f: + // + // decltype(static_cast<int const*>(fp)) f<int>(int*) + EXPECT_TRUE(Demangle("_Z1fIiEDTscPKT_fp_EPS0_", tmp, sizeof(tmp))); + EXPECT_STREQ("f<>()", tmp); +} + +TEST(Demangle, ConstCast) { + char tmp[80]; + + // Source: + // + // template <class T> auto f(T* p) -> decltype(const_cast<const T*>(p)) { + // return p; + // } + // void g(int* p) { f(p); } + // + // Full LLVM demangling of the instantiation of f: + // + // decltype(const_cast<int const*>(fp)) f<int>(int*) + EXPECT_TRUE(Demangle("_Z1fIiEDTccPKT_fp_EPS0_", tmp, sizeof(tmp))); + EXPECT_STREQ("f<>()", tmp); +} + +TEST(Demangle, ReinterpretCast) { + char tmp[80]; + + // Source: + // + // template <class T> auto f(T* p) + // -> decltype(reinterpret_cast<const T*>(p)) { + // return p; + // } + // void g(int* p) { f(p); } + // + // Full LLVM demangling of the instantiation of f: + // + // decltype(reinterpret_cast<int const*>(fp)) f<int>(int*) + EXPECT_TRUE(Demangle("_Z1fIiEDTrcPKT_fp_EPS0_", tmp, sizeof(tmp))); + EXPECT_STREQ("f<>()", tmp); +} + TEST(Demangle, ThreadLocalWrappers) { char tmp[80]; |