[llvm] [ItaniumDemangle] reject A-F in FP literals (PR #83061)

Ryan Prichard via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 27 19:43:01 PST 2024


https://github.com/rprichard updated https://github.com/llvm/llvm-project/pull/83061

>From 5c4f316b96c37f1c368ffbc63cf3513a9feb9785 Mon Sep 17 00:00:00 2001
From: Ryan Prichard <rprichard at google.com>
Date: Mon, 26 Feb 2024 13:31:16 -0800
Subject: [PATCH] [ItaniumDemangle] reject A-F in FP literals

Sync this change to the copy of ItaniumDemangle.h in "llvm":

The Itanium C++ ABI specifies that FP literals are encoded using a
lowercase hexadecimal string. Previously, libc++abi allowed uppercase
A-F characters but decoded them by subtracting 'a' from them, producing
negative digit values. It is especially confusing to accept an 'E' digit
because 'E' marks the end of the FP literal.
---
 llvm/include/llvm/Demangle/ItaniumDemangle.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/include/llvm/Demangle/ItaniumDemangle.h b/llvm/include/llvm/Demangle/ItaniumDemangle.h
index 04bc58d8f63e47..d33af157543fec 100644
--- a/llvm/include/llvm/Demangle/ItaniumDemangle.h
+++ b/llvm/include/llvm/Demangle/ItaniumDemangle.h
@@ -5540,7 +5540,7 @@ Node *AbstractManglingParser<Alloc, Derived>::parseFloatingLiteral() {
     return nullptr;
   std::string_view Data(First, N);
   for (char C : Data)
-    if (!std::isxdigit(C))
+    if (!(C >= '0' && C <= '9') && !(C >= 'a' && C <= 'f'))
       return nullptr;
   First += N;
   if (!consumeIf('E'))



More information about the llvm-commits mailing list