[llvm] fc0f2bb - [Demangle][Rust] Parse bool constants
Tomasz Miąsko via llvm-commits
llvm-commits at lists.llvm.org
Sat May 15 01:04:43 PDT 2021
Author: Tomasz Miąsko
Date: 2021-05-15T09:47:17+02:00
New Revision: fc0f2bb91d01963647392cbba1fe37a6f2d9f3bf
URL: https://github.com/llvm/llvm-project/commit/fc0f2bb91d01963647392cbba1fe37a6f2d9f3bf
DIFF: https://github.com/llvm/llvm-project/commit/fc0f2bb91d01963647392cbba1fe37a6f2d9f3bf.diff
LOG: [Demangle][Rust] Parse bool constants
Reviewed By: dblaikie
Differential Revision: https://reviews.llvm.org/D102518
Added:
Modified:
llvm/include/llvm/Demangle/RustDemangle.h
llvm/lib/Demangle/RustDemangle.cpp
llvm/test/Demangle/rust.test
Removed:
################################################################################
diff --git a/llvm/include/llvm/Demangle/RustDemangle.h b/llvm/include/llvm/Demangle/RustDemangle.h
index f7fa21328648a..3fe73803cf869 100644
--- a/llvm/include/llvm/Demangle/RustDemangle.h
+++ b/llvm/include/llvm/Demangle/RustDemangle.h
@@ -80,6 +80,7 @@ class Demangler {
void demangleType();
void demangleConst();
void demangleConstInt();
+ void demangleConstBool();
Identifier parseIdentifier();
uint64_t parseOptionalBase62Number(char Tag);
diff --git a/llvm/lib/Demangle/RustDemangle.cpp b/llvm/lib/Demangle/RustDemangle.cpp
index 1bc9d47f6940c..3a9e75f33b9c5 100644
--- a/llvm/lib/Demangle/RustDemangle.cpp
+++ b/llvm/lib/Demangle/RustDemangle.cpp
@@ -411,11 +411,14 @@ void Demangler::demangleConst() {
case BasicType::USize:
demangleConstInt();
break;
+ case BasicType::Bool:
+ demangleConstBool();
+ break;
case BasicType::Placeholder:
print('_');
break;
default:
- // FIXME demangle backreferences, bool constants, and char constants.
+ // FIXME demangle backreferences and char constants.
Error = true;
break;
}
@@ -439,6 +442,19 @@ void Demangler::demangleConstInt() {
}
}
+// <const-data> = "0_" // false
+// | "1_" // true
+void Demangler::demangleConstBool() {
+ StringView HexDigits;
+ parseHexNumber(HexDigits);
+ if (HexDigits == "0")
+ print("false");
+ else if (HexDigits == "1")
+ print("true");
+ else
+ Error = true;
+}
+
// <undisambiguated-identifier> = ["u"] <decimal-number> ["_"] <bytes>
Identifier Demangler::parseIdentifier() {
bool Punycode = consumeIf('u');
diff --git a/llvm/test/Demangle/rust.test b/llvm/test/Demangle/rust.test
index 256d594206ebb..4caf92b3230e4 100644
--- a/llvm/test/Demangle/rust.test
+++ b/llvm/test/Demangle/rust.test
@@ -191,6 +191,22 @@ CHECK: i64::<0>
CHECK: u64::<0>
_RIC3u64Ky0_E
+; Bool constants
+
+CHECK: bool::<false>
+ _RIC4boolKb0_E
+
+CHECK: bool::<true>
+ _RIC4boolKb1_E
+
+; Invalid bool constants
+
+CHECK: _RIC4boolKb2_E
+ _RIC4boolKb2_E
+
+CHECK: _RIC4boolKbn0_E
+ _RIC4boolKbn0_E
+
; Invalid mangled characters
CHECK: _RNvC2a.1c
More information about the llvm-commits
mailing list