[cfe-commits] [Patch][libc++] Mark vector:: and string::empty() as warn_unused_result

Nico Weber thakis at chromium.org
Wed Apr 11 12:28:35 PDT 2012


Yes, pure is strictly better, attached :-)

Howard: I agree that it would be better if the frontend could figure
out automatically when a function is pure. However, that bug hasn't
seen any action in a over 10 months, so I figured this low-tech patch
could catch a few bugs until the better solution is implemented. I
only sent it out because I saw that bug twice recently and this patch
was easy to write. If you don't want to merge this, that's fine with
me. (We don't use libc++ yet anyway.)

Nico

On Wed, Apr 11, 2012 at 11:57 AM, Chris Lattner <clattner at apple.com> wrote:
>
> On Apr 10, 2012, at 8:49 PM, Nico Weber wrote:
>
>> Hi,
>>
>> the attached patch marks vector:: and string::empty() as
>> warn_unused_result. It looks like it's fairly often confused with
>> clear() in practice:
>>
>> https://breakpad.appspot.com/377003/
>> http://codereview.chromium.org/10034006/
>> http://www.viva64.com/en/a/0079/ (search for "empty")
>>
>> See also http://llvm.org/bugs/show_bug.cgi?id=10011 for a more general approach.
>
> Besides, wouldn't it be better to mark it as "pure"?
>
> -Chris
-------------- next part --------------
A non-text attachment was scrubbed...
Name: libcxx-pure.patch
Type: application/octet-stream
Size: 2163 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120411/5a9efc1d/attachment.obj>


More information about the cfe-commits mailing list