diff options
author | Larisse Voufo <lvoufo@google.com> | 2015-02-25 23:48:43 +0000 |
---|---|---|
committer | Larisse Voufo <lvoufo@google.com> | 2015-02-25 23:48:43 +0000 |
commit | 697b32a0cb702f2cc50329e25bfad15abc5beb9b (patch) | |
tree | 8e114ec40833432cc5c99ed92341e80413d440a5 /clang/lib/Sema/SemaExprCXX.cpp | |
parent | 17151eba64be0688d51991321e65addb88910cd9 (diff) | |
download | bcm5719-llvm-697b32a0cb702f2cc50329e25bfad15abc5beb9b.tar.gz bcm5719-llvm-697b32a0cb702f2cc50329e25bfad15abc5beb9b.zip |
Improvement on sized deallocation from r230160:
Do not declare sized deallocation functions dependently on whether it is found in global scope. Instead, enforce the branching in emitted code by (1) declaring the functions extern_weak and (2) emitting sized delete expressions as a branching between both forms delete.
llvm-svn: 230580
Diffstat (limited to 'clang/lib/Sema/SemaExprCXX.cpp')
-rw-r--r-- | clang/lib/Sema/SemaExprCXX.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index d24a653b348..c5df3ed0169 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -2090,15 +2090,6 @@ void Sema::DeclareGlobalAllocationFunction(DeclarationName Name, } } - // If the function is sized operator delete and has not already been - // declared, and weak definitions have been disabled, do not declare - // it implicitly. Instead, let deallocation function lookup pick up - // unsized delete. - // FIXME: We should remove this guard once backward compatibility is - // no longer an issue - if (NumParams == 2 && !getLangOpts().DefineSizedDeallocation) - return; - FunctionProtoType::ExtProtoInfo EPI; QualType BadAllocType; @@ -2131,6 +2122,16 @@ void Sema::DeclareGlobalAllocationFunction(DeclarationName Name, Alloc->addAttr(VisibilityAttr::CreateImplicit(Context, VisibilityAttr::Default)); + if (NumParams == 2 && !getLangOpts().DefineSizedDeallocation) { + assert(getLangOpts().SizedDeallocation && + "Only sized deallocation can have two parameters"); + + // This declaration should be emited as extern_weak. + LinkageInfo LV = Alloc->getLinkageAndVisibility(); + assert(LV.getLinkage() == clang::ExternalLinkage); + Alloc->addAttr(WeakAttr::CreateImplicit(Context)); + } + if (AddRestrictAttr) Alloc->addAttr( RestrictAttr::CreateImplicit(Context, RestrictAttr::GNU_malloc)); |