This is an archive of the discontinued LLVM Phabricator instance.

[AST][RecoveryExpr] Preserve the invalid "undef_var" initializer.
ClosedPublic

Authored by hokein on Jun 8 2020, 7:09 AM.

Details

Summary

And don't invalidate the VarDecl if the type is known.

Diff Detail

Event Timeline

hokein created this revision.Jun 8 2020, 7:09 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 8 2020, 7:09 AM
hokein marked an inline comment as done.Jun 8 2020, 7:10 AM
hokein added inline comments.
clang/include/clang/Sema/Sema.h
3900 ↗(On Diff #269218)

not quite happy with the naming, open for suggestions.

Very nice! Just want to give some thought to what these callsites look like.

clang/include/clang/Sema/Sema.h
3899 ↗(On Diff #269218)

This definitely seems like something that makes sense to call in more places. Wonder if the API can be smoother.

Both of the examples are of the form: CorrectDelayedTypos, if invalid, rebuildTypos.
Are *all* likely cases of this form? (Could make it an optional part of CorrectDelayedTypos)
Are there any places where you want CorrectDelayedTypos and don't want rebuild? (Could make it an eventually-mandatory part of CorrectDelayedTypos)

3900 ↗(On Diff #269218)

given current API, I'd suggest RecoverFromUncorrectedTypos or so

hokein marked an inline comment as done.Jun 9 2020, 4:28 AM
hokein added inline comments.
clang/include/clang/Sema/Sema.h
3899 ↗(On Diff #269218)

Are *all* likely cases of this form? (Could make it an optional part of CorrectDelayedTypos)

I think so (at least for the moment).

Are there any places where you want CorrectDelayedTypos and don't want rebuild? (Could make it an eventually-mandatory part of CorrectDelayedTypos)

yeah, I think the eventual goal is to make the rebuild as the default fallback when typo correction fails, but it is still too far away to do it at the moment -- many testcases are broken (some are crashes, some are diagnostics improvements) when turning on recovery-ast by default.

I suppose we'd need to fix that case by case until it is ready, given this situation, adding an option parameter (recoveryUncorrectedTypos) to CorrectDelayedTyposInExpr API seems a feasible solution.

hokein updated this revision to Diff 270746.Jun 15 2020, 7:31 AM

Make recovery fallback as part of the CorrectDelayedTyposInExpr.

sammccall accepted this revision.Jun 17 2020, 8:06 AM

LG once the overload set is fixed

clang/include/clang/Sema/Sema.h
3876 ↗(On Diff #270746)

I think it's too confusing to have multiple overloads with different subsets of the parameters possible and also in different orders :-(

If there's nothing better, you could replace this with two overloads

CorrectDelayedTyposInExpr(ER, Filter)
CorrectDelayedTyposInExpr(ER, bool, Filter)

clang/lib/Sema/SemaDecl.cpp
12042–12043

could consider splitting this change out of the refactoring (or vice versa), up to you

clang/lib/Sema/SemaExprCXX.cpp
8318 ↗(On Diff #270746)

/*RecoverUncorrectedTypos=*/

This revision is now accepted and ready to land.Jun 17 2020, 8:06 AM
hokein marked 5 inline comments as done.Jun 17 2020, 12:44 PM
hokein added inline comments.
clang/include/clang/Sema/Sema.h
3876 ↗(On Diff #270746)

This method doesn't have too many usages, I'd just remove it, which leaves us two overloads (one for Expr, the other one for ExprResult).

clang/lib/Sema/SemaDecl.cpp
12042–12043

split the refactoring change in https://reviews.llvm.org/D82047

(this looks reasonable now but it'd be nice to have a rebased diff!)

hokein updated this revision to Diff 271928.Jun 18 2020, 11:59 PM
hokein marked 2 inline comments as done.

rebase to head.

sammccall accepted this revision.Jun 19 2020, 1:12 AM
This revision was automatically updated to reflect the committed changes.