[llvm] r183350 - Rename BinaryRef::isBinary to more descriptive DataIsHexString.
Sean Silva
silvas at purdue.edu
Wed Jun 5 16:32:31 PDT 2013
Author: silvas
Date: Wed Jun 5 18:32:31 2013
New Revision: 183350
URL: http://llvm.org/viewvc/llvm-project?rev=183350&view=rev
Log:
Rename BinaryRef::isBinary to more descriptive DataIsHexString.
And add a doxygen comment.
Modified:
llvm/trunk/include/llvm/Object/YAML.h
llvm/trunk/lib/Object/YAML.cpp
Modified: llvm/trunk/include/llvm/Object/YAML.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/YAML.h?rev=183350&r1=183349&r2=183350&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/YAML.h (original)
+++ llvm/trunk/include/llvm/Object/YAML.h Wed Jun 5 18:32:31 2013
@@ -27,26 +27,27 @@ class BinaryRef {
/// \brief Either raw binary data, or a string of hex bytes (must always
/// be an even number of characters).
ArrayRef<uint8_t> Data;
- bool isBinary;
+ /// \brief Discriminator between the two states of the `Data` member.
+ bool DataIsHexString;
public:
- BinaryRef(ArrayRef<uint8_t> Data) : Data(Data), isBinary(true) {}
+ BinaryRef(ArrayRef<uint8_t> Data) : Data(Data), DataIsHexString(false) {}
BinaryRef(StringRef Data)
: Data(reinterpret_cast<const uint8_t *>(Data.data()), Data.size()),
- isBinary(false) {}
- BinaryRef() : isBinary(false) {}
+ DataIsHexString(true) {}
+ BinaryRef() : DataIsHexString(true) {}
StringRef getHex() const {
- assert(!isBinary);
+ assert(DataIsHexString);
return StringRef(reinterpret_cast<const char *>(Data.data()), Data.size());
}
ArrayRef<uint8_t> getBinary() const {
- assert(isBinary);
+ assert(!DataIsHexString);
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)
+ if (DataIsHexString)
return Data.size() / 2;
return Data.size();
}
@@ -55,7 +56,7 @@ public:
if (Ref.Data.empty() && Data.empty())
return true;
- return Ref.isBinary == isBinary && Ref.Data == Data;
+ return Ref.DataIsHexString == DataIsHexString && Ref.Data == Data;
}
/// \brief Write the contents (regardless of whether it is binary or a
/// hex string) as binary to the given raw_ostream.
Modified: llvm/trunk/lib/Object/YAML.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/YAML.cpp?rev=183350&r1=183349&r2=183350&view=diff
==============================================================================
--- llvm/trunk/lib/Object/YAML.cpp (original)
+++ llvm/trunk/lib/Object/YAML.cpp Wed Jun 5 18:32:31 2013
@@ -51,7 +51,7 @@ StringRef yaml::ScalarTraits<object::yam
}
void BinaryRef::writeAsBinary(raw_ostream &OS) const {
- if (isBinary) {
+ if (!DataIsHexString) {
OS.write((const char *)Data.data(), Data.size());
return;
}
More information about the llvm-commits
mailing list