This is an archive of the discontinued LLVM Phabricator instance.

Add a version of the pass_object_size attribute that works with builtin_dynamic_object_size
ClosedPublic

Authored by erik.pilkington on Feb 27 2019, 8:21 PM.

Details

Summary

This attribute, named pass_dynamic_object_size has the same semantics as pass_object_size, except that it calls __builtin_dynamic_object_size at the caller instead of __builtin_object_size. You can read more about __builtin_dynamic_object_size here: https://clang.llvm.org/docs/LanguageExtensions.html#evaluating-object-size-dynamically, it was introduced in D56760.

rdar://48208787

Thanks for taking a look!
Erik

Diff Detail

Repository
rC Clang

Event Timeline

aaron.ballman added inline comments.Mar 6 2019, 8:08 AM
clang/include/clang/Basic/Attr.td
1570 ↗(On Diff #188666)

Why use a separate attribute as opposed to a separate spelling and an accessor on PassObjectSizeAttr to ask whether it's dynamic or not? The two attributes seem to have identical semantics aside from which builtin is called, so I think it makes sense to use the same semantic attribute type.

clang/lib/Sema/SemaDeclAttr.cpp
1108 ↗(On Diff #188666)

Please do not add a parameter here -- we keep all of the handleFooAttr() function signatures the same because some day we'd like to refactor the switch to be more tablegenerated as well.

1140 ↗(On Diff #188666)

Elide braces here and below.

erik.pilkington marked 4 inline comments as done.

Address review comments.

clang/include/clang/Basic/Attr.td
1570 ↗(On Diff #188666)

Oh, I didn't even know that was possible. I guess thats why Spellings is an array :). That simplifies the implementation too, now we can ditch getPassObjectSizeInfo.

This revision is now accepted and ready to land.Mar 19 2019, 12:37 PM
This revision was automatically updated to reflect the committed changes.