diff options
| author | David Blaikie <dblaikie@gmail.com> | 2015-11-11 20:44:52 +0000 |
|---|---|---|
| committer | David Blaikie <dblaikie@gmail.com> | 2015-11-11 20:44:52 +0000 |
| commit | 1070a09f1799633ae31a9135216d7d5b796ac9da (patch) | |
| tree | 33cecb2fc14f617059fb87947fd473e72c1020a4 /llvm/lib | |
| parent | bdce12a01bcb9e2f99c2092be4a1a1777a38385d (diff) | |
| download | bcm5719-llvm-1070a09f1799633ae31a9135216d7d5b796ac9da.tar.gz bcm5719-llvm-1070a09f1799633ae31a9135216d7d5b796ac9da.zip | |
unique_ptrify the AllocValueProfData helper function introduced in r252783
llvm-svn: 252799
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/ProfileData/InstrProf.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/llvm/lib/ProfileData/InstrProf.cpp b/llvm/lib/ProfileData/InstrProf.cpp index ddd23014673..92a3c251f6e 100644 --- a/llvm/lib/ProfileData/InstrProf.cpp +++ b/llvm/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<ValueProfData> AllocValueProfData(uint32_t TotalSize) { + return std::unique_ptr<ValueProfData>(new (::operator new(TotalSize)) + ValueProfData()); } std::unique_ptr<ValueProfData> ValueProfData::serializeFrom(const InstrProfRecord &Record) { uint32_t TotalSize = getSize(Record); - std::unique_ptr<ValueProfData> VPD(AllocValueProfData(TotalSize)); + std::unique_ptr<ValueProfData> 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<ValueProfData> VPD(AllocValueProfData(TotalSize)); + std::unique_ptr<ValueProfData> VPD = AllocValueProfData(TotalSize); memcpy(VPD.get(), D, TotalSize); // Byte swap. |

