[Sema] Fix a use-after-deallocate of a ParsedAttr
authorErik Pilkington <erik.pilkington@gmail.com>
Tue, 2 Apr 2019 19:48:11 +0000 (19:48 +0000)
committerErik Pilkington <erik.pilkington@gmail.com>
Tue, 2 Apr 2019 19:48:11 +0000 (19:48 +0000)
commitaf913156685a910c4930c40e72a4f641f268a83f
treed12ec96cb15a9c60d16b8eb22e595d5682f82f19
parent3299ead8e9ff3d65ff133518d4df84dc2a424c72
[Sema] Fix a use-after-deallocate of a ParsedAttr

moveAttrFromListToList only makes sense when moving an attribute to a list with
a pool that's either equivalent, or has a shorter lifetime. Therefore, using it
to move a ParsedAttr from a declarator to a declaration specifier doesn't make
sense, since the declaration specifier's pool outlives the declarator's. The
patch adds a new function, ParsedAttributes::takeOneFrom, which transfers the
attribute from one pool to another, fixing the use-after-deallocate.

rdar://49175426

Differential revision: https://reviews.llvm.org/D60101

llvm-svn: 357516
clang/include/clang/Sema/ParsedAttr.h
clang/lib/Sema/SemaType.cpp
clang/test/SemaObjC/arc-property-decl-attrs.m