From 9650aeb6c8331b186cdb7c6b7606aac49f2575de Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Wed, 11 Nov 2015 20:44:52 +0000 Subject: [PATCH 1/1] unique_ptrify the AllocValueProfData helper function introduced in r252783 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252799 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/ProfileData/InstrProf.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/ProfileData/InstrProf.cpp b/lib/ProfileData/InstrProf.cpp index ddd23014673..92a3c251f6e 100644 --- a/lib/ProfileData/InstrProf.cpp +++ b/lib/ProfileData/InstrProf.cpp @@ -244,17 +244,16 @@ void ValueProfData::deserializeTo(InstrProfRecord &Record, } } -static ValueProfData *AllocValueProfData(uint32_t TotalSize) { - void *RawMem = ::operator new(TotalSize); - ValueProfData *VPDMem = new (RawMem) ValueProfData(); - return VPDMem; +static std::unique_ptr AllocValueProfData(uint32_t TotalSize) { + return std::unique_ptr(new (::operator new(TotalSize)) + ValueProfData()); } std::unique_ptr ValueProfData::serializeFrom(const InstrProfRecord &Record) { uint32_t TotalSize = getSize(Record); - std::unique_ptr VPD(AllocValueProfData(TotalSize)); + std::unique_ptr VPD = AllocValueProfData(TotalSize); VPD->TotalSize = TotalSize; VPD->NumValueKinds = Record.getNumValueKinds(); @@ -290,7 +289,7 @@ ValueProfData::getValueProfData(const unsigned char *D, if (TotalSize % sizeof(uint64_t)) return instrprof_error::malformed; - std::unique_ptr VPD(AllocValueProfData(TotalSize)); + std::unique_ptr VPD = AllocValueProfData(TotalSize); memcpy(VPD.get(), D, TotalSize); // Byte swap. -- 2.34.1