[lld] r229165 - [ELF] Replace std::set with StringSet.
Shankar Easwaran
shankare at codeaurora.org
Fri Feb 13 14:26:52 PST 2015
Author: shankare
Date: Fri Feb 13 16:26:51 2015
New Revision: 229165
URL: http://llvm.org/viewvc/llvm-project?rev=229165&view=rev
Log:
[ELF] Replace std::set with StringSet.
Wrap functionality was using a std::set to record symbols that need to be
wrapped. This changes the implementation to use a StringSet instead.
No change in functionality.
Modified:
lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h
lld/trunk/lib/ReaderWriter/ELF/ELFFile.h
lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp
Modified: lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h?rev=229165&r1=229164&r2=229165&view=diff
==============================================================================
--- lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h (original)
+++ lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h Fri Feb 13 16:26:51 2015
@@ -48,8 +48,6 @@ public:
class ELFLinkingContext : public LinkingContext {
public:
- typedef std::set<StringRef>::iterator StringRefSetIterT;
-
/// \brief The type of ELF executable that the linker
/// creates.
enum class OutputMagic : uint8_t {
@@ -300,9 +298,9 @@ public:
}
// --wrap option.
- void addWrapForSymbol(StringRef);
+ void addWrapForSymbol(StringRef sym) { _wrapCalls.insert(sym); }
- range<std::set<StringRef>::iterator> wrapCalls() const;
+ const llvm::StringSet<> &wrapCalls() const { return _wrapCalls; }
private:
ELFLinkingContext() LLVM_DELETED_FUNCTION;
@@ -343,7 +341,7 @@ protected:
StringRef _soname;
StringRefVector _rpathList;
StringRefVector _rpathLinkList;
- std::set<StringRef> _wrapCalls;
+ llvm::StringSet<> _wrapCalls;
std::map<std::string, uint64_t> _absoluteSymbols;
llvm::StringSet<> _dynamicallyExportedSymbols;
std::vector<std::unique_ptr<script::Parser>> _scripts;
Modified: lld/trunk/lib/ReaderWriter/ELF/ELFFile.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ELFFile.h?rev=229165&r1=229164&r2=229165&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/ELFFile.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/ELFFile.h Fri Feb 13 16:26:51 2015
@@ -17,6 +17,7 @@
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/StringSet.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/Object/ELF.h"
#include "llvm/Object/ObjectFile.h"
@@ -763,18 +764,19 @@ template <class ELFT> std::error_code EL
// c) All references to the symbol specified by wrap should point to
// __wrap_<symbolname>
// d) All references to __real_symbol should point to the <symbol>
- for (auto wrapsym : _ctx.wrapCalls()) {
+ for (auto &wrapsym : _ctx.wrapCalls()) {
+ StringRef wrapStr = wrapsym.getKey();
// Create a undefined symbol fror the wrap symbol.
UndefinedAtom *wrapSymAtom =
- new (_readerStorage) SimpleUndefinedAtom(*this, wrapsym);
+ new (_readerStorage) SimpleUndefinedAtom(*this, wrapStr);
StringRef wrapCallSym =
- _ctx.allocateString((llvm::Twine("__wrap_") + wrapsym).str());
+ _ctx.allocateString((llvm::Twine("__wrap_") + wrapStr).str());
StringRef realCallSym =
- _ctx.allocateString((llvm::Twine("__real_") + wrapsym).str());
+ _ctx.allocateString((llvm::Twine("__real_") + wrapStr).str());
UndefinedAtom *wrapCallAtom =
new (_readerStorage) SimpleUndefinedAtom(*this, wrapCallSym);
// Create maps, when there is call to sym, it should point to wrapCallSym.
- _wrapSymbolMap.insert(std::make_pair(wrapsym, wrapCallAtom));
+ _wrapSymbolMap.insert(std::make_pair(wrapStr, wrapCallAtom));
// Whenever there is a reference to realCall it should point to the symbol
// created for each wrap usage.
_wrapSymbolMap.insert(std::make_pair(realCallSym, wrapSymAtom));
Modified: lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp?rev=229165&r1=229164&r2=229165&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp Fri Feb 13 16:26:51 2015
@@ -256,14 +256,4 @@ std::string ELFLinkingContext::demangle(
return symbolName;
}
-// Support --wrap option.
-void ELFLinkingContext::addWrapForSymbol(StringRef symbol) {
- _wrapCalls.insert(symbol);
-}
-
-range<ELFLinkingContext::StringRefSetIterT>
-ELFLinkingContext::wrapCalls() const {
- return _wrapCalls;
-}
-
} // end namespace lld
More information about the llvm-commits
mailing list