[PATCH] D19598: compiler warning for casting away const qualifier

Sjoerd Meijer via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 27 07:51:09 PDT 2016


SjoerdMeijer created this revision.
SjoerdMeijer added reviewers: joker.eph, tejohnson.
SjoerdMeijer added a subscriber: llvm-commits.
Herald added a subscriber: joker.eph.

This fix avoids compiler warnings about casting away const qualifiers.

http://reviews.llvm.org/D19598

Files:
  lib/Bitcode/Writer/BitcodeWriter.cpp
  lib/LTO/ThinLTOCodeGenerator.cpp

Index: lib/LTO/ThinLTOCodeGenerator.cpp
===================================================================
--- lib/LTO/ThinLTOCodeGenerator.cpp
+++ lib/LTO/ThinLTOCodeGenerator.cpp
@@ -457,17 +457,17 @@
 
     // Include the hash for the resolved ODR.
     for (auto &Entry : ResolvedODR) {
-      Hasher.update(ArrayRef<uint8_t>((uint8_t *)&Entry.first,
+      Hasher.update(ArrayRef<uint8_t>((const uint8_t *)&Entry.first,
                                       sizeof(GlobalValue::GUID)));
-      Hasher.update(ArrayRef<uint8_t>((uint8_t *)&Entry.second,
+      Hasher.update(ArrayRef<uint8_t>((const uint8_t *)&Entry.second,
                                       sizeof(GlobalValue::LinkageTypes)));
     }
 
     // Include the hash for the preserved symbols.
     for (auto &Entry : PreservedSymbols) {
       if (DefinedFunctions.count(Entry))
         Hasher.update(
-            ArrayRef<uint8_t>((uint8_t *)&Entry, sizeof(GlobalValue::GUID)));
+            ArrayRef<uint8_t>((const uint8_t *)&Entry, sizeof(GlobalValue::GUID)));
     }
 
     sys::path::append(EntryPath, CachePath, toHex(Hasher.result()));
Index: lib/Bitcode/Writer/BitcodeWriter.cpp
===================================================================
--- lib/Bitcode/Writer/BitcodeWriter.cpp
+++ lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -3337,7 +3337,7 @@
   // Emit the module's hash.
   // MODULE_CODE_HASH: [5*i32]
   SHA1 Hasher;
-  Hasher.update(ArrayRef<uint8_t>((uint8_t *)&(Buffer)[BlockStartPos],
+  Hasher.update(ArrayRef<uint8_t>((const uint8_t *)&(Buffer)[BlockStartPos],
                                   Buffer.size() - BlockStartPos));
   auto Hash = Hasher.result();
   SmallVector<uint64_t, 20> Vals;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19598.55230.patch
Type: text/x-patch
Size: 1699 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160427/6961a88c/attachment.bin>


More information about the llvm-commits mailing list