[PATCH] [clang/asan] Do not emit memcpy for trivial operator= when -fsanitize-address-field-padding >= 1
Kostya Serebryany
kcc at google.com
Tue Nov 11 15:28:36 PST 2014
================
Comment at: lib/CodeGen/CGExprCXX.cpp:321
@@ -320,3 +320,3 @@
if ((MD->isCopyAssignmentOperator() || MD->isMoveAssignmentOperator()) &&
- MD->isTrivial()) {
+ MD->isTrivial() && !MD->getParent()->mayInsertExtraPadding()) {
llvm::Value *Src = EmitLValue(E->getArg(1)).getAddress();
----------------
rsmith wrote:
> Is `mayInsertExtraPadding` ever `true` for a union? The non-`memcpy` path will not do the right thing for a trivial assignment operator in that case.
It is never true:
bool RecordDecl::mayInsertExtraPadding(bool EmitRemark) const {
...
else if (CXXRD->isUnion())
ReasonToReject = 2; // is a union.
http://reviews.llvm.org/D6160
More information about the cfe-commits
mailing list