[all-commits] [llvm/llvm-project] 9a5f38: [AST] Pick last tentative definition as the acting...

Benson Chu via All-commits all-commits at lists.llvm.org
Tue Aug 24 06:52:13 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 9a5f3888505630cea88f8372d3068b2d63cfb381
      https://github.com/llvm/llvm-project/commit/9a5f3888505630cea88f8372d3068b2d63cfb381
  Author: Benson Chu <bensonchu457 at gmail.com>
  Date:   2021-08-24 (Tue, 24 Aug 2021)

  Changed paths:
    M clang/lib/AST/Decl.cpp
    A clang/test/CodeGen/attr-tentative-definition.c

  Log Message:
  -----------
  [AST] Pick last tentative definition as the acting definition

Clang currently picks the second tentative definition when
VarDecl::getActingDefinition is called.

This can lead to attributes being dropped if they are attached to
tentative definitions that appear after the second one. This is
because VarDecl::getActingDefinition loops through VarDecl::redecls
assuming that the last tentative definition is the last element in the
iterator. However, it is the second element that would be the last
tentative definition.

This changeset modifies getActingDefinition to iterate through the
declaration chain in reverse, so that it can immediately return when
it encounters a tentative definition.

Differential Revision: https://reviews.llvm.org/D99732




More information about the All-commits mailing list