diff options
author | Nuno Lopes <nunoplopes@sapo.pt> | 2009-12-16 16:59:22 +0000 |
---|---|---|
committer | Nuno Lopes <nunoplopes@sapo.pt> | 2009-12-16 16:59:22 +0000 |
commit | fc2844846e91398205fddc71196fe9dda04e105f (patch) | |
tree | ac559da7abd78c1dc3d305257a1c726c6046f222 /lib/Sema/SemaDecl.cpp | |
parent | 52bb5d2a1474460707e5ca11656b2749a7a33a82 (diff) |
implement PR5654: add -fassume-sane-operator-new, which is enabled by default, and adds the malloc attribute to the global function new() and to the overloaded new operators.
feel free to chage the name to this lengthy argument
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91543 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 7a27e1185e..bf5b350da0 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -2799,6 +2799,11 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC, D.getIdentifierLoc(), Name, R, TInfo, isStatic, isInline); + if ((Name.getCXXOverloadedOperator() == OO_New || + Name.getCXXOverloadedOperator() == OO_Array_New) && + getLangOptions().AssumeSaneOperatorNew) + NewFD->addAttr(::new (Context) MallocAttr()); + isVirtualOkay = !isStatic; } else { // Determine whether the function was written with a |