[PATCH] SemaCXX: Support templates in availability attributes

Duncan P. N. Exon Smith via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 22 18:19:09 PST 2016

> On 2016-Feb-22, at 17:24, Manman Ren <mren at apple.com> wrote:
>> On Feb 8, 2016, at 8:17 PM, Duncan P. N. Exon Smith <dexonsmith at apple.com> wrote:
>> This patch adds support for templates in availability attributes.
>> - If the context for an availability diagnostic is a
>>   `FunctionTemplateDecl`, look through it to the `FunctionDecl`.
>> AvailabilityResult Decl::getAvailability(std::string *Message) const {
>> +  if (auto *FTD = dyn_cast<FunctionTemplateDecl>(this))
>> +    return FTD->getTemplatedDecl()->getAvailability(Message);
>> +
>>   AvailabilityResult Result = AR_Available;
> This looks generally correct to me.
> The UnavailableAttr is attached to the FunctionDecl, not the FunctionTemplateDecl, so looking through sounds right.
>> - Add `__has_feature(attribute_availability_in_templates)`.
>> Is there anything else I should be testing to be sure availability
>> works correctly in templates?
> Maybe
> test<UnavailableClass>()
> calling unavailable function from an unavailable template function
> calling an unavailable template function
> I think these all work with the current compiler. But I am not sure if we have existing test coverage.

Thanks for the ideas; let me know if you have any others.

Can you have a look at the new patch?

> Cheers,
> Manman
>> I'm working on a patch to add
>> availability markup to the libc++ headers, and this is the only
>> problem I've hit so far.  Anyone have thoughts on other things I
>> should test?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-SemaCXX-Support-templates-in-availability-attributes.patch
Type: application/octet-stream
Size: 5731 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160222/a653d4c5/attachment.obj>

More information about the cfe-commits mailing list