summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/include/llvm/MC/StringTableBuilder.h7
-rw-r--r--llvm/lib/MC/StringTableBuilder.cpp4
2 files changed, 7 insertions, 4 deletions
diff --git a/llvm/include/llvm/MC/StringTableBuilder.h b/llvm/include/llvm/MC/StringTableBuilder.h
index 90d1bc36f16..e63a3530eec 100644
--- a/llvm/include/llvm/MC/StringTableBuilder.h
+++ b/llvm/include/llvm/MC/StringTableBuilder.h
@@ -31,6 +31,7 @@ public:
}
StringRef val() const { return StringRef(P, Size); }
+ uint32_t size() const { return Size; }
uint32_t hash() const { return Hash; }
};
@@ -56,7 +57,8 @@ public:
/// \brief Add a string to the builder. Returns the position of S in the
/// table. The position will be changed if finalize is used.
/// Can only be used before the table is finalized.
- size_t add(StringRef S);
+ size_t add(CachedHashString S);
+ size_t add(StringRef S) { return add(CachedHashString(S)); }
/// \brief Analyze the strings and build the final table. No more strings can
/// be added after this point.
@@ -68,7 +70,8 @@ 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(CachedHashString S) const;
+ size_t getOffset(StringRef S) const { return getOffset(CachedHashString(S)); }
size_t getSize() const { return Size; }
void clear();
diff --git a/llvm/lib/MC/StringTableBuilder.cpp b/llvm/lib/MC/StringTableBuilder.cpp
index 63554fa39e6..42292d42fb7 100644
--- a/llvm/lib/MC/StringTableBuilder.cpp
+++ b/llvm/lib/MC/StringTableBuilder.cpp
@@ -183,14 +183,14 @@ void StringTableBuilder::clear() {
StringIndexMap.clear();
}
-size_t StringTableBuilder::getOffset(StringRef S) const {
+size_t StringTableBuilder::getOffset(CachedHashString S) const {
assert(isFinalized());
auto I = StringIndexMap.find(S);
assert(I != StringIndexMap.end() && "String is not in table!");
return I->second;
}
-size_t StringTableBuilder::add(StringRef S) {
+size_t StringTableBuilder::add(CachedHashString S) {
if (K == WinCOFF)
assert(S.size() > COFF::NameSize && "Short string in COFF string table!");
OpenPOWER on IntegriCloud