[clang][Sema] Fix uninitialized `SourceLocation` for types with multiple attributes...
authorVolodymyr Sapsai <vsapsai@apple.com>
Tue, 10 Jan 2023 20:41:11 +0000 (12:41 -0800)
committerVolodymyr Sapsai <vsapsai@apple.com>
Wed, 18 Jan 2023 22:15:53 +0000 (16:15 -0600)
commit304d7307aee15b6eb88d198ae94b595f4e09f485
tree8925002ec068a9f822e14c3596b2461dd44ece55
parentd3da9067d143f3d4ce59b6d9ab4606a8ef1dc937
[clang][Sema] Fix uninitialized `SourceLocation` for types with multiple attributes and macros.

Some `TypeLoc`s are considered "sugar" and we go past them in
`GetTypeSourceInfoForDeclarator`. The problem is that we peel off only
the same kind of `TypeLoc` at the time which makes it impossible to
handle mixed sequences like
`AttributedTypeLoc - MacroQualifiedTypeLoc - AttributedTypeLoc - PointerTypeLoc`

In this situation, as shown in the added test, we don't get to
`PointerTypeLoc` and don't set its starLoc leaving it uninitialized.

Address FIXME and peel off "sugar" `TypeLoc`s regardless of their order.

rdar://102149264

Differential Revision: https://reviews.llvm.org/D141424
clang/lib/Sema/SemaType.cpp
clang/unittests/AST/SourceLocationTest.cpp