diff options
author | Sean Silva <silvas@purdue.edu> | 2013-06-05 23:32:27 +0000 |
---|---|---|
committer | Sean Silva <silvas@purdue.edu> | 2013-06-05 23:32:27 +0000 |
commit | 63958fba58716ed435563321944f7d4663d2ee2d (patch) | |
tree | 5670637b121f3e1bfa1c4d5230a3f98e8df61e9b /include | |
parent | 2b1068952ade3a1d2c704e7589c54e3d32dc0eb8 (diff) | |
download | external_llvm-63958fba58716ed435563321944f7d4663d2ee2d.zip external_llvm-63958fba58716ed435563321944f7d4663d2ee2d.tar.gz external_llvm-63958fba58716ed435563321944f7d4663d2ee2d.tar.bz2 |
Add BinaryRef binary_size() method.
This avoids making assumptions about the data representation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183349 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/Object/YAML.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/include/llvm/Object/YAML.h b/include/llvm/Object/YAML.h index e6f1da1..92811b0 100644 --- a/include/llvm/Object/YAML.h +++ b/include/llvm/Object/YAML.h @@ -43,6 +43,13 @@ public: assert(isBinary); return Data; } + /// \brief The number of bytes that are represented by this BinaryRef. + /// This is the number of bytes that writeAsBinary() will write. + ArrayRef<uint8_t>::size_type binary_size() const { + if (!isBinary) + return Data.size() / 2; + return Data.size(); + } bool operator==(const BinaryRef &Ref) { // Special case for default constructed BinaryRef. if (Ref.Data.empty() && Data.empty()) |