[llvm] r252799 - unique_ptrify the AllocValueProfData helper function introduced in r252783

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 11 12:44:53 PST 2015


Author: dblaikie
Date: Wed Nov 11 14:44:52 2015
New Revision: 252799

URL: http://llvm.org/viewvc/llvm-project?rev=252799&view=rev
Log:
unique_ptrify the AllocValueProfData helper function introduced in r252783

Modified:
    llvm/trunk/lib/ProfileData/InstrProf.cpp

Modified: llvm/trunk/lib/ProfileData/InstrProf.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ProfileData/InstrProf.cpp?rev=252799&r1=252798&r2=252799&view=diff
==============================================================================
--- llvm/trunk/lib/ProfileData/InstrProf.cpp (original)
+++ llvm/trunk/lib/ProfileData/InstrProf.cpp Wed Nov 11 14:44:52 2015
@@ -244,17 +244,16 @@ void ValueProfData::deserializeTo(InstrP
   }
 }
 
-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 un
   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.




More information about the llvm-commits mailing list