Minor cleanups (from review feedback)
authorXinliang David Li <davidxl@google.com>
Wed, 18 Nov 2015 22:42:27 +0000 (22:42 +0000)
committerXinliang David Li <davidxl@google.com>
Wed, 18 Nov 2015 22:42:27 +0000 (22:42 +0000)
1. remove uneeded header inclusion
2. use reinterpret_cast instead of c ctyle
3. other format change

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253515 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ProfileData/InstrProfReader.h
lib/ProfileData/InstrProfReader.cpp

index c1d17c271582dcca512e0777f11ad0203c664221..f58000c3057703ab949bdea8ac2d9d4bc45b133c 100644 (file)
 #include "llvm/ProfileData/InstrProf.h"
 #include "llvm/Support/EndianStream.h"
 #include "llvm/Support/ErrorOr.h"
-#include "llvm/Support/raw_ostream.h"
 #include "llvm/Support/LineIterator.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/OnDiskHashTable.h"
+#include "llvm/Support/raw_ostream.h"
 #include <iterator>
-#include <map>
 
 namespace llvm {
 
@@ -186,13 +185,15 @@ private:
     return NamesStart + Offset;
   }
   const uint8_t *getValueDataCounts(IntPtrT ValueCountsPtr) const {
-    ptrdiff_t Offset = (swap(ValueCountsPtr) - ValueDataDelta) / sizeof(uint8_t);
+    ptrdiff_t Offset =
+        (swap(ValueCountsPtr) - ValueDataDelta) / sizeof(uint8_t);
     return ValueDataStart + Offset;
   }
   // This accepts an already byte-swapped ValueDataPtr argument.
   const InstrProfValueData *getValueData(IntPtrT ValueDataPtr) const {
     ptrdiff_t Offset = (ValueDataPtr - ValueDataDelta) / sizeof(uint8_t);
-    return reinterpret_cast<const InstrProfValueData*>(ValueDataStart + Offset);
+    return reinterpret_cast<const InstrProfValueData *>(ValueDataStart +
+                                                        Offset);
   }
 };
 
index 8a0354dc98cf6fb2910dc44cb6f1892839745085..fe52e1312ef467d6565d7e4de9f6f07539aaa5f1 100644 (file)
@@ -255,7 +255,8 @@ template <class IntPtrT>
 std::error_code RawInstrProfReader<IntPtrT>::readName(InstrProfRecord &Record) {
   Record.Name = StringRef(getName(Data->NamePtr), swap(Data->NameSize));
   if (Record.Name.data() < NamesStart ||
-      Record.Name.data() + Record.Name.size() > (char*)ValueDataStart)
+      Record.Name.data() + Record.Name.size() >
+          reinterpret_cast<const char *>(ValueDataStart))
     return error(instrprof_error::malformed);
   return success();
 }
@@ -311,7 +312,8 @@ std::error_code RawInstrProfReader<IntPtrT>::readValueData(
   auto VDataCounts = makeArrayRef(getValueDataCounts(Data->Values), NumVSites);
   // Check bounds.
   if (VDataCounts.data() < ValueDataStart ||
-      VDataCounts.data() + VDataCounts.size() > (const uint8_t *)ProfileEnd)
+      VDataCounts.data() + VDataCounts.size() >
+          reinterpret_cast<const uint8_t *>(ProfileEnd))
     return error(instrprof_error::malformed);
 
   const InstrProfValueData *VDataPtr =