Fix a bug in codegenprep where it was losing track of values OptimizeMemoryInst
[oota-llvm.git] / tools / obj2yaml / coff2yaml.cpp
index 4a8ffbd81e20ff54371d570f112656d7086cf92d..5106a4a44b60fd8919ba63fc6977e22b5e37f52e 100644 (file)
@@ -202,8 +202,6 @@ RelocationTypesARMPairs [] = {
 };
 #undef STRING_PAIR
 
-namespace yaml {  // COFF-specific yaml-writing specific routines
-
 static raw_ostream &writeName(raw_ostream &Out,
                               const char *Name, std::size_t NameSize) {
   for (std::size_t i = 0; i < NameSize; ++i) {
@@ -224,8 +222,6 @@ static raw_ostream &writeBitMask(raw_ostream &Out,
   return Out;
 }
 
-} // end of yaml namespace
-
 // Given an array of pod_pair<enum, const char *>, look up a value
 template <typename T, std::size_t N>
 const char *nameLookup(const pod_pair<T, const char *> (&Arr)[N],
@@ -237,21 +233,18 @@ const char *nameLookup(const pod_pair<T, const char *> (&Arr)[N],
   return NotFound;
 }
 
-
-static raw_ostream &yamlCOFFHeader(const object::coff_file_header *Header,
-                                   raw_ostream &Out) {
-
+static void yamlCOFFHeader(const object::coff_file_header *Header,
+                           raw_ostream &Out) {
   Out << "header: !Header\n";
   Out << "  Machine: ";
   Out << nameLookup(MachineTypePairs, Header->Machine, "# Unknown_MachineTypes")
       << " # (";
-  return yaml::writeHexNumber(Out, Header->Machine) << ")\n\n";
+  objyaml::writeHexNumber(Out, Header->Machine) << ")\n\n";
 }
 
 
-static raw_ostream &yamlCOFFSections(object::COFFObjectFile &Obj,
-                                     std::size_t NumSections,
-                                     raw_ostream &Out) {
+static void yamlCOFFSections(object::COFFObjectFile &Obj,
+                             std::size_t NumSections, raw_ostream &Out) {
   error_code ec;
   Out << "sections:\n";
   for (object::section_iterator iter = Obj.begin_sections();
@@ -260,21 +253,21 @@ static raw_ostream &yamlCOFFSections(object::COFFObjectFile &Obj,
 
     Out << "  - !Section\n";
     Out << "    Name: ";
-    yaml::writeName(Out, sect->Name, sizeof(sect->Name)) << '\n';
+    writeName(Out, sect->Name, sizeof(sect->Name)) << '\n';
 
     Out << "    Characteristics: [";
-    yaml::writeBitMask(Out, SectionCharacteristicsPairs1, sect->Characteristics);
+    writeBitMask(Out, SectionCharacteristicsPairs1, sect->Characteristics);
     Out << nameLookup(SectionCharacteristicsPairsAlignment,
         sect->Characteristics & 0x00F00000, "# Unrecognized_IMAGE_SCN_ALIGN")
         << ", ";
-    yaml::writeBitMask(Out, SectionCharacteristicsPairs2, sect->Characteristics);
+    writeBitMask(Out, SectionCharacteristicsPairs2, sect->Characteristics);
     Out << "] # ";
-    yaml::writeHexNumber(Out, sect->Characteristics) << '\n';
+    objyaml::writeHexNumber(Out, sect->Characteristics) << '\n';
 
     ArrayRef<uint8_t> sectionData;
     Obj.getSectionContents(sect, sectionData);
     Out << "    SectionData: ";
-    yaml::writeHexStream(Out, sectionData) << '\n';
+    objyaml::writeHexStream(Out, sectionData) << '\n';
     if (iter->begin_relocations() != iter->end_relocations())
       Out << "    Relocations:\n";
     for (object::relocation_iterator rIter = iter->begin_relocations();
@@ -283,7 +276,7 @@ static raw_ostream &yamlCOFFSections(object::COFFObjectFile &Obj,
 
         Out << "      - !Relocation\n";
         Out << "        VirtualAddress: " ;
-        yaml::writeHexNumber(Out, reloc->VirtualAddress) << '\n';
+        objyaml::writeHexNumber(Out, reloc->VirtualAddress) << '\n';
         Out << "        SymbolTableIndex: " << reloc->SymbolTableIndex << '\n';
         Out << "        Type: "
             << nameLookup(RelocationTypeX86Pairs, reloc->Type) << '\n';
@@ -292,12 +285,10 @@ static raw_ostream &yamlCOFFSections(object::COFFObjectFile &Obj,
       }
 
   }
-  return Out;
 }
 
-static raw_ostream& yamlCOFFSymbols(object::COFFObjectFile &Obj,
-                                    std::size_t NumSymbols,
-                                    raw_ostream &Out) {
+static void yamlCOFFSymbols(object::COFFObjectFile &Obj, std::size_t NumSymbols,
+                            raw_ostream &Out) {
   error_code ec;
   Out << "symbols:\n";
   for (object::symbol_iterator iter = Obj.begin_symbols();
@@ -336,13 +327,11 @@ static raw_ostream& yamlCOFFSymbols(object::COFFObjectFile &Obj,
       Out << "    NumberOfAuxSymbols: "
           << (int) symbol->NumberOfAuxSymbols << '\n';
       Out << "    AuxillaryData: ";
-      yaml::writeHexStream(Out, aux);
+      objyaml::writeHexStream(Out, aux);
     }
 
     Out << '\n';
   }
-
-  return Out;
 }