[llvm] Revert "[NFC] Don't recompute type name" (PR #119907)

Ian Wood via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 13 09:56:22 PST 2024


https://github.com/IanWood1 updated https://github.com/llvm/llvm-project/pull/119907

>From 68d7d771d84cefff427cfa47e3bf2beeaf2706a6 Mon Sep 17 00:00:00 2001
From: Ian Wood <ianwood2024 at u.northwestern.edu>
Date: Fri, 13 Dec 2024 09:37:36 -0800
Subject: [PATCH 1/2] Revert "[NFC] Don't recompute type name (#119631)"

This reverts commit 003a721c1c9e3a99d6d0c1a6755443b260235537.
---
 llvm/include/llvm/Support/TypeName.h | 30 +++++++++++-----------------
 1 file changed, 12 insertions(+), 18 deletions(-)

diff --git a/llvm/include/llvm/Support/TypeName.h b/llvm/include/llvm/Support/TypeName.h
index 61ba09c2163047..9547e76a7fa79b 100644
--- a/llvm/include/llvm/Support/TypeName.h
+++ b/llvm/include/llvm/Support/TypeName.h
@@ -13,8 +13,18 @@
 
 namespace llvm {
 
-namespace detail {
-template <typename DesiredTypeName> inline StringRef getTypeNameImpl() {
+/// We provide a function which tries to compute the (demangled) name of a type
+/// statically.
+///
+/// This routine may fail on some platforms or for particularly unusual types.
+/// Do not use it for anything other than logging and debugging aids. It isn't
+/// portable or dependendable in any real sense.
+///
+/// The returned StringRef will point into a static storage duration string.
+/// However, it may not be null terminated and may be some strangely aligned
+/// inner substring of a larger string.
+template <typename DesiredTypeName>
+inline StringRef getTypeName() {
 #if defined(__clang__) || defined(__GNUC__)
   StringRef Name = __PRETTY_FUNCTION__;
 
@@ -48,22 +58,6 @@ template <typename DesiredTypeName> inline StringRef getTypeNameImpl() {
   return "UNKNOWN_TYPE";
 #endif
 }
-} // namespace detail
-
-/// We provide a function which tries to compute the (demangled) name of a type
-/// statically.
-///
-/// This routine may fail on some platforms or for particularly unusual types.
-/// Do not use it for anything other than logging and debugging aids. It isn't
-/// portable or dependendable in any real sense.
-///
-/// The returned StringRef will point into a static storage duration string.
-/// However, it may not be null terminated and may be some strangely aligned
-/// inner substring of a larger string.
-template <typename DesiredTypeName> inline StringRef getTypeName() {
-  static StringRef Name = detail::getTypeNameImpl<DesiredTypeName>();
-  return Name;
-}
 
 } // namespace llvm
 

>From b858dfc01b6da1675f3ed99416063e118dd27324 Mon Sep 17 00:00:00 2001
From: Ian Wood <ianwood2024 at u.northwestern.edu>
Date: Fri, 13 Dec 2024 21:52:05 -0800
Subject: [PATCH 2/2] Fix formatting

---
 llvm/include/llvm/Support/TypeName.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/llvm/include/llvm/Support/TypeName.h b/llvm/include/llvm/Support/TypeName.h
index 9547e76a7fa79b..518a39ee02a53a 100644
--- a/llvm/include/llvm/Support/TypeName.h
+++ b/llvm/include/llvm/Support/TypeName.h
@@ -23,8 +23,7 @@ namespace llvm {
 /// The returned StringRef will point into a static storage duration string.
 /// However, it may not be null terminated and may be some strangely aligned
 /// inner substring of a larger string.
-template <typename DesiredTypeName>
-inline StringRef getTypeName() {
+template <typename DesiredTypeName> inline StringRef getTypeName() {
 #if defined(__clang__) || defined(__GNUC__)
   StringRef Name = __PRETTY_FUNCTION__;
 



More information about the llvm-commits mailing list