[cfe-commits] r120872 - in /cfe/trunk: lib/Sema/SemaDeclAttr.cpp test/Sema/warn-unused-function.c
rjmccall at apple.com
Mon Dec 6 10:12:32 PST 2010
On Dec 6, 2010, at 10:06 AM, Argyrios Kyrtzidis wrote:
> On Dec 5, 2010, at 8:33 PM, John McCall wrote:
>> On Dec 3, 2010, at 5:12 PM, Argyrios Kyrtzidis wrote:
>>> Author: akirtzidis
>>> Date: Fri Dec 3 19:12:11 2010
>>> New Revision: 120872
>>> URL: http://llvm.org/viewvc/llvm-project?rev=120872&view=rev
>>> Mark functions referenced by 'cleanup' attribute as used. Fixes rdar://8728293
>>> Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=120872&r1=120871&r2=120872&view=diff
>>> --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
>>> +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Fri Dec 3 19:12:11 2010
>>> @@ -1450,6 +1450,7 @@
>>> d->addAttr(::new (S.Context) CleanupAttr(Attr.getLoc(), S.Context, FD));
>>> + FD->setUsed();
>> Technically, you can use __attribute__((cleanup)) inside a template. This should use MarkDeclarationReferenced, and then there should be special instantiation logic for the attribute.
> Hmm, is this really the right approach ? If it's referenced from a template which is not instantiated, it's not used from the codegen perspective but how about from the user's perspective:
> -We emit a warning that the function 'foo' is unused.
> -User removes function 'foo'
> -Now we emit an error that 'foo' is not found.
Oh, you mean if a function is referenced from a template definition that's never instantiated? Yeah, that's a valid user complaint. That's not specific to attribute((cleanup)), though; any reference without dependent ADL will have that issue.
More information about the cfe-commits