[llvm] [ADT] Make hexdigit static (PR #94287)

Jacob Lambert via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 3 15:21:14 PDT 2024


https://github.com/lamb-j created https://github.com/llvm/llvm-project/pull/94287

By setting hexdigit to static, we avoid inadvertently exposing the symbol when creating an LLVM-based static library.

Without setting it to static, we see the following symbol when calling objdump -t -C on a static library calling LLVM APIs:

.rodata._ZZN4llvm8hexdigitEjbE3LU

>From 15a602dd430e3ad570ee7f2f53d8476f46915554 Mon Sep 17 00:00:00 2001
From: Jacob Lambert <jacob.lambert at amd.com>
Date: Mon, 3 Jun 2024 15:14:22 -0700
Subject: [PATCH] [ADT] Make hexdigit static

By setting hexdigit to static, we avoid inadvertently exposing
the symbol when creating a static library calling LLVM APIs
---
 llvm/include/llvm/ADT/StringExtras.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/include/llvm/ADT/StringExtras.h b/llvm/include/llvm/ADT/StringExtras.h
index 20e6ad1f68f99..bb33a8d867f59 100644
--- a/llvm/include/llvm/ADT/StringExtras.h
+++ b/llvm/include/llvm/ADT/StringExtras.h
@@ -34,7 +34,7 @@ class raw_ostream;
 
 /// hexdigit - Return the hexadecimal character for the
 /// given number \p X (which should be less than 16).
-inline char hexdigit(unsigned X, bool LowerCase = false) {
+static inline char hexdigit(unsigned X, bool LowerCase = false) {
   assert(X < 16);
   static const char LUT[] = "0123456789ABCDEF";
   const uint8_t Offset = LowerCase ? 32 : 0;



More information about the llvm-commits mailing list