[PATCH] D21157: [pdb] Improve StreamInterface to support writing
Zachary Turner via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 8 22:38:42 PDT 2016
zturner added inline comments.
================
Comment at: include/llvm/DebugInfo/CodeView/StreamWriter.h:32-33
@@ +31,4 @@
+ Error writeBytes(ArrayRef<uint8_t> Buffer);
+ Error writeInteger(uint16_t Dest);
+ Error writeInteger(uint32_t Dest);
+ Error writeZeroString(StringRef Str);
----------------
ruiu wrote:
> I'd like to name them writeUint{16,32} instead of defining as a overloaded function. Sometimes argument type is not obvious in a local context (uses of `auto` makes it much harder).
Hmm, it turns out this makes `writeEnum` difficult to implement, because it relies on the overload. It can still be done with something like this:
```
template<typename T, typename U = std::underlying_type<T>::type> Error writeEnum(T Num);
template<typename T> Error writeEnum<T, uint32_t> Error writeEnum(T Num) {
return writeUInt32(static_cast<uint32_t>(Num));
}
template<typename T> Error writeEnum<T, uint16_t> Error writeEnum(T Num) {
return writeUInt16(static_cast<uint16_t>(Num));
}
```
but I start to wonder if it's an improvement.
http://reviews.llvm.org/D21157
More information about the llvm-commits
mailing list