diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-08-18 15:06:25 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-08-18 15:06:25 +0000 |
commit | 7b86862ff555a9d848ac7abf6042d192b6d5a04d (patch) | |
tree | c7caceba87703434f13383a3d6a08e92795b392c /lib/Sema/SemaExprCXX.cpp | |
parent | 783c56f47745f719590b17afd7ed937bf2407b53 (diff) |
Make sure to add MallocAttr to explicitly-declared operator new/new[]
when -fassume-sane-operator-new. Patch by Tom Jablin!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111363 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExprCXX.cpp')
-rw-r--r-- | lib/Sema/SemaExprCXX.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index 5e46090c05..8599a146c6 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -1257,8 +1257,11 @@ 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; + } } } } |