This is an archive of the discontinued LLVM Phabricator instance.

[Sema] Fix a use-after-deallocate of a ParsedAttr
ClosedPublic

Authored by erik.pilkington on Apr 1 2019, 3:26 PM.

Details

Summary

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

Thanks for taking a look!
Erik

Diff Detail

Repository
rC Clang

Event Timeline

erik.pilkington created this revision.Apr 1 2019, 3:26 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 1 2019, 3:26 PM
aaron.ballman accepted this revision.Apr 2 2019, 7:46 AM

LGTM aside from some minor nits. Thanks for this!

clang/include/clang/Sema/ParsedAttr.h
896 ↗(On Diff #193185)

How about Attrs and PA to fit with usual naming conventions?

clang/test/SemaObjC/arc-property-decl-attrs.m
291 ↗(On Diff #193185)

Can you add a comment here that explains what this test is intending to cover?

This revision is now accepted and ready to land.Apr 2 2019, 7:46 AM
This revision was automatically updated to reflect the committed changes.