[PECOFF] Parameterize ResovalbeSymbols object.

So that it can be shared by multiple input files.

llvm-svn: 213699
This commit is contained in:
Rui Ueyama 2014-07-22 22:55:06 +00:00
parent f7acddde5b
commit 97d7c29fbc
2 changed files with 10 additions and 10 deletions

View File

@ -232,14 +232,13 @@ private:
// next visit.
class ExportedSymbolRenameFile : public impl::VirtualArchiveLibraryFile {
public:
ExportedSymbolRenameFile(const PECOFFLinkingContext &ctx)
: VirtualArchiveLibraryFile("<export>") {
ExportedSymbolRenameFile(const PECOFFLinkingContext &ctx,
std::shared_ptr<ResolvableSymbols> syms)
: VirtualArchiveLibraryFile("<export>"), _syms(syms) {
for (const PECOFFLinkingContext::ExportDesc &desc : ctx.getDllExports())
_exportedSyms.insert(desc.name);
}
void addResolvableSymbols(File *file) { _syms.add(file); }
const File *find(StringRef sym, bool dataSymbolOnly) const override {
if (_exportedSyms.count(sym) == 0)
return nullptr;
@ -254,7 +253,7 @@ private:
// by @number suffix.
bool findSymbolWithAtsignSuffix(std::string sym, std::string &res) const {
sym.append("@");
const std::set<std::string> &defined = _syms.defined();
const std::set<std::string> &defined = _syms->defined();
auto it = defined.lower_bound(sym);
for (auto e = defined.end(); it != e; ++it) {
if (!StringRef(*it).startswith(sym))
@ -271,7 +270,7 @@ private:
}
std::set<std::string> _exportedSyms;
mutable ResolvableSymbols _syms;
mutable std::shared_ptr<ResolvableSymbols> _syms;
mutable llvm::BumpPtrAllocator _alloc;
};

View File

@ -119,14 +119,15 @@ bool PECOFFLinkingContext::createImplicitFiles(
getInputGraph().insertElementAt(std::move(impFileNode),
InputGraph::Position::END);
std::shared_ptr<pecoff::ResolvableSymbols> syms(
new pecoff::ResolvableSymbols());
getInputGraph().registerObserver([=](File *file) { syms->add(file); });
// Create a file for dllexported symbols.
std::unique_ptr<SimpleFileNode> exportNode(new SimpleFileNode("<export>"));
pecoff::ExportedSymbolRenameFile *renameFile =
new pecoff::ExportedSymbolRenameFile(*this);
auto *renameFile = new pecoff::ExportedSymbolRenameFile(*this, syms);
exportNode->appendInputFile(std::unique_ptr<File>(renameFile));
getLibraryGroup()->addFile(std::move(exportNode));
getInputGraph().registerObserver(
[=](File *file) { renameFile->addResolvableSymbols(file); });
return true;
}