mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-28 21:34:23 +00:00
Make findModulesDefiningSymbols modify its symbols argument so we can \
eliminate symbols defined by the archive efficiently git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17976 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
3cf2c32202
commit
7783e8ad69
@ -396,10 +396,13 @@ class Archive {
|
|||||||
/// more than one symbol at a time. If \p symbols contains a list of
|
/// more than one symbol at a time. If \p symbols contains a list of
|
||||||
/// undefined symbols in some module, then calling this method is like
|
/// undefined symbols in some module, then calling this method is like
|
||||||
/// making one complete pass through the archive to resolve symbols but is
|
/// making one complete pass through the archive to resolve symbols but is
|
||||||
/// more efficient than looking at the individual members.
|
/// more efficient than looking at the individual members. Note that on
|
||||||
|
/// exit, the symbols resolved by this method will be removed from \p
|
||||||
|
/// symbols to ensure they are not re-searched on a subsequent call. If
|
||||||
|
/// you need to retain the list of symbols, make a copy.
|
||||||
/// @brief Look up multiple symbols in the archive.
|
/// @brief Look up multiple symbols in the archive.
|
||||||
void findModulesDefiningSymbols(
|
void findModulesDefiningSymbols(
|
||||||
const std::set<std::string>& symbols, ///< Symbols to be sought
|
std::set<std::string>& symbols, ///< Symbols to be sought
|
||||||
std::set<ModuleProvider*>& modules ///< The modules matching \p symbols
|
std::set<ModuleProvider*>& modules ///< The modules matching \p symbols
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -407,7 +407,7 @@ Archive::findModuleDefiningSymbol(const std::string& symbol) {
|
|||||||
// Look up multiple symbols in the symbol table and return a set of
|
// Look up multiple symbols in the symbol table and return a set of
|
||||||
// ModuleProviders that define those symbols.
|
// ModuleProviders that define those symbols.
|
||||||
void
|
void
|
||||||
Archive::findModulesDefiningSymbols(const std::set<std::string>& symbols,
|
Archive::findModulesDefiningSymbols(std::set<std::string>& symbols,
|
||||||
std::set<ModuleProvider*>& result)
|
std::set<ModuleProvider*>& result)
|
||||||
{
|
{
|
||||||
assert(mapfile && base && "Can't findModulesDefiningSymbols on new archive");
|
assert(mapfile && base && "Can't findModulesDefiningSymbols on new archive");
|
||||||
@ -462,11 +462,22 @@ Archive::findModulesDefiningSymbols(const std::set<std::string>& symbols,
|
|||||||
// At this point we have a valid symbol table (one way or another) so we
|
// At this point we have a valid symbol table (one way or another) so we
|
||||||
// just use it to quickly find the symbols requested.
|
// just use it to quickly find the symbols requested.
|
||||||
|
|
||||||
for (std::set<std::string>::const_iterator I=symbols.begin(),
|
for (std::set<std::string>::iterator I=symbols.begin(),
|
||||||
E=symbols.end(); I != E; ++I) {
|
E=symbols.end(); I != E;) {
|
||||||
|
// See if this symbol exists
|
||||||
ModuleProvider* mp = findModuleDefiningSymbol(*I);
|
ModuleProvider* mp = findModuleDefiningSymbol(*I);
|
||||||
if (mp) {
|
if (mp) {
|
||||||
|
// The symbol exists, insert the ModuleProvider into our result,
|
||||||
|
// duplicates wil be ignored
|
||||||
result.insert(mp);
|
result.insert(mp);
|
||||||
|
|
||||||
|
// Remove the symbol now that its been resolved, being careful to
|
||||||
|
// not invalidate our iterator.
|
||||||
|
std::set<std::string>::iterator save = I;
|
||||||
|
++I;
|
||||||
|
symbols.erase(save);
|
||||||
|
} else {
|
||||||
|
++I;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -407,7 +407,7 @@ Archive::findModuleDefiningSymbol(const std::string& symbol) {
|
|||||||
// Look up multiple symbols in the symbol table and return a set of
|
// Look up multiple symbols in the symbol table and return a set of
|
||||||
// ModuleProviders that define those symbols.
|
// ModuleProviders that define those symbols.
|
||||||
void
|
void
|
||||||
Archive::findModulesDefiningSymbols(const std::set<std::string>& symbols,
|
Archive::findModulesDefiningSymbols(std::set<std::string>& symbols,
|
||||||
std::set<ModuleProvider*>& result)
|
std::set<ModuleProvider*>& result)
|
||||||
{
|
{
|
||||||
assert(mapfile && base && "Can't findModulesDefiningSymbols on new archive");
|
assert(mapfile && base && "Can't findModulesDefiningSymbols on new archive");
|
||||||
@ -462,11 +462,22 @@ Archive::findModulesDefiningSymbols(const std::set<std::string>& symbols,
|
|||||||
// At this point we have a valid symbol table (one way or another) so we
|
// At this point we have a valid symbol table (one way or another) so we
|
||||||
// just use it to quickly find the symbols requested.
|
// just use it to quickly find the symbols requested.
|
||||||
|
|
||||||
for (std::set<std::string>::const_iterator I=symbols.begin(),
|
for (std::set<std::string>::iterator I=symbols.begin(),
|
||||||
E=symbols.end(); I != E; ++I) {
|
E=symbols.end(); I != E;) {
|
||||||
|
// See if this symbol exists
|
||||||
ModuleProvider* mp = findModuleDefiningSymbol(*I);
|
ModuleProvider* mp = findModuleDefiningSymbol(*I);
|
||||||
if (mp) {
|
if (mp) {
|
||||||
|
// The symbol exists, insert the ModuleProvider into our result,
|
||||||
|
// duplicates wil be ignored
|
||||||
result.insert(mp);
|
result.insert(mp);
|
||||||
|
|
||||||
|
// Remove the symbol now that its been resolved, being careful to
|
||||||
|
// not invalidate our iterator.
|
||||||
|
std::set<std::string>::iterator save = I;
|
||||||
|
++I;
|
||||||
|
symbols.erase(save);
|
||||||
|
} else {
|
||||||
|
++I;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user