function_refify. NFC.

While there use emplace_back to create an expensive pair.

llvm-svn: 274344
This commit is contained in:
Benjamin Kramer 2016-07-01 11:05:15 +00:00
parent 2290e3d147
commit a8509b51f9
2 changed files with 6 additions and 10 deletions

View File

@ -67,8 +67,7 @@ public:
/// symbol found and the associated flags.
static void CollectAsmUndefinedRefs(
const Triple &TheTriple, StringRef InlineAsm,
const std::function<void(StringRef, BasicSymbolRef::Flags)> &
AsmUndefinedRefs);
function_ref<void(StringRef, BasicSymbolRef::Flags)> AsmUndefinedRefs);
/// \brief Finds and returns bitcode in the given memory buffer (which may
/// be either a bitcode file or a native object file with embedded bitcode),

View File

@ -38,20 +38,17 @@ using namespace object;
IRObjectFile::IRObjectFile(MemoryBufferRef Object, std::unique_ptr<Module> Mod)
: SymbolicFile(Binary::ID_IR, Object), M(std::move(Mod)) {
Mang.reset(new Mangler());
CollectAsmUndefinedRefs(
Triple(M->getTargetTriple()), M->getModuleInlineAsm(),
[this](StringRef Name, BasicSymbolRef::Flags Flags) {
AsmSymbols.push_back(
std::make_pair<std::string, uint32_t>(Name, std::move(Flags)));
});
CollectAsmUndefinedRefs(Triple(M->getTargetTriple()), M->getModuleInlineAsm(),
[this](StringRef Name, BasicSymbolRef::Flags Flags) {
AsmSymbols.emplace_back(Name, std::move(Flags));
});
}
// Parse inline ASM and collect the list of symbols that are not defined in
// the current module. This is inspired from IRObjectFile.
void IRObjectFile::CollectAsmUndefinedRefs(
const Triple &TT, StringRef InlineAsm,
const std::function<void(StringRef, BasicSymbolRef::Flags)> &
AsmUndefinedRefs) {
function_ref<void(StringRef, BasicSymbolRef::Flags)> AsmUndefinedRefs) {
if (InlineAsm.empty())
return;