Index: clang/include/clang/Sema/Sema.h =================================================================== --- clang/include/clang/Sema/Sema.h +++ clang/include/clang/Sema/Sema.h @@ -5195,6 +5195,18 @@ AFS_Both }; + static VisibilityAttr::VisibilityType getVisibilityAttr(clang::Visibility V) { + switch (V) { + case DefaultVisibility: + return VisibilityAttr::Default; + case HiddenVisibility: + return VisibilityAttr::Hidden; + case ProtectedVisibility: + return VisibilityAttr::Protected; + } + llvm_unreachable("unknown visibility!"); + }; + /// Finds the overloads of operator new and delete that are appropriate /// for the allocation. bool FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range, Index: clang/lib/Sema/SemaExprCXX.cpp =================================================================== --- clang/lib/Sema/SemaExprCXX.cpp +++ clang/lib/Sema/SemaExprCXX.cpp @@ -2816,9 +2816,9 @@ // Global allocation functions should always be visible. Alloc->setVisibleDespiteOwningModule(); - // Implicit sized deallocation functions always have default visibility. - Alloc->addAttr( - VisibilityAttr::CreateImplicit(Context, VisibilityAttr::Default)); + Alloc->addAttr(VisibilityAttr::CreateImplicit( + Context, + getVisibilityAttr(Context.getLangOpts().getValueVisibilityMode()))); llvm::SmallVector ParamDecls; for (QualType T : Params) {