llvm::endian::Writer is often used to serialize for binary formats, which makes it attractive to explicitly provide template arguments for the type being written. However, this can also lead to accidental truncation of data, which can lead to corruption of the serialized archive. (Real-world example: https://github.com/apple/swift/pull/17265.) Add assertions for this sort of accidental truncation with integer types, and for overflow errors with floating-point types, while preserving the existing behavior when the template argument is not provided explicitly.
Diff Detail
Diff Detail
- Repository
- rL LLVM