[all-commits] [llvm/llvm-project] a9db0a: [AST] Fix the EndLoc calculation for ObjCObjectPoi...

Luke Petre via All-commits all-commits at lists.llvm.org
Tue Oct 26 11:03:53 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: a9db0a804a5335b6534995c54ab9d6fcef06e739
      https://github.com/llvm/llvm-project/commit/a9db0a804a5335b6534995c54ab9d6fcef06e739
  Author: Luke Petre <lpetre at gmail.com>
  Date:   2021-10-26 (Tue, 26 Oct 2021)

  Changed paths:
    M clang/lib/AST/TypeLoc.cpp
    M clang/test/AST/ast-dump-decl.mm

  Log Message:
  -----------
  [AST] Fix the EndLoc calculation for ObjCObjectPointer

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




More information about the All-commits mailing list