[PATCH] D104366: [Demangle][Rust] Parse non-ASCII identifiers

David Blaikie via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 28 16:21:01 PDT 2021


dblaikie accepted this revision.
dblaikie added a comment.

I haven't looked in detail at the punycode implementation - I guess this'll get some workout when tested against rust's output (leaving some chance of symmetric encode/decode bugs) & that's probably good enough.



================
Comment at: libcxxabi/src/demangle/Utility.h:129
 
+  void insert(size_t Pos, const char *S, size_t N) {
+    assert(Pos <= CurrentPosition);
----------------
Could use an `Arrayref<const char>` (Or `StringRef`) instead of separate `const char *` and `size_t` parameters. Not necessary, there's some value in the symmetry with standard library functions (though I guess they're more likely to use begin/end rather than begin/length), etc.


================
Comment at: libcxxabi/src/demangle/Utility.h:131-136
+    if (N > 0) {
+      grow(N);
+      std::memmove(Buffer + Pos + N, Buffer + Pos, CurrentPosition - Pos);
+      std::memcpy(Buffer + Pos, S, N);
+      CurrentPosition += N;
+    }
----------------
I'd probably use an early return here to reduce indentation.


================
Comment at: llvm/lib/Demangle/RustDemangle.cpp:547-548
       Identifier Ident = parseIdentifier();
+      if (Ident.Punycode)
+        Error = true;
       for (char C : Ident.Name) {
----------------
Is this error path tested?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104366/new/

https://reviews.llvm.org/D104366



More information about the llvm-commits mailing list