This is an archive of the discontinued LLVM Phabricator instance.

[Demangle][Rust] Parse named types
ClosedPublic

Authored by tmiasko on May 16 2021, 2:24 AM.

Diff Detail

Event Timeline

tmiasko created this revision.May 16 2021, 2:24 AM
tmiasko requested review of this revision.May 16 2021, 2:24 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 16 2021, 2:24 AM
dblaikie added inline comments.May 16 2021, 10:06 AM
llvm/include/llvm/Demangle/RustDemangle.h
86–87

Could use a custom enum parameter here to avoid having to add a comment at every call site.

llvm/lib/Demangle/RustDemangle.cpp
424–437

Perhaps it'd be more appropriate to use look() here, then consume() in the if block below?

429–435

Rather than special casing a bunch of things here - especially if the consume->look change makes sense - could this code here use demanglePath unconditionally and let errors fall out of that naturally? (it'd match the grammar more closely, I think - avoid needing the implementation of <path> mixed up in the implementation of <type>)

I guess maybe that's not feasible - if some invalid basic type could then be interpreted as a path, even though it should be an invalid basic type instead?

llvm/test/Demangle/rust.test
141

These tests for <type> are using inherited impl whereas I think previous tests for <type> were using generic args. It'd be nice if they were consistent, I think? (so as not to raise questions/confusion about whether the context in which the type appears is significant to the testing of the type rule) (I don't mind which way they are consistent - if you'd rather change the previous tests over to use inherited impl so they're consistent with the new tests, or chan these new ones to use generic args - or both to some third thing (changing existing tests should be done in a preliminary/separate commit, though))

tmiasko updated this revision to Diff 345881.May 17 2021, 7:46 AM
tmiasko marked 4 inline comments as done.
  • Fall back to the path production without special casing.
  • Use an enum for InType.
  • Use generic arguments in tests instead of an inherent impl.
llvm/lib/Demangle/RustDemangle.cpp
424–437

In context of this changes using look() instead of consume() seems like an improvement, and I changed it accordingly.

Admittedly I will return to the previous approach when introducing additional type productions since each would have to consume the initial character otherwise.

llvm/test/Demangle/rust.test
141

Replaced with generic arguments for consistency. As additional benefit it emphasizes the distinction between demangling of generic arguments outside types where :: is included, and in types where it is omitted.

dblaikie accepted this revision.May 17 2021, 3:53 PM

Looks good, thanks!

This revision is now accepted and ready to land.May 17 2021, 3:53 PM
This revision was landed with ongoing or failed builds.May 18 2021, 3:12 PM
This revision was automatically updated to reflect the committed changes.