This is an archive of the discontinued LLVM Phabricator instance.

[AST][RecoveryExpr] Make DeduceAutoType fail if the auto is deduced from recovery exprs.
ClosedPublic

Authored by hokein on May 19 2020, 9:42 AM.

Details

Summary

With recovery-ast, we will get an undeduced auto return type for
"auto foo()->undef()" function declaration, the function decl still keeps
valid, it is dangerous, and breaks assumptions in clang, and leads crashes.

This patch invalidates these functions, if we deduce autos from the
return rexpression, which is similar to auto VarDecl.

Diff Detail

Event Timeline

hokein created this revision.May 19 2020, 9:42 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 19 2020, 9:42 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
hokein updated this revision to Diff 264951.May 19 2020, 9:45 AM

small update

hokein marked an inline comment as done.May 19 2020, 9:47 AM
hokein added inline comments.
clang/test/AST/ast-dump-recovery.cpp
182

with this patch, we don't preserve the return stmt, so we only have the CXXRecordDecl for the lambda, and no TypeAliasDecl node.

hokein added a subscriber: rsmith.

Friendly ping, in case it is out of your radar -- this fixes another recovery-ast crash-on-invalid.

sammccall accepted this revision.May 28 2020, 9:32 AM
sammccall added inline comments.
clang/lib/Sema/SemaTemplateDeduction.cpp
4658

it's not clear to me what "if the type is known" means precisely.
If it's just a matter of checking some condition and continuing, presumably we'd do that already. as is, the FIXME doesn't seem actionable.

clang/test/AST/ast-dump-invalid-auto-return-funcs.cpp
4

maybe add a comment/FIXME about why we're finding int as the return type?

This revision is now accepted and ready to land.May 28 2020, 9:32 AM
hokein updated this revision to Diff 267137.May 29 2020, 12:53 AM
hokein marked 2 inline comments as done.

address comments.

This revision was automatically updated to reflect the committed changes.