llvm.org GIT mirror llvm / cde97ea
[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 Simon Atanasyan 5 years ago
1 changed file(s) with 10 addition(s) and 10 deletion(s). Raw diff Collapse all Expand all
9393 };
9494 } // end anonymous namespace
9595
96 // Used to keep track of section names, so that in the YAML file sections
97 // can be referenced by name instead of by index.
96 // Used to keep track of section and symbol names, so that in the YAML file
97 // sections and symbols can be referenced by name instead of by index.
9898 namespace {
99 class SectionNameToIdxMap {
99 class NameToIdxMap {
100100 StringMap Map;
101101 public:
102102 /// \returns true if name is already present in the map.
103 bool addName(StringRef SecName, unsigned i) {
104 StringMapEntry &Entry = Map.GetOrCreateValue(SecName, -1);
103 bool addName(StringRef Name, unsigned i) {
104 StringMapEntry &Entry = Map.GetOrCreateValue(Name, -1);
105105 if (Entry.getValue() != -1)
106106 return true;
107107 Entry.setValue((int)i);
108108 return false;
109109 }
110110 /// \returns true if name is not present in the map
111 bool lookupSection(StringRef SecName, unsigned &Idx) const {
112 StringMap::const_iterator I = Map.find(SecName);
111 bool lookup(StringRef Name, unsigned &Idx) const {
112 StringMap::const_iterator I = Map.find(Name);
113113 if (I == Map.end())
114114 return true;
115115 Idx = I->getValue();
149149 /// \brief The future ".shstrtab" section.
150150 StringTableBuilder DotShStrtab;
151151
152 SectionNameToIdxMap SN2I;
152 NameToIdxMap SN2I;
153153 const ELFYAML::Object &Doc;
154154
155155 bool buildSectionIndex();
228228
229229 if (!Sec.Link.empty()) {
230230 unsigned Index;
231 if (SN2I.lookupSection(Sec.Link, Index)) {
231 if (SN2I.lookup(Sec.Link, Index)) {
232232 errs() << "error: Unknown section referenced: '" << Sec.Link
233233 << "' at YAML section '" << Sec.Name << "'.\n";
234234 return false;;
294294 Symbol.setBindingAndType(SymbolBinding, Sym.Type);
295295 if (!Sym.Section.empty()) {
296296 unsigned Index;
297 if (SN2I.lookupSection(Sym.Section, Index)) {
297 if (SN2I.lookup(Sym.Section, Index)) {
298298 errs() << "error: Unknown section referenced: '" << Sym.Section
299299 << "' by YAML symbol " << Sym.Name << ".\n";
300300 exit(1);