[ELF] Replace std::set with StringSet.
authorShankar Easwaran <shankare@codeaurora.org>
Fri, 13 Feb 2015 22:26:51 +0000 (22:26 +0000)
committerShankar Easwaran <shankare@codeaurora.org>
Fri, 13 Feb 2015 22:26:51 +0000 (22:26 +0000)
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.

llvm-svn: 229165

lld/include/lld/ReaderWriter/ELFLinkingContext.h
lld/lib/ReaderWriter/ELF/ELFFile.h
lld/lib/ReaderWriter/ELF/ELFLinkingContext.cpp

index 3bfcfcb..a4eae3c 100644 (file)
@@ -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;
index f46a869..7d2a4a3 100644 (file)
@@ -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 ELFFile<ELFT>::createAtomsFromContext() {
   // 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));
index d4f19aa..90a7698 100644 (file)
@@ -256,14 +256,4 @@ std::string ELFLinkingContext::demangle(StringRef symbolName) const {
   return symbolName;
 }
 
-// Support --wrap option.
-void ELFLinkingContext::addWrapForSymbol(StringRef symbol) {
-  _wrapCalls.insert(symbol);
-}
-
-range<ELFLinkingContext::StringRefSetIterT>
-ELFLinkingContext::wrapCalls() const {
-  return _wrapCalls;
-}
-
 } // end namespace lld