This is an archive of the discontinued LLVM Phabricator instance.

Fix incorrect parsing of arguments for nested functions
ClosedPublic

Authored by arseny.kapoulkine on Sep 26 2015, 12:19 AM.

Details

Reviewers
mclow.lists
Summary

For nested functions, local-name can be followed by function arguments; in
some cases the first argument starts with a digit (if it's a named type).

For example, this code:

void test() { struct g { void foo(Point p); }; }

Generates this name for symbol foo:

_ZZ4testvEN1g3fooE5Point

When decomposed, this results in a local-name with entity name N1g3fooE
(aka g::foo). According to Itanium ABI, entity name can be followed by
a discriminator that has to start with _.

However, libcxxabi defines an extension that says that discriminator can start
with a digit. This makes the grammar ambiguous, and causes 5 to be skipped and
Point to be parsed as a series of types for function arguments.

Resolve ambiguity by requiring that a digit-only discriminator is the last
token in the input string.

Diff Detail

Event Timeline

arseny.kapoulkine retitled this revision from to Fix incorrect parsing of arguments for nested functions.
arseny.kapoulkine updated this object.
arseny.kapoulkine added a subscriber: cfe-commits.
mclow.lists accepted this revision.Oct 7 2015, 2:31 PM
mclow.lists edited edge metadata.

This looks fine to me. Thanks for the patch (and the test case).

This revision is now accepted and ready to land.Oct 7 2015, 2:31 PM
mclow.lists closed this revision.Oct 12 2015, 1:51 PM

landed as revision 249649