Make sure to add MallocAttr to explicitly-declared operator new/new[]
when -fassume-sane-operator-new. Patch by Tom Jablin! llvm-svn: 111363
This commit is contained in:
parent
b13f5d99af
commit
c1a42fdd53
|
@ -1257,11 +1257,14 @@ void Sema::DeclareGlobalAllocationFunction(DeclarationName Name,
|
|||
Context.getCanonicalType(
|
||||
Func->getParamDecl(0)->getType().getUnqualifiedType());
|
||||
// FIXME: Do we need to check for default arguments here?
|
||||
if (Func->getNumParams() == 1 && InitialParamType == Argument)
|
||||
if (Func->getNumParams() == 1 && InitialParamType == Argument) {
|
||||
if(AddMallocAttr && !Func->hasAttr<MallocAttr>())
|
||||
Func->addAttr(::new (Context) MallocAttr());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QualType BadAllocType;
|
||||
bool HasBadAllocExceptionSpec
|
||||
|
|
|
@ -73,6 +73,10 @@ void t8(int n) {
|
|||
new U[n];
|
||||
}
|
||||
|
||||
// noalias
|
||||
// CHECK: declare noalias i8* @_Znam
|
||||
void *operator new[](size_t);
|
||||
|
||||
void t9() {
|
||||
bool b;
|
||||
|
||||
|
|
Loading…
Reference in New Issue