Use std::function instead of llvm::function_ref.
authorRui Ueyama <ruiu@google.com>
Thu, 17 Jul 2014 21:23:52 +0000 (21:23 +0000)
committerRui Ueyama <ruiu@google.com>
Thu, 17 Jul 2014 21:23:52 +0000 (21:23 +0000)
llvm-svn: 213312

lld/include/lld/Core/InputGraph.h
lld/lib/Core/InputGraph.cpp
lld/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp

index 7232e02..1b357a2 100644 (file)
@@ -24,6 +24,7 @@
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/raw_ostream.h"
 
+#include <functional>
 #include <memory>
 #include <stack>
 #include <vector>
@@ -71,7 +72,7 @@ public:
   /// Adds an observer of getNextFile(). Each time a new file is about to be
   /// returned from getNextFile(), registered observers are called with the file
   /// being returned.
-  void registerObserver(llvm::function_ref<void(File *)> fn);
+  void registerObserver(std::function<void(File *)>);
 
   /// \brief Adds a node into the InputGraph
   void addInputElement(std::unique_ptr<InputElement>);
@@ -99,7 +100,7 @@ protected:
   // Index of the next element to be processed
   uint32_t _nextElementIndex;
   InputElement *_currentInputElement;
-  std::vector<llvm::function_ref<void(File *)>> _observers;
+  std::vector<std::function<void(File *)>> _observers;
 
 private:
   ErrorOr<InputElement *> getNextInputElement();
index 5d8009f..d086eb6 100644 (file)
@@ -38,7 +38,7 @@ ErrorOr<File &> InputGraph::getNextFile() {
 
 void InputGraph::notifyProgress() { _currentInputElement->notifyProgress(); }
 
-void InputGraph::registerObserver(llvm::function_ref<void(File *)> fn) {
+void InputGraph::registerObserver(std::function<void(File *)> fn) {
   _observers.push_back(fn);
 }
 
index a33efc8..67cc919 100644 (file)
@@ -101,20 +101,6 @@ std::unique_ptr<File> PECOFFLinkingContext::createUndefinedSymbolFile() const {
       "<command line option /include>");
 }
 
-namespace {
-// As per policy, we cannot use std::function.
-class ObserverCallback {
-public:
-  explicit ObserverCallback(pecoff::ExportedSymbolRenameFile *f)
-      : _renameFile(f) {}
-
-  void operator()(File *file) { _renameFile->addResolvableSymbols(file); }
-
-private:
-  pecoff::ExportedSymbolRenameFile *_renameFile;
-};
-} // end anonymous namespace
-
 bool PECOFFLinkingContext::createImplicitFiles(
     std::vector<std::unique_ptr<File>> &) const {
   // Create a file for __ImageBase.
@@ -140,7 +126,7 @@ bool PECOFFLinkingContext::createImplicitFiles(
   exportNode->appendInputFile(std::unique_ptr<File>(renameFile));
   getLibraryGroup()->addFile(std::move(exportNode));
   getInputGraph().registerObserver(
-      *(new (_allocator) ObserverCallback(renameFile)));
+      [=](File *file) { renameFile->addResolvableSymbols(file); });
   return true;
 }