This is an archive of the discontinued LLVM Phabricator instance.

[Parse] Don't speculatively parse an identifier in the wrong context.
AbandonedPublic

Authored by efriedma on Oct 10 2019, 6:21 PM.

Details

Reviewers
rsmith
Summary

When we see something like i<i, we try to check whether the second "i" refers to a type. However, when we do this, we can end up creating an expression in the wrong context: the "<" has different parse priority if it's actually a relational operator.

To fix the issue, just remove the check. This makes diagnostics slightly worse, but avoids the crash. I'm not really happy with this, but I don't see another way to fix this without implementing a giant refactoring.

Fixes https://bugs.llvm.org/show_bug.cgi?id=43080 (but not the issues currently marked as "duplicate"; I haven't dug deeply into the causes of those issues).

Diff Detail

Repository
rC Clang

Event Timeline

efriedma created this revision.Oct 10 2019, 6:21 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 10 2019, 6:21 PM

It looks like it's not actually all that complex to defer building the expression until we're ready to consume the annotation. I've got a mostly-complete patch for that, and I'd like to try finishing that before we add workarounds.

https://reviews.llvm.org/D68896 for the patch to defer forming the Expr until it's consumed. This is still not right for implicit member access, but I think that's feasible to fix too (if a little awkward).

efriedma abandoned this revision.Oct 14 2019, 3:28 PM