diff options
author | Tomasz Miąsko <tomasz.miasko@gmail.com> | 2021-06-07 18:14:06 +0200 |
---|---|---|
committer | Tomasz Miąsko <tomasz.miasko@gmail.com> | 2021-06-07 18:18:31 +0200 |
commit | 619a65e5e4ed0df7b753eac9d7d41be976fd909b (patch) | |
tree | 6a65b809095b294cfec4912ffafd71a8b26882d2 /llvm/lib/Demangle/RustDemangle.cpp | |
parent | 1499afa09ba27ee0e6569668b74fea40e0458930 (diff) | |
download | llvm-619a65e5e4ed0df7b753eac9d7d41be976fd909b.zip llvm-619a65e5e4ed0df7b753eac9d7d41be976fd909b.tar.gz llvm-619a65e5e4ed0df7b753eac9d7d41be976fd909b.tar.bz2 |
[Demangle][Rust] Parse dyn-trait-assoc-binding
Reviewed By: dblaikie
Differential Revision: https://reviews.llvm.org/D103364
Diffstat (limited to 'llvm/lib/Demangle/RustDemangle.cpp')
-rw-r--r-- | llvm/lib/Demangle/RustDemangle.cpp | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/llvm/lib/Demangle/RustDemangle.cpp b/llvm/lib/Demangle/RustDemangle.cpp index cbb52fa..9513a00 100644 --- a/llvm/lib/Demangle/RustDemangle.cpp +++ b/llvm/lib/Demangle/RustDemangle.cpp @@ -121,7 +121,10 @@ bool Demangler::demangle(StringView Mangled) { return !Error; } -// Demangles a path. InType indicates whether a path is inside a type. +// Demangles a path. InType indicates whether a path is inside a type. When +// LeaveOpen is true, a closing `>` after generic arguments is omitted from the +// output. Return value indicates whether generics arguments have been left +// open. // // <path> = "C" <identifier> // crate root // | "M" <impl-path> <type> // <T> (inherent impl) @@ -135,10 +138,10 @@ bool Demangler::demangle(StringView Mangled) { // | "S" // shim // | <A-Z> // other special namespaces // | <a-z> // internal namespaces -void Demangler::demanglePath(InType InType) { +bool Demangler::demanglePath(InType InType, LeaveOpen LeaveOpen) { if (Error || RecursionLevel >= MaxRecursionLevel) { Error = true; - return; + return false; } SwapAndRestore<size_t> SaveRecursionLevel(RecursionLevel, RecursionLevel + 1); @@ -220,7 +223,10 @@ void Demangler::demanglePath(InType InType) { print(", "); demangleGenericArg(); } - print(">"); + if (LeaveOpen == rust_demangle::LeaveOpen::Yes) + return true; + else + print(">"); break; } default: @@ -228,6 +234,8 @@ void Demangler::demanglePath(InType InType) { Error = true; break; } + + return false; } // <impl-path> = [<disambiguator>] <path> @@ -555,8 +563,20 @@ void Demangler::demangleDynBounds() { // <dyn-trait> = <path> {<dyn-trait-assoc-binding>} // <dyn-trait-assoc-binding> = "p" <undisambiguated-identifier> <type> void Demangler::demangleDynTrait() { - demanglePath(InType::Yes); - // FIXME demangle {<dyn-trait-assoc-binding>} + bool IsOpen = demanglePath(InType::Yes, LeaveOpen::Yes); + while (!Error && consumeIf('p')) { + if (!IsOpen) { + IsOpen = true; + print('<'); + } else { + print(", "); + } + print(parseIdentifier().Name); + print(" = "); + demangleType(); + } + if (IsOpen) + print(">"); } // Demangles optional binder and updates the number of bound lifetimes. |