[PATCH] D103459: [Demangle][Rust] Parse path backreferences
Tomasz Miąsko via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 8 01:03:26 PDT 2021
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
tmiasko marked an inline comment as done.
Closed by commit rG82b7e822d005: [Demangle][Rust] Parse path backreferences (authored by tmiasko).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D103459/new/
https://reviews.llvm.org/D103459
Files:
llvm/include/llvm/Demangle/RustDemangle.h
llvm/lib/Demangle/RustDemangle.cpp
llvm/test/Demangle/rust.test
Index: llvm/test/Demangle/rust.test
===================================================================
--- llvm/test/Demangle/rust.test
+++ llvm/test/Demangle/rust.test
@@ -420,6 +420,22 @@
CHECK: _RIC4charKc1234567_E
_RIC4charKc1234567_E
+; Backreferences
+
+CHECK: backref::<backref::ident>
+ _RIC7backrefNvB0_5identE
+
+; Invalid backreferences
+
+CHECK: _RB_
+ _RB_
+
+CHECK: _RB5_
+ _RB5_
+
+CHECK: _RNvB_1a
+ _RNvB_1a
+
; Invalid mangled characters
CHECK: _RNvC2a.1c
Index: llvm/lib/Demangle/RustDemangle.cpp
===================================================================
--- llvm/lib/Demangle/RustDemangle.cpp
+++ llvm/lib/Demangle/RustDemangle.cpp
@@ -232,8 +232,12 @@
print(">");
break;
}
+ case 'B': {
+ bool IsOpen = false;
+ demangleBackref([&] { IsOpen = demanglePath(InType, LeaveOpen); });
+ return IsOpen;
+ }
default:
- // FIXME parse remaining productions.
Error = true;
break;
}
Index: llvm/include/llvm/Demangle/RustDemangle.h
===================================================================
--- llvm/include/llvm/Demangle/RustDemangle.h
+++ llvm/include/llvm/Demangle/RustDemangle.h
@@ -102,6 +102,21 @@
void demangleConstBool();
void demangleConstChar();
+ template <typename Callable> void demangleBackref(Callable Demangler) {
+ uint64_t Backref = parseBase62Number();
+ if (Error || Backref >= Position) {
+ Error = true;
+ return;
+ }
+
+ if (!Print)
+ return;
+
+ SwapAndRestore<size_t> SavePosition(Position, Position);
+ Position = Backref;
+ Demangler();
+ }
+
Identifier parseIdentifier();
uint64_t parseOptionalBase62Number(char Tag);
uint64_t parseBase62Number();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103459.350522.patch
Type: text/x-patch
Size: 1745 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210608/aa41bf40/attachment.bin>
More information about the llvm-commits
mailing list