[PATCH] D50267: [ASTWriter] Use zlib::compress which operates on std::unique_ptr<uint8_t[]>

Fangrui Song via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 3 11:33:27 PDT 2018


MaskRay created this revision.
MaskRay added reviewers: ruiu, rsmith.
Herald added a subscriber: cfe-commits.

Repository:
  rC Clang

https://reviews.llvm.org/D50267

Files:
  lib/Serialization/ASTWriter.cpp


Index: lib/Serialization/ASTWriter.cpp
===================================================================
--- lib/Serialization/ASTWriter.cpp
+++ lib/Serialization/ASTWriter.cpp
@@ -2207,14 +2207,17 @@
 
   // Compress the buffer if possible. We expect that almost all PCM
   // consumers will not want its contents.
-  SmallString<0> CompressedBuffer;
+  std::unique_ptr<uint8_t[]> CompressedData;
+  size_t CompressedSize;
   if (llvm::zlib::isAvailable()) {
-    llvm::Error E = llvm::zlib::compress(Blob.drop_back(1), CompressedBuffer);
+    llvm::Error E =
+        llvm::zlib::compress(Blob.drop_back(1), CompressedData, CompressedSize);
     if (!E) {
       RecordDataType Record[] = {SM_SLOC_BUFFER_BLOB_COMPRESSED,
                                  Blob.size() - 1};
-      Stream.EmitRecordWithBlob(SLocBufferBlobCompressedAbbrv, Record,
-                                CompressedBuffer);
+      Stream.EmitRecordWithBlob(
+          SLocBufferBlobCompressedAbbrv, Record,
+          StringRef((char *)CompressedData.get(), CompressedSize));
       return;
     }
     llvm::consumeError(std::move(E));


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50267.159061.patch
Type: text/x-patch
Size: 1116 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180803/9d456c8e/attachment.bin>


More information about the cfe-commits mailing list