Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:44:17

0001 //===-- Decompressor.h ------------------------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===/
0008 
0009 #ifndef LLVM_OBJECT_DECOMPRESSOR_H
0010 #define LLVM_OBJECT_DECOMPRESSOR_H
0011 
0012 #include "llvm/ADT/ArrayRef.h"
0013 #include "llvm/ADT/StringRef.h"
0014 #include "llvm/Support/Compression.h"
0015 #include "llvm/Support/Error.h"
0016 
0017 namespace llvm {
0018 namespace object {
0019 
0020 /// Decompressor helps to handle decompression of compressed sections.
0021 class Decompressor {
0022 public:
0023   /// Create decompressor object.
0024   /// @param Name        Section name.
0025   /// @param Data        Section content.
0026   /// @param IsLE        Flag determines if Data is in little endian form.
0027   /// @param Is64Bit     Flag determines if object is 64 bit.
0028   static Expected<Decompressor> create(StringRef Name, StringRef Data,
0029                                        bool IsLE, bool Is64Bit);
0030 
0031   /// Resize the buffer and uncompress section data into it.
0032   /// @param Out         Destination buffer.
0033   template <class T> Error resizeAndDecompress(T &Out) {
0034     Out.resize(DecompressedSize);
0035     return decompress({(uint8_t *)Out.data(), (size_t)DecompressedSize});
0036   }
0037 
0038   /// Uncompress section data to raw buffer provided.
0039   Error decompress(MutableArrayRef<uint8_t> Output);
0040 
0041   /// Return memory buffer size required for decompression.
0042   uint64_t getDecompressedSize() { return DecompressedSize; }
0043 
0044 private:
0045   Decompressor(StringRef Data);
0046 
0047   Error consumeCompressedHeader(bool Is64Bit, bool IsLittleEndian);
0048 
0049   StringRef SectionData;
0050   uint64_t DecompressedSize;
0051   DebugCompressionType CompressionType = DebugCompressionType::None;
0052 };
0053 
0054 } // end namespace object
0055 } // end namespace llvm
0056 
0057 #endif // LLVM_OBJECT_DECOMPRESSOR_H