[all-commits] [llvm/llvm-project] 304d73: [clang][Sema] Fix uninitialized `SourceLocation` f...

Volodymyr Sapsai via All-commits all-commits at lists.llvm.org
Wed Jan 18 14:16:18 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 304d7307aee15b6eb88d198ae94b595f4e09f485
      https://github.com/llvm/llvm-project/commit/304d7307aee15b6eb88d198ae94b595f4e09f485
  Author: Volodymyr Sapsai <vsapsai at apple.com>
  Date:   2023-01-18 (Wed, 18 Jan 2023)

  Changed paths:
    M clang/lib/Sema/SemaType.cpp
    M clang/unittests/AST/SourceLocationTest.cpp

  Log Message:
  -----------
  [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




More information about the All-commits mailing list