[llvm-commits] [llvm] r75898 - in /llvm/trunk/lib/CodeGen: ELF.h ELFWriter.cpp ELFWriter.h

Bruno Cardoso Lopes bruno.cardoso at gmail.com
Wed Jul 15 23:26:49 PDT 2009


Author: bruno
Date: Thu Jul 16 01:26:41 2009
New Revision: 75898

URL: http://llvm.org/viewvc/llvm-project?rev=75898&view=rev
Log:
Fix coding style issues pointed by Bill.

Modified:
    llvm/trunk/lib/CodeGen/ELF.h
    llvm/trunk/lib/CodeGen/ELFWriter.cpp
    llvm/trunk/lib/CodeGen/ELFWriter.h

Modified: llvm/trunk/lib/CodeGen/ELF.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ELF.h?rev=75898&r1=75897&r2=75898&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/ELF.h (original)
+++ llvm/trunk/lib/CodeGen/ELF.h Thu Jul 16 01:26:41 2009
@@ -72,17 +72,17 @@
     unsigned SymTabIdx;
 
     enum {
-      STB_LOCAL = 0,
-      STB_GLOBAL = 1,
-      STB_WEAK = 2
+      STB_LOCAL = 0,  // Local sym, not visible outside obj file containing def
+      STB_GLOBAL = 1, // Global sym, visible to all object files being combined
+      STB_WEAK = 2    // Weak symbol, like global but lower-precedence
     };
 
     enum {
-      STT_NOTYPE = 0,
-      STT_OBJECT = 1,
-      STT_FUNC = 2,
-      STT_SECTION = 3,
-      STT_FILE = 4
+      STT_NOTYPE = 0,  // Symbol's type is not specified
+      STT_OBJECT = 1,  // Symbol is a data object (variable, array, etc.)
+      STT_FUNC = 2,    // Symbol is executable code (function, etc.)
+      STT_SECTION = 3, // Symbol refers to a section
+      STT_FILE = 4     // Local, absolute symbol that refers to a file
     };
 
     enum {

Modified: llvm/trunk/lib/CodeGen/ELFWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ELFWriter.cpp?rev=75898&r1=75897&r2=75898&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/ELFWriter.cpp (original)
+++ llvm/trunk/lib/CodeGen/ELFWriter.cpp Thu Jul 16 01:26:41 2009
@@ -456,8 +456,8 @@
 void ELFWriter::EmitRelocations() {
 
   // Create Relocation sections for each section which needs it.
-  for (unsigned i=0, e=SectionList.size(); i < e; ++i) {
-    ELFSection &S = *SectionList[i];
+  for (ELFSectionIter I=SectionList.begin(), E=SectionList.end(); I != E; ++I) {
+    ELFSection &S = *(*I);
 
     // This section does not have relocations
     if (!S.hasRelocations()) continue;
@@ -581,8 +581,8 @@
   // Walk on the symbol list and write symbol names into the
   // string table.
   unsigned Index = 1;
-  for (unsigned i = 0, e = SymbolList.size(); i < e; ++i) {
-    ELFSym &Sym = *SymbolList[i];
+  for (ELFSymIter I=SymbolList.begin(), E=SymbolList.end(); I != E; ++I) {
+    ELFSym &Sym = *(*I);
 
     // Use the name mangler to uniquify the LLVM symbol.
     std::string Name;
@@ -606,23 +606,23 @@
 // all other symbols with non-local bindings. The return value is
 // the position of the first non local symbol.
 unsigned ELFWriter::SortSymbols() {
-  unsigned FirstNonLocalSymbol, i, e;
+  unsigned FirstNonLocalSymbol;
   std::vector<ELFSym*> LocalSyms, OtherSyms;
 
-  for (i = 0, e = SymbolList.size(); i < e; ++i) {
-    if (SymbolList[i]->isLocalBind())
-      LocalSyms.push_back(SymbolList[i]);
+  for (ELFSymIter I=SymbolList.begin(), E=SymbolList.end(); I != E; ++I) {
+    if ((*I)->isLocalBind())
+      LocalSyms.push_back(*I);
     else
-      OtherSyms.push_back(SymbolList[i]);
+      OtherSyms.push_back(*I);
   }
   SymbolList.clear();
   FirstNonLocalSymbol = LocalSyms.size();
 
-  for (i = 0; i < FirstNonLocalSymbol; ++i)
+  for (unsigned i = 0; i < FirstNonLocalSymbol; ++i)
     SymbolList.push_back(LocalSyms[i]);
 
-  for (i = 0, e = OtherSyms.size(); i < e; ++i)
-    SymbolList.push_back(OtherSyms[i]);
+  for (ELFSymIter I=OtherSyms.begin(), E=OtherSyms.end(); I != E; ++I)
+    SymbolList.push_back(*I);
 
   LocalSyms.clear();
   OtherSyms.clear();
@@ -685,14 +685,15 @@
   // the string table.
   unsigned Index = 0;
 
-  for (unsigned i=0, e=SectionList.size(); i < e; ++i) {
+  for (ELFSectionIter I=SectionList.begin(), E=SectionList.end(); I != E; ++I) {
+    ELFSection &S = *(*I);
     // Set the index into the table.  Note if we have lots of entries with
     // common suffixes, we could memoize them here if we cared.
-    SectionList[i]->NameIdx = Index;
-    SHStrTab.emitString(SectionList[i]->getName());
+    S.NameIdx = Index;
+    SHStrTab.emitString(S.getName());
 
     // Keep track of the number of bytes emitted to this section.
-    Index += SectionList[i]->getName().size()+1;
+    Index += S.getName().size()+1;
   }
 
   // Set the size of .shstrtab now that we know what it is.
@@ -748,8 +749,8 @@
   BinaryObject SHdrTable(isLittleEndian, is64Bit);
 
   // Emit all of sections to the file and build the section header table.
-  for (unsigned i=0, e=SectionList.size(); i < e; ++i) {
-    ELFSection &S = *SectionList[i];
+  for (ELFSectionIter I=SectionList.begin(), E=SectionList.end(); I != E; ++I) {
+    ELFSection &S = *(*I);
     DOUT << "SectionIdx: " << S.SectionIdx << ", Name: " << S.getName()
          << ", Size: " << S.Size << ", Offset: " << S.Offset
          << ", SectionData Size: " << S.size() << "\n";

Modified: llvm/trunk/lib/CodeGen/ELFWriter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ELFWriter.h?rev=75898&r1=75897&r2=75898&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/ELFWriter.h (original)
+++ llvm/trunk/lib/CodeGen/ELFWriter.h Thu Jul 16 01:26:41 2009
@@ -34,6 +34,9 @@
   class TargetELFWriterInfo;
   class raw_ostream;
 
+  typedef std::vector<ELFSym*>::iterator ELFSymIter;
+  typedef std::vector<ELFSection*>::iterator ELFSectionIter;
+
   /// ELFWriter - This class implements the common target-independent code for
   /// writing ELF files.  Targets should derive a class from this to
   /// parameterize the output format.





More information about the llvm-commits mailing list