There is an issue where the AST code does not compute the correct SourceRange for a ObjCObjectPointer.
From Richard Smith (ie @zygoloid) in discord:
I think the problem is that we set an invalid location for the * (because there isn't one): https://github.com/llvm/llvm-project/blob/main/clang/lib/Sema/SemaType.cpp#L1121
And then we use the default getLocalSourceRangeImpl for a PointerLikeTypeLoc that just assumes the * location is the type's end location: https://github.com/llvm/llvm-project/blob/main/clang/include/clang/AST/TypeLoc.h#L1293
Possibly we should be special-casing that here: https://github.com/llvm/llvm-project/blob/main/clang/lib/AST/TypeLoc.cpp#L228
My change:
- introduces a AST dump test to show the issue in the first commit
- special cases ObjCObjectPointerType in the second commit to correctly compute the end location