Skip to content

Commit

Permalink
Simplify WinCOFFObjectWriter by removing a template member function.
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295126 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
rui314 committed Feb 14, 2017
1 parent 7c1b5b0 commit 6b607dc
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions lib/MC/WinCOFFObjectWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,6 @@ class WinCOFFObjectWriter : public MCObjectWriter {
COFFSymbol *GetOrCreateCOFFSymbol(const MCSymbol *Symbol);
COFFSection *createSection(StringRef Name);

template <typename object_t, typename list_t>
object_t *createCOFFEntity(StringRef Name, list_t &List);

void defineSection(MCSectionCOFF const &Sec);

COFFSymbol *getLinkedSymbol(const MCSymbol &Symbol);
Expand Down Expand Up @@ -226,27 +223,20 @@ WinCOFFObjectWriter::WinCOFFObjectWriter(MCWinCOFFObjectTargetWriter *MOTW,
}

COFFSymbol *WinCOFFObjectWriter::createSymbol(StringRef Name) {
return createCOFFEntity<COFFSymbol>(Name, Symbols);
Symbols.push_back(make_unique<COFFSymbol>(Name));
return Symbols.back().get();
}

COFFSymbol *WinCOFFObjectWriter::GetOrCreateCOFFSymbol(const MCSymbol *Symbol) {
COFFSymbol *&Ret = SymbolMap[Symbol];
if (!Ret)
Ret = createCOFFEntity<COFFSymbol>(Symbol->getName(), Symbols);
Ret = createSymbol(Symbol->getName());
return Ret;
}

COFFSection *WinCOFFObjectWriter::createSection(StringRef Name) {
return createCOFFEntity<COFFSection>(Name, Sections);
}

/// A template used to lookup or create a symbol/section, and initialize it if
/// needed.
template <typename object_t, typename list_t>
object_t *WinCOFFObjectWriter::createCOFFEntity(StringRef Name, list_t &List) {
List.push_back(make_unique<object_t>(Name));

return List.back().get();
Sections.emplace_back(make_unique<COFFSection>(Name));
return Sections.back().get();
}

/// This function takes a section data object from the assembler
Expand Down

0 comments on commit 6b607dc

Please sign in to comment.