[cfe-commits] r133173 - in /cfe/trunk: include/clang/Sema/Sema.h lib/Sema/SemaChecking.cpp test/SemaCXX/warn-bad-memaccess.cpp

Douglas Gregor dgregor at apple.com
Thu Jun 16 11:15:05 PDT 2011


On Jun 16, 2011, at 11:08 AM, Nico Weber wrote:

> Thanks!
> 
> On Thu, Jun 16, 2011 at 10:56 AM, Douglas Gregor <dgregor at apple.com> wrote:
>> Author: dgregor
>> Date: Thu Jun 16 12:56:04 2011
>> New Revision: 133173
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=133173&view=rev
>> Log:
>> Teach the warning about non-POD memset/memcpy/memmove to deal with the
>> __builtin_ versions of these functions as well as the normal function
>> versions, so that it works on platforms where memset/memcpy/memmove
>> are macros that map down to the builtins (e.g., Darwin). Fixes
>> <rdar://problem/9372688>.
> 
> Out of idle curiosity, what's the radar about?

It's about warning when memcpy/memmove'ing lifetime-qualified objects in Objective-C ARC, e.g.,

  void f(__strong id dest[], __strong id source[], int n) {
  memcpy(dest, source, n * sizeof(__strong id));
} 

should (and now does) produce:

t.m:5:3: warning: destination for this '__builtin___memcpy_chk' call is a
      pointer to lifetime-qualified type '__strong id' [-Wnon-pod-memaccess]
  memcpy(dest, source, n * sizeof(__strong id));
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
t.m:5:10: note: instantiated from:
  memcpy(dest, source, n * sizeof(__strong id));
         ^
t.m:5:3: note: explicitly cast the pointer to silence this warning

The actual warning came in with ARC yesterday, but it didn't work properly without r133173.

	- Doug



More information about the cfe-commits mailing list