This also reverts 282cae0b9a602267ad7ef622f770066491332a11 as the
particular crash is now handled by the new code.
Before this change Clang would always leave declarations inside the
type-locs as null if the declarator had an invalid type. This patch
populates declarations even for invalid types if the structure of the
type and the type-locs match.
There are certain cases that may still cause crashes. These happen when
Clang recovers the type in a way that is not reflected in the
declarator's structure, e.g. adding a pointer when it was not present in
the code for ObjC interfaces or ignoring pointers written in the code
in C++ with auto return type (auto* foo() -> int). Those cases look
fixable with a better recovery strategy and I plan to follow up with
more patches to address those.
The first attempt caused 31 tests from check-clang to crash due to
different structure of the types and type-locs after certain errors. The
good news is that the failure is localized and mismatch in structures is
discovered by assertions inside DeclaratorLocFiller. Some notable
cases caught by existing tests:
- Invalid chunks when type is fully ignored and replace with int or now. Crashed in C/C2x/n2838.c.
- Invalid return types in lambdas. Crashed in CXX/drs/dr6xx.cpp.
- Invalid member pointers. Crashed in CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3-generic-lambda-1y.cpp
- ObjC recovery that adds pointers. Crashed in SemaObjC/blocks.m
This change also updates the output of Index/complete-blocks.m.
Not entirely sure what causes the change, but the new function signature
is closer to the source code, so this seems like an improvement.