llvm.org GIT mirror llvm / d29bdc7
tools: avoid use of std::function Remove the use of the std::function and replace the capturing lambda with a non-capturing one, opting to pass the user data down to the context. This is needed as std::function is not yet available on all hosted platforms (it requires RTTI, which breaks on Windows). Thanks to Nico Rieck for pointing this out! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209607 91177308-0d34-0410-b5e6-96231b3b80d8 Saleem Abdulrasool 6 years ago
3 changed file(s) with 14 addition(s) and 12 deletion(s). Raw diff Collapse all Expand all
848848 case COFF::IMAGE_FILE_MACHINE_AMD64: {
849849 Win64EH::Dumper Dumper(W);
850850 Win64EH::Dumper::SymbolResolver Resolver =
851 [this](const object::coff_section *Section, uint64_t Offset,
852 SymbolRef &Symbol) -> error_code {
853 return this->resolveSymbol(Section, Offset, Symbol);
851 [](const object::coff_section *Section, uint64_t Offset,
852 SymbolRef &Symbol, void *user_data) -> error_code {
853 COFFDumper *Dumper = reinterpret_cast(user_data);
854 return Dumper->resolveSymbol(Section, Offset, Symbol);
854855 };
855 Win64EH::Dumper::Context Ctx(*Obj, Resolver);
856 Win64EH::Dumper::Context Ctx(*Obj, Resolver, this);
856857 Dumper.printData(Ctx);
857858 break;
858859 }
119119
120120 StringRef Name;
121121 SymbolRef Symbol;
122 if (Ctx.ResolveSymbol(Section, Offset, Symbol) || Symbol.getName(Name)) {
122 if (Ctx.ResolveSymbol(Section, Offset, Symbol, Ctx.UserData) ||
123 Symbol.getName(Name)) {
123124 OS << format(" (0x%" PRIX64 ")", Offset);
124125 return OS.str();
125126 }
138139 const coff_section *&ResolvedSection,
139140 uint64_t &ResolvedAddress) {
140141 SymbolRef Symbol;
141 if (error_code EC = Ctx.ResolveSymbol(Section, Offset, Symbol))
142 if (error_code EC = Ctx.ResolveSymbol(Section, Offset, Symbol, Ctx.UserData))
142143 return EC;
143144
144145 if (error_code EC = Symbol.getAddress(ResolvedAddress))
1212 #include "StreamWriter.h"
1313 #include "llvm/Support/Win64EH.h"
1414
15 #include
16
1715 namespace llvm {
1816 namespace object {
1917 class COFFObjectFile;
2725 raw_ostream &OS;
2826
2927 public:
30 typedef std::function
31 object::SymbolRef &)> SymbolResolver;
28 typedef error_code (*SymbolResolver)(const object::coff_section *, uint64_t,
29 object::SymbolRef &, void *);
3230
3331 struct Context {
3432 const object::COFFObjectFile &COFF;
3533 SymbolResolver ResolveSymbol;
34 void *UserData;
3635
37 Context(const object::COFFObjectFile &COFF, SymbolResolver Resolver)
38 : COFF(COFF), ResolveSymbol(Resolver) {}
36 Context(const object::COFFObjectFile &COFF, SymbolResolver Resolver,
37 void *UserData)
38 : COFF(COFF), ResolveSymbol(Resolver), UserData(UserData) {}
3939 };
4040
4141 private: