[clang] [llvm] [LLVM] Infer compression format from zlib and zstd headers (PR #222773)

Joseph Huber via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 28 05:14:20 PDT 2026


================
@@ -1927,19 +1927,15 @@ bool ASTReader::ReadSLocEntry(int ID) {
     unsigned RecCode = MaybeRecCode.get();
 
     if (RecCode == SM_SLOC_BUFFER_BLOB_COMPRESSED) {
-      // Inspect the first byte to differentiate zlib (\x78) and zstd
-      // (little-endian 0xFD2FB528).
-      const llvm::compression::Format F =
-          Blob.size() > 0 && Blob.data()[0] == 0x78
-              ? llvm::compression::Format::Zlib
-              : llvm::compression::Format::Zstd;
-      if (const char *Reason = llvm::compression::getReasonIfUnsupported(F)) {
+      ArrayRef<uint8_t> Compressed = llvm::arrayRefFromStringRef(Blob);
+      if (const char *Reason =
+              llvm::compression::getReasonIfUnsupported(Compressed)) {
         Error(Reason);
         return nullptr;
       }
----------------
jhuber6 wrote:

Done, I did that just to keep the old flow, but we can definitely just pipe this through the `Error` instead of a `const char *`.

https://github.com/llvm/llvm-project/pull/222773


More information about the llvm-commits mailing list