[PATCH] D137885: [modules] Support zstd in .pcm file

Fangrui Song via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 18 11:18:25 PST 2022


MaskRay marked 2 inline comments as done.
MaskRay added inline comments.


================
Comment at: clang/lib/Serialization/ASTReader.cpp:1457
+      const llvm::compression::Format F =
+          Blob.size() >= 2 && memcmp(Blob.data(), "\x1f\x8b", 2) == 0
+              ? llvm::compression::Format::Zlib
----------------
dblaikie wrote:
> tschuett wrote:
> > Could you put the magic number into a named constant?
> & perhaps we should have/test a magic number for zstd too, so it's clear it's one or the other and not something else added in the future (since this isn't reving the bitcode version or anything - reading zstd compressed data with the library before this version will I guess/hopefully appear corrupted, but we could avoid that being the failure mode in the future when another compression scheme is added by checking explicitly for zstd/zlib now and reporting unknown compression scheme otherwise?)?
> Could you put the magic number into a named constant?

I think a constant doesn't improve readability of this used-once value with a comment.

> & perhaps we should have/test a magic number for zstd too, so it's clear it's one or the other and not something else added in the future

Since the version number keeps increasing, when a new algorithm is added, they will see a version mismatch error...


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137885/new/

https://reviews.llvm.org/D137885



More information about the cfe-commits mailing list