This is an archive of the discontinued LLVM Phabricator instance.

[libcxxabi][demangler] Clean up and llvm-ify the expression parser
ClosedPublic

Authored by erik.pilkington on Jan 9 2018, 3:43 PM.

Details

Summary

As of https://reviews.llvm.org/D41885, every parse_* function now either returns a single Node* or fails. I'm using this new rule to clean up the parsing for the demangler, and also update it to use LLVM coding conventions. This patch updates the expression parser. The expression grammer is pretty simple, so this patch is a pretty mechanical transformation.

In the new parser:

  • The position in the mangled name is held in Db, and is accessed by Db::look() and Db::consume() functions
  • Parse functions now return a Node* directly instead of pushing a node onto the Name stack and having their caller immediately pop it off.
  • Failed to parse mean the parse functions returns nullptr.
  • LLVM style.

Thanks for taking a look!
Erik

Diff Detail

Repository
rL LLVM

Event Timeline

erik.pilkington created this revision.Jan 9 2018, 3:43 PM

Rebase onto r323906. Most of this patch is just a mechanical transformation to the parser to use the new API, the interesting part is just the changes to the Db struct.

dexonsmith accepted this revision.Jan 31 2018, 2:45 PM

LGTM.

src/cxa_demangle.cpp
1992 ↗(On Diff #132279)

I think clang-format would place the * and & differently. Should you rerun clang-format-diff.py?

This revision is now accepted and ready to land.Jan 31 2018, 2:45 PM
This revision was automatically updated to reflect the committed changes.