1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 10:42:39 +01:00

[Demangle][Rust] Parse path backreferences

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D103459
This commit is contained in:
Tomasz Miąsko 2021-06-07 23:34:34 +02:00
parent fcb88533b1
commit 1dcdf007c2
3 changed files with 36 additions and 1 deletions

View File

@ -102,6 +102,21 @@ private:
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();

View File

@ -232,8 +232,12 @@ bool Demangler::demanglePath(InType InType, LeaveOpen LeaveOpen) {
print(">");
break;
}
case 'B': {
bool IsOpen = false;
demangleBackref([&] { IsOpen = demanglePath(InType, LeaveOpen); });
return IsOpen;
}
default:
// FIXME parse remaining productions.
Error = true;
break;
}

View File

@ -420,6 +420,22 @@ CHECK: char::<'\u{10ffff}'>
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