This is an archive of the discontinued LLVM Phabricator instance.

[AST] Produce ReturnStmt containing RecoveryExpr when type is wrong
ClosedPublic

Authored by sammccall on Dec 30 2021, 8:31 AM.

Details

Summary

Previously we just drop the ReturnStmt and its argument from the AST,
which blocks analysis of broken code.

Fixes https://github.com/llvm/llvm-project/issues/39944

Diff Detail

Event Timeline

sammccall requested review of this revision.Dec 30 2021, 8:31 AM
sammccall created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptDec 30 2021, 8:31 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
sammccall updated this revision to Diff 396680.Dec 30 2021, 8:34 AM

Add evaluation test

sammccall added a comment.EditedDec 30 2021, 8:35 AM

No changes to constant evaluation needed. This is expected as these patterns already exist today: return undef(); produces a RecoveryExpr and return; is preserved in the AST with no value even for non-void functions.

hokein accepted this revision.Jan 4 2022, 5:21 AM

Thanks, this looks great.

clang/lib/Sema/SemaStmt.cpp
4037–4042

iniializers => inializers

clang/test/AST/ast-dump-recovery.cpp
365

nit: I would check the function-decl is invalid as well (this is important).

This revision is now accepted and ready to land.Jan 4 2022, 5:21 AM
This revision was landed with ongoing or failed builds.Jan 4 2022, 8:08 AM
This revision was automatically updated to reflect the committed changes.
sammccall marked 2 inline comments as done.