When -fsanitize-address-field-padding=1 is present
don't emit memcpy for copy constructor.
Thanks Nico for the extra test case.
Details
Details
Diff Detail
Diff Detail
Event Timeline
Comment Actions
Sorry about the slow review.
Rather than adding all these checks before calling EmitAggregateCopy(), is it maybe possible to do this check in EmitAggregateCopy() itself? Else there will always be cases that you miss. For example:
$ cat foo.cc struct ClassWithTrivialCopy { ClassWithTrivialCopy(); ~ClassWithTrivialCopy(); void *a; private: void *c; }; struct NontrivialCopy { NontrivialCopy(const NontrivialCopy&); }; struct pair { NontrivialCopy nc; ClassWithTrivialCopy second[4]; pair(const pair&) = default; }; void MakeTrivialCopy( const pair &p) { pair p2(p); } $ bin/clang -c foo.cc -std=c++11 -fsanitize=address -fsanitize-address-field-padding=1 -emit-llvm -S -o - | grep memcpy %68 = call i8* @__asan_memcpy(i8* %66, i8* %67, i64 128) declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture readonly, i64, i32, i1) #4 declare i8* @__asan_memcpy(i8*, i8*, i64)