[llvm] 89615a5 - [Demangle][Rust] Parse dyn-bounds

Tomasz Miąsko via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 7 09:25:26 PDT 2021


Author: Tomasz Miąsko
Date: 2021-06-07T18:18:30+02:00
New Revision: 89615a5e925e10f388130e80fba4bf28bc3c3c0a

URL: https://github.com/llvm/llvm-project/commit/89615a5e925e10f388130e80fba4bf28bc3c3c0a
DIFF: https://github.com/llvm/llvm-project/commit/89615a5e925e10f388130e80fba4bf28bc3c3c0a.diff

LOG: [Demangle][Rust] Parse dyn-bounds

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D103151

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 a57f4d09bf73..8158787b47ba 100644
--- a/llvm/include/llvm/Demangle/RustDemangle.h
+++ b/llvm/include/llvm/Demangle/RustDemangle.h
@@ -89,6 +89,7 @@ class Demangler {
   void demangleGenericArg();
   void demangleType();
   void demangleFnSig();
+  void demangleDynBounds();
   void demangleOptionalBinder();
   void demangleConst();
   void demangleConstInt();

diff  --git a/llvm/lib/Demangle/RustDemangle.cpp b/llvm/lib/Demangle/RustDemangle.cpp
index d6cf78bb654e..04bc175c3b82 100644
--- a/llvm/lib/Demangle/RustDemangle.cpp
+++ b/llvm/lib/Demangle/RustDemangle.cpp
@@ -480,6 +480,17 @@ void Demangler::demangleType() {
   case 'F':
     demangleFnSig();
     break;
+  case 'D':
+    demangleDynBounds();
+    if (consumeIf('L')) {
+      if (auto Lifetime = parseBase62Number()) {
+        print(" + ");
+        printLifetime(Lifetime);
+      }
+    } else {
+      Error = true;
+    }
+    break;
   default:
     Position = Start;
     demanglePath(rust_demangle::InType::Yes);
@@ -529,6 +540,16 @@ void Demangler::demangleFnSig() {
   }
 }
 
+// <dyn-bounds> = [<binder>] {<dyn-trait>} "E"
+void Demangler::demangleDynBounds() {
+  SwapAndRestore<size_t> SaveBoundLifetimes(BoundLifetimes, BoundLifetimes);
+  print("dyn ");
+  demangleOptionalBinder();
+  // FIXME demangle {dyn-trait}
+  if (!consumeIf('E'))
+    Error = true;
+}
+
 // Demangles optional binder and updates the number of bound lifetimes.
 //
 // <binder> = "G" <base-62-number>

diff  --git a/llvm/test/Demangle/rust.test b/llvm/test/Demangle/rust.test
index c13d8f5d4e8b..caded76e11be 100644
--- a/llvm/test/Demangle/rust.test
+++ b/llvm/test/Demangle/rust.test
@@ -232,6 +232,22 @@ CHECK: function::<extern "cdecl" fn()>
 CHECK: function::<unsafe extern "C-cmse-nonsecure-call" fn()>
        _RIC8functionFUK21C_cmse_nonsecure_callEuE
 
+; Trait objects
+
+CHECK: trait::<dyn >
+       _RIC5traitDEL_E
+
+CHECK: trait::<dyn for<'a> >
+       _RIC5traitDG_EL_E
+
+CHECK: trait::<for<'a> fn(dyn for<'b> + 'a)>
+       _RIC5traitFG_DG_EL0_EuE
+
+; Invalid trait object, missing lifetime.
+
+CHECK: _RIC5traitDEE
+       _RIC5traitDEE
+
 ; Binders
 
 CHECK: binders::<for<'a> fn(&'a _)>


        


More information about the llvm-commits mailing list