diff options
author | Simon Atanasyan <simon@atanasyan.com> | 2014-04-06 09:02:55 +0000 |
---|---|---|
committer | Simon Atanasyan <simon@atanasyan.com> | 2014-04-06 09:02:55 +0000 |
commit | cde97ea514e4b3a4c9c23db1cee865e8b188b426 (patch) | |
tree | 09f1238bd160705b9061b2f237fa264e1f9a52f5 /tools/yaml2obj/yaml2elf.cpp | |
parent | 1c41705d34fa0257eeea0e2141eb574fa3130ced (diff) | |
download | llvm-cde97ea514e4b3a4c9c23db1cee865e8b188b426.tar.gz llvm-cde97ea514e4b3a4c9c23db1cee865e8b188b426.tar.bz2 llvm-cde97ea514e4b3a4c9c23db1cee865e8b188b426.tar.xz |
[yaml2obj][ELF] Rename class SectionNameToIdxMap => NameToIdxMap. It can
be used for indexing not only section's names.
No functional changes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205687 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/yaml2obj/yaml2elf.cpp')
-rw-r--r-- | tools/yaml2obj/yaml2elf.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/tools/yaml2obj/yaml2elf.cpp b/tools/yaml2obj/yaml2elf.cpp index 21506d9a32..4e9ee4dcd6 100644 --- a/tools/yaml2obj/yaml2elf.cpp +++ b/tools/yaml2obj/yaml2elf.cpp @@ -94,23 +94,23 @@ public: }; } // end anonymous namespace -// Used to keep track of section names, so that in the YAML file sections -// can be referenced by name instead of by index. +// Used to keep track of section and symbol names, so that in the YAML file +// sections and symbols can be referenced by name instead of by index. namespace { -class SectionNameToIdxMap { +class NameToIdxMap { StringMap<int> Map; public: /// \returns true if name is already present in the map. - bool addName(StringRef SecName, unsigned i) { - StringMapEntry<int> &Entry = Map.GetOrCreateValue(SecName, -1); + bool addName(StringRef Name, unsigned i) { + StringMapEntry<int> &Entry = Map.GetOrCreateValue(Name, -1); if (Entry.getValue() != -1) return true; Entry.setValue((int)i); return false; } /// \returns true if name is not present in the map - bool lookupSection(StringRef SecName, unsigned &Idx) const { - StringMap<int>::const_iterator I = Map.find(SecName); + bool lookup(StringRef Name, unsigned &Idx) const { + StringMap<int>::const_iterator I = Map.find(Name); if (I == Map.end()) return true; Idx = I->getValue(); @@ -150,7 +150,7 @@ class ELFState { /// \brief The future ".shstrtab" section. StringTableBuilder DotShStrtab; - SectionNameToIdxMap SN2I; + NameToIdxMap SN2I; const ELFYAML::Object &Doc; bool buildSectionIndex(); @@ -229,7 +229,7 @@ bool ELFState<ELFT>::initSectionHeaders(std::vector<Elf_Shdr> &SHeaders, if (!Sec.Link.empty()) { unsigned Index; - if (SN2I.lookupSection(Sec.Link, Index)) { + if (SN2I.lookup(Sec.Link, Index)) { errs() << "error: Unknown section referenced: '" << Sec.Link << "' at YAML section '" << Sec.Name << "'.\n"; return false;; @@ -295,7 +295,7 @@ void ELFState<ELFT>::addSymbols(const std::vector<ELFYAML::Symbol> &Symbols, Symbol.setBindingAndType(SymbolBinding, Sym.Type); if (!Sym.Section.empty()) { unsigned Index; - if (SN2I.lookupSection(Sym.Section, Index)) { + if (SN2I.lookup(Sym.Section, Index)) { errs() << "error: Unknown section referenced: '" << Sym.Section << "' by YAML symbol " << Sym.Name << ".\n"; exit(1); |