More robust fix for crash on invalid range-based for statement.
authorRichard Smith <richard@metafoo.co.uk>
Mon, 8 Jun 2020 18:52:14 +0000 (11:52 -0700)
committerRichard Smith <richard@metafoo.co.uk>
Mon, 8 Jun 2020 20:11:23 +0000 (13:11 -0700)
commit58f831d2b3885bbbc2366045e46211c507fa5f8b
tree1fa5b9953ca49412ce58aeab857b921d0f84e554
parent775ef44514b333ad042bea37204323bff295643e
More robust fix for crash on invalid range-based for statement.

Reliably mark the loop variable declaration in a range for as having an
invalid initializer if anything goes wrong building the initializer. We
previously based this determination on whether an error was emitted,
which is not a reliable signal due to error suppression (during error
recovery etc).

Also, properly mark the variable as having initializer errors rather
than simply marking it invalid. This is necessary to mark any structured
bindings as invalid too.

This generalizes the previous fix in
936ec89e91e2dda8b6110b1fd1f9920509d7a17b.
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaStmt.cpp
clang/lib/Sema/TreeTransform.h
clang/test/SemaCXX/cxx11-crashes.cpp
clang/test/SemaCXX/for-range-crash.cpp