#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/raw_ostream.h"
+#include <functional>
#include <memory>
#include <stack>
#include <vector>
/// 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>);
// 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();
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);
}
"<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.
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;
}