aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-07-23 18:52:12 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-07-23 18:52:12 +0000
commite2db823b3f0483a199eeda4c4220cb616e616c9b (patch)
tree02aaed474e034e9d1331d646fe672ff232acbca6 /lib
parentd29fce6da587bcae207f2905bcd4e7006fc85995 (diff)
downloadexternal_llvm-e2db823b3f0483a199eeda4c4220cb616e616c9b.zip
external_llvm-e2db823b3f0483a199eeda4c4220cb616e616c9b.tar.gz
external_llvm-e2db823b3f0483a199eeda4c4220cb616e616c9b.tar.bz2
Switch ValueSymbolTable to StringRef based API.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76894 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Linker/LinkModules.cpp6
-rw-r--r--lib/VMCore/Module.cpp2
-rw-r--r--lib/VMCore/ValueSymbolTable.cpp27
3 files changed, 7 insertions, 28 deletions
diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp
index c97cd9c..95f0ece 100644
--- a/lib/Linker/LinkModules.cpp
+++ b/lib/Linker/LinkModules.cpp
@@ -548,8 +548,7 @@ static bool LinkGlobals(Module *Dest, const Module *Src,
// Check to see if may have to link the global with the global, alias or
// function.
if (SGV->hasName() && !SGV->hasLocalLinkage())
- DGV = cast_or_null<GlobalValue>(DestSymTab.lookup(SGV->getNameStart(),
- SGV->getNameEnd()));
+ DGV = cast_or_null<GlobalValue>(DestSymTab.lookup(SGV->getNameRef()));
// If we found a global with the same name in the dest module, but it has
// internal linkage, we are really not doing any linkage here.
@@ -942,8 +941,7 @@ static bool LinkFunctionProtos(Module *Dest, const Module *Src,
// Check to see if may have to link the function with the global, alias or
// function.
if (SF->hasName() && !SF->hasLocalLinkage())
- DGV = cast_or_null<GlobalValue>(DestSymTab.lookup(SF->getNameStart(),
- SF->getNameEnd()));
+ DGV = cast_or_null<GlobalValue>(DestSymTab.lookup(SF->getNameRef()));
// If we found a global with the same name in the dest module, but it has
// internal linkage, we are really not doing any linkage here.
diff --git a/lib/VMCore/Module.cpp b/lib/VMCore/Module.cpp
index 4daa92d..9e6e31a 100644
--- a/lib/VMCore/Module.cpp
+++ b/lib/VMCore/Module.cpp
@@ -118,7 +118,7 @@ GlobalValue *Module::getNamedValue(const std::string &Name) const {
}
GlobalValue *Module::getNamedValue(const char *Name) const {
- llvm::Value *V = getValueSymbolTable().lookup(Name, Name+strlen(Name));
+ llvm::Value *V = getValueSymbolTable().lookup(Name);
return cast_or_null<GlobalValue>(V);
}
diff --git a/lib/VMCore/ValueSymbolTable.cpp b/lib/VMCore/ValueSymbolTable.cpp
index 8d3514b..f87bb63 100644
--- a/lib/VMCore/ValueSymbolTable.cpp
+++ b/lib/VMCore/ValueSymbolTable.cpp
@@ -30,24 +30,6 @@ ValueSymbolTable::~ValueSymbolTable() {
#endif
}
-// lookup a value - Returns null on failure...
-//
-Value *ValueSymbolTable::lookup(const std::string &Name) const {
- const_iterator VI = vmap.find(Name);
- if (VI != vmap.end()) // We found the symbol
- return VI->getValue();
- return 0;
-}
-
-Value *ValueSymbolTable::lookup(const char *NameBegin,
- const char *NameEnd) const {
- // FIXME: ValueSymbolTable should move to a StringRef based API.
- const_iterator VI = vmap.find(StringRef(NameBegin, NameEnd - NameBegin));
- if (VI != vmap.end()) // We found the symbol
- return VI->getValue();
- return 0;
-}
-
// Insert a value into the symbol table with the specified name...
//
void ValueSymbolTable::reinsertValue(Value* V) {
@@ -93,10 +75,9 @@ void ValueSymbolTable::removeValueName(ValueName *V) {
/// createValueName - This method attempts to create a value name and insert
/// it into the symbol table with the specified name. If it conflicts, it
/// auto-renames the name and returns that instead.
-ValueName *ValueSymbolTable::createValueName(const char *NameStart,
- unsigned NameLen, Value *V) {
+ValueName *ValueSymbolTable::createValueName(const StringRef &Name, Value *V) {
// In the common case, the name is not already in the symbol table.
- ValueName &Entry = vmap.GetOrCreateValue(StringRef(NameStart, NameLen));
+ ValueName &Entry = vmap.GetOrCreateValue(Name);
if (Entry.getValue() == 0) {
Entry.setValue(V);
//DEBUG(DOUT << " Inserted value: " << Entry.getKeyData() << ": "
@@ -105,11 +86,11 @@ ValueName *ValueSymbolTable::createValueName(const char *NameStart,
}
// Otherwise, there is a naming conflict. Rename this value.
- SmallString<128> UniqueName(NameStart, NameStart+NameLen);
+ SmallString<128> UniqueName(Name.begin(), Name.end());
while (1) {
// Trim any suffix off.
- UniqueName.resize(NameLen);
+ UniqueName.resize(Name.size());
UniqueName.append_uint_32(++LastUnique);
// Try insert the vmap entry with this suffix.