forked from OSchip/llvm-project
Fix the variable names to match the LLVM style.
llvm-svn: 251143
This commit is contained in:
parent
52f7b08b4a
commit
a9b3944c0e
|
@ -24,7 +24,7 @@ class StringTableBuilder {
|
|||
public:
|
||||
/// \brief Add a string to the builder. Returns a StringRef to the internal
|
||||
/// copy of s. Can only be used before the table is finalized.
|
||||
void add(StringRef s);
|
||||
void add(StringRef S);
|
||||
|
||||
enum Kind {
|
||||
ELF,
|
||||
|
@ -34,7 +34,7 @@ public:
|
|||
|
||||
/// \brief Analyze the strings and build the final table. No more strings can
|
||||
/// be added after this point.
|
||||
void finalize(Kind kind);
|
||||
void finalize(Kind K);
|
||||
|
||||
/// \brief Retrieve the string table data. Can only be used after the table
|
||||
/// is finalized.
|
||||
|
@ -45,7 +45,7 @@ public:
|
|||
|
||||
/// \brief Get the offest of a string in the string table. Can only be used
|
||||
/// after the table is finalized.
|
||||
size_t getOffset(StringRef s) const;
|
||||
size_t getOffset(StringRef S) const;
|
||||
|
||||
void clear();
|
||||
|
||||
|
|
|
@ -18,21 +18,21 @@ using namespace llvm;
|
|||
|
||||
static int compareBySuffix(std::pair<StringRef, size_t> *const *AP,
|
||||
std::pair<StringRef, size_t> *const *BP) {
|
||||
StringRef a = (*AP)->first;
|
||||
StringRef b = (*BP)->first;
|
||||
size_t sizeA = a.size();
|
||||
size_t sizeB = b.size();
|
||||
size_t len = std::min(sizeA, sizeB);
|
||||
for (size_t i = 0; i < len; ++i) {
|
||||
char ca = a[sizeA - i - 1];
|
||||
char cb = b[sizeB - i - 1];
|
||||
if (ca != cb)
|
||||
return cb - ca;
|
||||
StringRef A = (*AP)->first;
|
||||
StringRef B = (*BP)->first;
|
||||
size_t SizeA = A.size();
|
||||
size_t SizeB = B.size();
|
||||
size_t Len = std::min(SizeA, SizeB);
|
||||
for (size_t I = 0; I < Len; ++I) {
|
||||
char CA = A[SizeA - I - 1];
|
||||
char CB = B[SizeB - I - 1];
|
||||
if (CA != CB)
|
||||
return CB - CA;
|
||||
}
|
||||
return sizeB - sizeA;
|
||||
return SizeB - SizeA;
|
||||
}
|
||||
|
||||
void StringTableBuilder::finalize(Kind kind) {
|
||||
void StringTableBuilder::finalize(Kind K) {
|
||||
std::vector<std::pair<StringRef, size_t> *> Strings;
|
||||
Strings.reserve(StringIndexMap.size());
|
||||
for (std::pair<StringRef, size_t> &P : StringIndexMap)
|
||||
|
@ -40,7 +40,7 @@ void StringTableBuilder::finalize(Kind kind) {
|
|||
|
||||
array_pod_sort(Strings.begin(), Strings.end(), compareBySuffix);
|
||||
|
||||
switch (kind) {
|
||||
switch (K) {
|
||||
case ELF:
|
||||
case MachO:
|
||||
// Start the table with a NUL byte.
|
||||
|
@ -54,22 +54,22 @@ void StringTableBuilder::finalize(Kind kind) {
|
|||
|
||||
StringRef Previous;
|
||||
for (std::pair<StringRef, size_t> *P : Strings) {
|
||||
StringRef s = P->first;
|
||||
if (kind == WinCOFF)
|
||||
assert(s.size() > COFF::NameSize && "Short string in COFF string table!");
|
||||
StringRef S = P->first;
|
||||
if (K == WinCOFF)
|
||||
assert(S.size() > COFF::NameSize && "Short string in COFF string table!");
|
||||
|
||||
if (Previous.endswith(s)) {
|
||||
P->second = StringTable.size() - 1 - s.size();
|
||||
if (Previous.endswith(S)) {
|
||||
P->second = StringTable.size() - 1 - S.size();
|
||||
continue;
|
||||
}
|
||||
|
||||
P->second = StringTable.size();
|
||||
StringTable += s;
|
||||
StringTable += S;
|
||||
StringTable += '\x00';
|
||||
Previous = s;
|
||||
Previous = S;
|
||||
}
|
||||
|
||||
switch (kind) {
|
||||
switch (K) {
|
||||
case ELF:
|
||||
break;
|
||||
case MachO:
|
||||
|
@ -80,9 +80,9 @@ void StringTableBuilder::finalize(Kind kind) {
|
|||
case WinCOFF:
|
||||
// Write the table size in the first word.
|
||||
assert(StringTable.size() <= std::numeric_limits<uint32_t>::max());
|
||||
uint32_t size = static_cast<uint32_t>(StringTable.size());
|
||||
uint32_t Size = static_cast<uint32_t>(StringTable.size());
|
||||
support::endian::write<uint32_t, support::little, support::unaligned>(
|
||||
StringTable.data(), size);
|
||||
StringTable.data(), Size);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -92,14 +92,14 @@ void StringTableBuilder::clear() {
|
|||
StringIndexMap.clear();
|
||||
}
|
||||
|
||||
size_t StringTableBuilder::getOffset(StringRef s) const {
|
||||
size_t StringTableBuilder::getOffset(StringRef S) const {
|
||||
assert(isFinalized());
|
||||
auto I = StringIndexMap.find(s);
|
||||
auto I = StringIndexMap.find(S);
|
||||
assert(I != StringIndexMap.end() && "String is not in table!");
|
||||
return I->second;
|
||||
}
|
||||
|
||||
void StringTableBuilder::add(StringRef s) {
|
||||
void StringTableBuilder::add(StringRef S) {
|
||||
assert(!isFinalized());
|
||||
StringIndexMap.insert(std::make_pair(s, 0));
|
||||
StringIndexMap.insert(std::make_pair(S, 0));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue