[all-commits] [llvm/llvm-project] 6184e5: [demangler][NFC] Refactor some parsing
Nathan Sidwell via All-commits
all-commits at lists.llvm.org
Mon Jan 24 05:31:28 PST 2022
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 6184e565ad4065026bc121fd13d6a8743a1fe593
https://github.com/llvm/llvm-project/commit/6184e565ad4065026bc121fd13d6a8743a1fe593
Author: Nathan Sidwell <nathan at acm.org>
Date: 2022-01-24 (Mon, 24 Jan 2022)
Changed paths:
M libcxxabi/src/demangle/ItaniumDemangle.h
M libcxxabi/test/test_demangle.pass.cpp
M llvm/include/llvm/Demangle/ItaniumDemangle.h
Log Message:
-----------
[demangler][NFC] Refactor some parsing
There's some unnecessary code duplication in the parser. This
refactors that and deploys boolean variables to avoid the duplication.
These also happen to help adding module demangling (with an updated
mangling scheme).
1a) The grammar requires some lookahead concerning <template-args>. We
may discover an <unscoped-name> is actually <unscoped-template-name>
<template-args>. (When <unscoped-name> was a substitution, there must
be a following <template-args>.) Refactor parseName to only have one
code path looking for the 'I' indicating <template-args>.
1b) While there I altered the control flow to hold the result in a
variable, rather than tail call. Made it easier to debug (and of
course an optimizer will DTRT here anyway).
2a) An <unscoped-name> can have an St or StL prefix. No need for
completely separate code paths handling the following unqualified-name
though.
2b) Also no need to look for both 'St' and 'StL' separately. Look for
'St' and then conditionally swallow an 'L'.
3) We get a similar issue as #1a when parsing a typeName. Here I just
change the control flow slightly to bring the 'break' out to the end
of the 'S' block and embed the early return inside an if. That's more
in keeping with the code style.
4) Although NFC, there's a new testcase as that's not covered by the
existing demangler tests and is significant in the #1a case above.
Reviewed By: ChuanqiXu
Differential Revision: https://reviews.llvm.org/D117879
More information about the All-commits
mailing list