[llvm-commits] CVS: llvm/lib/Bytecode/Archive/Archive.cpp ArchiveInternals.h ArchiveReader.cpp ArchiveWriter.cpp

Misha Brukman brukman at cs.uiuc.edu
Thu Apr 21 14:13:29 PDT 2005



Changes in directory llvm/lib/Bytecode/Archive:

Archive.cpp updated: 1.7 -> 1.8
ArchiveInternals.h updated: 1.4 -> 1.5
ArchiveReader.cpp updated: 1.39 -> 1.40
ArchiveWriter.cpp updated: 1.17 -> 1.18
---
Log message:

Remove trailing whitespace


---
Diffs of the changes:  (+93 -93)

 Archive.cpp        |   26 +++++++++---------
 ArchiveInternals.h |   18 ++++++------
 ArchiveReader.cpp  |   76 ++++++++++++++++++++++++++---------------------------
 ArchiveWriter.cpp  |   66 +++++++++++++++++++++++-----------------------
 4 files changed, 93 insertions(+), 93 deletions(-)


Index: llvm/lib/Bytecode/Archive/Archive.cpp
diff -u llvm/lib/Bytecode/Archive/Archive.cpp:1.7 llvm/lib/Bytecode/Archive/Archive.cpp:1.8
--- llvm/lib/Bytecode/Archive/Archive.cpp:1.7	Thu Apr 21 12:49:57 2005
+++ llvm/lib/Bytecode/Archive/Archive.cpp	Thu Apr 21 16:13:18 2005
@@ -1,10 +1,10 @@
 //===-- Archive.cpp - Generic LLVM archive functions ------------*- C++ -*-===//
-// 
+//
 //                     The LLVM Compiler Infrastructure
 //
-// This file was developed by Reid Spencer and is distributed under the 
+// This file was developed by Reid Spencer and is distributed under the
 // University of Illinois Open Source License. See LICENSE.TXT for details.
-// 
+//
 //===----------------------------------------------------------------------===//
 //
 // This file contains the implementation of the Archive and ArchiveMember
@@ -30,7 +30,7 @@
     result += path.toString().length() + 1;
 
   // If its now odd lengthed, include the padding byte
-  if (result % 2 != 0 ) 
+  if (result % 2 != 0 )
     result++;
 
   return result;
@@ -38,27 +38,27 @@
 
 // This default constructor is only use by the ilist when it creates its
 // sentry node. We give it specific static values to make it stand out a bit.
-ArchiveMember::ArchiveMember() 
+ArchiveMember::ArchiveMember()
   : next(0), prev(0), parent(0), path("<invalid>"), flags(0), data(0)
 {
   info.user = sys::Process::GetCurrentUserId();
-  info.group = sys::Process::GetCurrentGroupId(); 
-  info.mode = 0777; 
-  info.fileSize = 0; 
+  info.group = sys::Process::GetCurrentGroupId();
+  info.mode = 0777;
+  info.fileSize = 0;
   info.modTime = sys::TimeValue::now();
 }
 
 // This is the constructor that the Archive class uses when it is building or
 // reading an archive. It just defaults a few things and ensures the parent is
-// set for the iplist. The Archive class fills in the ArchiveMember's data. 
-// This is required because correctly setting the data may depend on other 
+// set for the iplist. The Archive class fills in the ArchiveMember's data.
+// This is required because correctly setting the data may depend on other
 // things in the Archive.
 ArchiveMember::ArchiveMember(Archive* PAR)
   : next(0), prev(0), parent(PAR), path(), flags(0), data(0)
 {
 }
 
-// This method allows an ArchiveMember to be replaced with the data for a 
+// This method allows an ArchiveMember to be replaced with the data for a
 // different file, presumably as an update to the member. It also makes sure
 // the flags are reset correctly.
 void ArchiveMember::replaceWith(const sys::Path& newFile) {
@@ -128,9 +128,9 @@
 }
 
 // Archive constructor - this is the only constructor that gets used for the
-// Archive class. Everything else (default,copy) is deprecated. This just 
+// Archive class. Everything else (default,copy) is deprecated. This just
 // initializes and maps the file into memory, if requested.
-Archive::Archive(const sys::Path& filename, bool map ) 
+Archive::Archive(const sys::Path& filename, bool map )
   : archPath(filename), members(), mapfile(0), base(0), symTab(), strtab(),
     symTabSize(0), firstFileOffset(0), modules(), foreignST(0)
 {


Index: llvm/lib/Bytecode/Archive/ArchiveInternals.h
diff -u llvm/lib/Bytecode/Archive/ArchiveInternals.h:1.4 llvm/lib/Bytecode/Archive/ArchiveInternals.h:1.5
--- llvm/lib/Bytecode/Archive/ArchiveInternals.h:1.4	Tue Apr 19 22:52:59 2005
+++ llvm/lib/Bytecode/Archive/ArchiveInternals.h	Thu Apr 21 16:13:18 2005
@@ -1,10 +1,10 @@
 //===-- lib/Bytecode/ArchiveInternals.h -------------------------*- C++ -*-===//
-// 
+//
 //                     The LLVM Compiler Infrastructure
 //
-// This file was developed by Reid Spencer and is distributed under the 
+// This file was developed by Reid Spencer and is distributed under the
 // University of Illinois Open Source License. See LICENSE.TXT for details.
-// 
+//
 //===----------------------------------------------------------------------===//
 //
 // Internal implementation header for LLVM Archive files.
@@ -18,8 +18,8 @@
 #include "llvm/System/TimeValue.h"
 #include "llvm/ADT/StringExtras.h"
 
-#define ARFILE_MAGIC "!<arch>\n"                   ///< magic string 
-#define ARFILE_MAGIC_LEN (sizeof(ARFILE_MAGIC)-1)  ///< length of magic string 
+#define ARFILE_MAGIC "!<arch>\n"                   ///< magic string
+#define ARFILE_MAGIC_LEN (sizeof(ARFILE_MAGIC)-1)  ///< length of magic string
 #define ARFILE_SVR4_SYMTAB_NAME "/               " ///< SVR4 symtab entry name
 #define ARFILE_LLVM_SYMTAB_NAME "#_LLVM_SYM_TAB_#" ///< LLVM symtab entry name
 #define ARFILE_BSD4_SYMTAB_NAME "__.SYMDEF SORTED" ///< BSD4 symtab entry name
@@ -29,9 +29,9 @@
 
 namespace llvm {
 
-  /// The ArchiveMemberHeader structure is used internally for bytecode 
-  /// archives. 
-  /// The header precedes each file member in the archive. This structure is 
+  /// The ArchiveMemberHeader structure is used internally for bytecode
+  /// archives.
+  /// The header precedes each file member in the archive. This structure is
   /// defined using character arrays for direct and correct interpretation
   /// regardless of the endianess of the machine that produced it.
   /// @brief Archive File Member Header
@@ -39,7 +39,7 @@
     /// @name Data
     /// @{
     public:
-      char name[16];  ///< Name of the file member. 
+      char name[16];  ///< Name of the file member.
       char date[12];  ///< File date, decimal seconds since Epoch
       char uid[6];    ///< user id in ASCII decimal
       char gid[6];    ///< group id in ASCII decimal


Index: llvm/lib/Bytecode/Archive/ArchiveReader.cpp
diff -u llvm/lib/Bytecode/Archive/ArchiveReader.cpp:1.39 llvm/lib/Bytecode/Archive/ArchiveReader.cpp:1.40
--- llvm/lib/Bytecode/Archive/ArchiveReader.cpp:1.39	Sat Feb 26 16:00:32 2005
+++ llvm/lib/Bytecode/Archive/ArchiveReader.cpp	Thu Apr 21 16:13:18 2005
@@ -1,10 +1,10 @@
 //===-- ArchiveReader.cpp - Read LLVM archive files -------------*- C++ -*-===//
-// 
+//
 //                     The LLVM Compiler Infrastructure
 //
-// This file was developed by Reid Spencer and is distributed under the 
+// This file was developed by Reid Spencer and is distributed under the
 // University of Illinois Open Source License. See LICENSE.TXT for details.
-// 
+//
 //===----------------------------------------------------------------------===//
 //
 // Builds up standard unix archive files (.a) containing LLVM bytecode.
@@ -20,9 +20,9 @@
 inline unsigned readInteger(const char*&At, const char*End) {
   unsigned Shift = 0;
   unsigned Result = 0;
-  
+
   do {
-    if (At == End) 
+    if (At == End)
       throw std::string("Ran out of data reading vbr_uint!");
     Result |= (unsigned)((*At++) & 0x7F) << Shift;
     Shift += 7;
@@ -49,7 +49,7 @@
 
 // This member parses an ArchiveMemberHeader that is presumed to be pointed to
 // by At. The At pointer is updated to the byte just after the header, which
-// can be variable in size. 
+// can be variable in size.
 ArchiveMember*
 Archive::parseMemberHeader(const char*& At, const char* End) {
   assert(At + sizeof(ArchiveMemberHeader) < End && "Not enough data");
@@ -61,7 +61,7 @@
   // Instantiate the ArchiveMember to be filled
   ArchiveMember* member = new ArchiveMember(this);
 
-  // Extract the size and determine if the file is 
+  // Extract the size and determine if the file is
   // compressed or not (negative length).
   int flags = 0;
   int MemberSize = atoi(Hdr->size);
@@ -79,14 +79,14 @@
     throw std::string("invalid file member signature");
 
   // Convert and check the member name
-  // The empty name ( '/' and 15 blanks) is for a foreign (non-LLVM) symbol 
-  // table. The special name "//" and 14 blanks is for a string table, used 
+  // The empty name ( '/' and 15 blanks) is for a foreign (non-LLVM) symbol
+  // table. The special name "//" and 14 blanks is for a string table, used
   // for long file names. This library doesn't generate either of those but
-  // it will accept them. If the name starts with #1/ and the remainder is 
-  // digits, then those digits specify the length of the name that is 
-  // stored immediately following the header. The special name 
-  // __LLVM_SYM_TAB__ identifies the symbol table for LLVM bytecode. 
-  // Anything else is a regular, short filename that is terminated with 
+  // it will accept them. If the name starts with #1/ and the remainder is
+  // digits, then those digits specify the length of the name that is
+  // stored immediately following the header. The special name
+  // __LLVM_SYM_TAB__ identifies the symbol table for LLVM bytecode.
+  // Anything else is a regular, short filename that is terminated with
   // a '/' and blanks.
 
   std::string pathname;
@@ -101,7 +101,7 @@
           flags |= ArchiveMember::HasLongFilenameFlag;
         } else
           throw std::string("invalid long filename");
-      } else if (Hdr->name[1] == '_' && 
+      } else if (Hdr->name[1] == '_' &&
                  (0 == memcmp(Hdr->name, ARFILE_LLVM_SYMTAB_NAME, 16))) {
         // The member is using a long file name (>15 chars) format.
         // This format is standard for 4.4BSD and Mac OSX operating
@@ -152,7 +152,7 @@
       }
       break;
     case '_':
-      if (Hdr->name[1] == '_' && 
+      if (Hdr->name[1] == '_' &&
           (0 == memcmp(Hdr->name, ARFILE_BSD4_SYMTAB_NAME, 16))) {
         pathname.assign(ARFILE_BSD4_SYMTAB_NAME);
         flags |= ArchiveMember::BSD4SymbolTableFlag;
@@ -208,7 +208,7 @@
     throw std::string("invalid signature for an archive file");
 }
 
-// This function loads the entire archive and fully populates its ilist with 
+// This function loads the entire archive and fully populates its ilist with
 // the members of the archive file. This is typically used in preparation for
 // editing the contents of the archive.
 void
@@ -226,7 +226,7 @@
   bool seenSymbolTable = false;
   bool foundFirstFile = false;
   while (At < End) {
-    // parse the member header 
+    // parse the member header
     const char* Save = At;
     ArchiveMember* mbr = parseMemberHeader(At, End);
 
@@ -253,7 +253,7 @@
       if ((intptr_t(At) & 1) == 1)
         At++;
       delete mbr;
-    } else if (mbr->isLLVMSymbolTable()) { 
+    } else if (mbr->isLLVMSymbolTable()) {
       // This is the LLVM symbol table for the archive. If we've seen it
       // already, its an error. Otherwise, parse the symbol table and move on.
       if (seenSymbolTable)
@@ -300,9 +300,9 @@
 
   for (iterator I=begin(), E=end(); I != E; ++I) {
     if (I->isBytecode() || I->isCompressedBytecode()) {
-      std::string FullMemberName = archPath.toString() + 
+      std::string FullMemberName = archPath.toString() +
         "(" + I->getPath().toString() + ")";
-      Module* M = ParseBytecodeBuffer((const unsigned char*)I->getData(), 
+      Module* M = ParseBytecodeBuffer((const unsigned char*)I->getData(),
           I->getSize(), FullMemberName, ErrMessage);
       if (!M)
         return true;
@@ -365,8 +365,8 @@
     FirstFile = At;
   } else {
     // There's no symbol table in the file. We have to rebuild it from scratch
-    // because the intent of this method is to get the symbol table loaded so 
-    // it can be searched efficiently. 
+    // because the intent of this method is to get the symbol table loaded so
+    // it can be searched efficiently.
     // Add the member to the members list
     members.push_back(mbr);
   }
@@ -391,19 +391,19 @@
 
 // Look up one symbol in the symbol table and return a ModuleProvider for the
 // module that defines that symbol.
-ModuleProvider* 
+ModuleProvider*
 Archive::findModuleDefiningSymbol(const std::string& symbol) {
   SymTabType::iterator SI = symTab.find(symbol);
   if (SI == symTab.end())
     return 0;
 
-  // The symbol table was previously constructed assuming that the members were 
+  // The symbol table was previously constructed assuming that the members were
   // written without the symbol table header. Because VBR encoding is used, the
   // values could not be adjusted to account for the offset of the symbol table
   // because that could affect the size of the symbol table due to VBR encoding.
-  // We now have to account for this by adjusting the offset by the size of the 
+  // We now have to account for this by adjusting the offset by the size of the
   // symbol table and its header.
-  unsigned fileOffset = 
+  unsigned fileOffset =
     SI->second +                // offset in symbol-table-less file
     firstFileOffset;            // add offset to first "real" file in archive
 
@@ -417,10 +417,10 @@
   ArchiveMember* mbr = parseMemberHeader(modptr, base + mapfile->size());
 
   // Now, load the bytecode module to get the ModuleProvider
-  std::string FullMemberName = archPath.toString() + "(" + 
+  std::string FullMemberName = archPath.toString() + "(" +
     mbr->getPath().toString() + ")";
   ModuleProvider* mp = getBytecodeBufferModuleProvider(
-      (const unsigned char*) mbr->getData(), mbr->getSize(), 
+      (const unsigned char*) mbr->getData(), mbr->getSize(),
       FullMemberName, 0);
 
   modules.insert(std::make_pair(fileOffset, std::make_pair(mp, mbr)));
@@ -428,7 +428,7 @@
   return mp;
 }
 
-// Look up multiple symbols in the symbol table and return a set of 
+// Look up multiple symbols in the symbol table and return a set of
 // ModuleProviders that define those symbols.
 void
 Archive::findModulesDefiningSymbols(std::set<std::string>& symbols,
@@ -454,16 +454,16 @@
 
       // If it contains symbols
       if (mbr->isBytecode() || mbr->isCompressedBytecode()) {
-        // Get the symbols 
+        // Get the symbols
         std::vector<std::string> symbols;
-        std::string FullMemberName = archPath.toString() + "(" + 
+        std::string FullMemberName = archPath.toString() + "(" +
           mbr->getPath().toString() + ")";
         ModuleProvider* MP = GetBytecodeSymbols((const unsigned char*)At,
             mbr->getSize(), FullMemberName, symbols);
 
         if (MP) {
           // Insert the module's symbols into the symbol table
-          for (std::vector<std::string>::iterator I = symbols.begin(), 
+          for (std::vector<std::string>::iterator I = symbols.begin(),
                E=symbols.end(); I != E; ++I ) {
             symTab.insert(std::make_pair(*I, offset));
           }
@@ -483,10 +483,10 @@
     }
   }
 
-  // At this point we have a valid symbol table (one way or another) so we 
+  // At this point we have a valid symbol table (one way or another) so we
   // just use it to quickly find the symbols requested.
 
-  for (std::set<std::string>::iterator I=symbols.begin(), 
+  for (std::set<std::string>::iterator I=symbols.begin(),
        E=symbols.end(); I != E;) {
     // See if this symbol exists
     ModuleProvider* mp = findModuleDefiningSymbol(*I);
@@ -495,7 +495,7 @@
       // duplicates wil be ignored
       result.insert(mp);
 
-      // Remove the symbol now that its been resolved, being careful to 
+      // Remove the symbol now that its been resolved, being careful to
       // post-increment the iterator.
       symbols.erase(I++);
     } else {
@@ -509,13 +509,13 @@
 {
   //Make sure the symTab has been loaded...
   //in most cases this should have been done
-  //when the archive was constructed, but still, 
+  //when the archive was constructed, but still,
   //this is just in case.
   if ( !symTab.size() )
     loadSymbolTable();
 
   //Now that we know it's been loaded, return true
-  //if it has a size  
+  //if it has a size
   if ( symTab.size() ) return true;
 
   //We still can't be sure it isn't a bytecode archive


Index: llvm/lib/Bytecode/Archive/ArchiveWriter.cpp
diff -u llvm/lib/Bytecode/Archive/ArchiveWriter.cpp:1.17 llvm/lib/Bytecode/Archive/ArchiveWriter.cpp:1.18
--- llvm/lib/Bytecode/Archive/ArchiveWriter.cpp:1.17	Thu Apr 21 11:15:19 2005
+++ llvm/lib/Bytecode/Archive/ArchiveWriter.cpp	Thu Apr 21 16:13:18 2005
@@ -1,10 +1,10 @@
 //===-- ArchiveWriter.cpp - Write LLVM archive files ----------------------===//
-// 
+//
 //                     The LLVM Compiler Infrastructure
 //
-// This file was developed by Reid Spencer and is distributed under the 
+// This file was developed by Reid Spencer and is distributed under the
 // University of Illinois Open Source License. See LICENSE.TXT for details.
-// 
+//
 //===----------------------------------------------------------------------===//
 //
 // Builds up an LLVM archive file (.a) containing LLVM bytecode.
@@ -30,7 +30,7 @@
       ARFile << (unsigned char)num;
       return;
     }
-    
+
     // Nope, we are bigger than a character, output the next 7 bits and set the
     // high bit to say that there is more coming...
     ARFile << (unsigned char)(0x80 | ((unsigned char)num & 0x7F));
@@ -44,9 +44,9 @@
 
   // Note that the following nested ifs are somewhat equivalent to a binary
   // search. We split it in half by comparing against 2^14 first. This allows
-  // most reasonable values to be done in 2 comparisons instead of 1 for 
+  // most reasonable values to be done in 2 comparisons instead of 1 for
   // small ones and four for large ones. We expect this to access file offsets
-  // in the 2^10 to 2^24 range and symbol lengths in the 2^0 to 2^8 range, 
+  // in the 2^10 to 2^24 range and symbol lengths in the 2^0 to 2^8 range,
   // so this approach is reasonable.
   if (num < 1<<14)
     if (num < 1<<7)
@@ -62,17 +62,17 @@
 }
 
 // Create an empty archive.
-Archive* 
+Archive*
 Archive::CreateEmpty(const sys::Path& FilePath ) {
   Archive* result = new Archive(FilePath,false);
   return result;
 }
 
-// Fill the ArchiveMemberHeader with the information from a member. If 
+// Fill the ArchiveMemberHeader with the information from a member. If
 // TruncateNames is true, names are flattened to 15 chars or less. The sz field
-// is provided here instead of coming from the mbr because the member might be 
-// stored compressed and the compressed size is not the ArchiveMember's size. 
-// Furthermore compressed files have negative size fields to identify them as 
+// is provided here instead of coming from the mbr because the member might be
+// stored compressed and the compressed size is not the ArchiveMember's size.
+// Furthermore compressed files have negative size fields to identify them as
 // compressed.
 bool
 Archive::fillHeader(const ArchiveMember &mbr, ArchiveMemberHeader& hdr,
@@ -119,7 +119,7 @@
       nm += slashpos + 1;
       len -= slashpos +1;
     }
-    if (len > 15) 
+    if (len > 15)
       len = 15;
     memcpy(hdr.name,nm,len);
     hdr.name[len] = '/';
@@ -190,7 +190,7 @@
   std::ofstream& ARFile,
   bool CreateSymbolTable,
   bool TruncateNames,
-  bool ShouldCompress 
+  bool ShouldCompress
 ) {
 
   unsigned filepos = ARFile.tellp();
@@ -205,45 +205,45 @@
     mFile = new sys::MappedFile(member.getPath());
     data = (const char*) mFile->map();
     fSize = mFile->size();
-  } 
+  }
 
-  // Now that we have the data in memory, update the 
+  // Now that we have the data in memory, update the
   // symbol table if its a bytecode file.
-  if (CreateSymbolTable && 
+  if (CreateSymbolTable &&
       (member.isBytecode() || member.isCompressedBytecode())) {
     std::vector<std::string> symbols;
-    std::string FullMemberName = archPath.toString() + "(" + 
-      member.getPath().toString() 
+    std::string FullMemberName = archPath.toString() + "(" +
+      member.getPath().toString()
       + ")";
     ModuleProvider* MP = GetBytecodeSymbols(
       (const unsigned char*)data,fSize,FullMemberName, symbols);
 
     // If the bytecode parsed successfully
     if ( MP ) {
-      for (std::vector<std::string>::iterator SI = symbols.begin(), 
+      for (std::vector<std::string>::iterator SI = symbols.begin(),
            SE = symbols.end(); SI != SE; ++SI) {
 
-        std::pair<SymTabType::iterator,bool> Res = 
+        std::pair<SymTabType::iterator,bool> Res =
           symTab.insert(std::make_pair(*SI,filepos));
 
         if (Res.second) {
-          symTabSize += SI->length() + 
-                        numVbrBytes(SI->length()) + 
+          symTabSize += SI->length() +
+                        numVbrBytes(SI->length()) +
                         numVbrBytes(filepos);
         }
       }
       // We don't need this module any more.
       delete MP;
     } else {
-      throw std::string("Can't parse bytecode member: ") + 
+      throw std::string("Can't parse bytecode member: ") +
              member.getPath().toString();
     }
   }
 
   // Determine if we actually should compress this member
-  bool willCompress = 
-      (ShouldCompress && 
-      !member.isCompressed() && 
+  bool willCompress =
+      (ShouldCompress &&
+      !member.isCompressed() &&
       !member.isCompressedBytecode() &&
       !member.isLLVMSymbolTable() &&
       !member.isSVR4SymbolTable() &&
@@ -266,7 +266,7 @@
     fSize = Compressor::compressToNewBuffer(data,fSize,output);
     data = output;
     if (member.isBytecode())
-      hdrSize = -fSize-4; 
+      hdrSize = -fSize-4;
     else
       hdrSize = -fSize;
   } else {
@@ -361,15 +361,15 @@
 }
 
 // Write the entire archive to the file specified when the archive was created.
-// This writes to a temporary file first. Options are for creating a symbol 
-// table, flattening the file names (no directories, 15 chars max) and 
+// This writes to a temporary file first. Options are for creating a symbol
+// table, flattening the file names (no directories, 15 chars max) and
 // compressing each archive member.
 void
 Archive::writeToDisk(bool CreateSymbolTable, bool TruncateNames, bool Compress){
-  
+
   // Make sure they haven't opened up the file, not loaded it,
   // but are now trying to write it which would wipe out the file.
-  assert(!(members.empty() && mapfile->size() > 8) && 
+  assert(!(members.empty() && mapfile->size() > 8) &&
          "Can't write an archive not opened for writing");
 
   // Create a temporary file to store the archive in
@@ -385,7 +385,7 @@
     std::ios::openmode io_mode = std::ios::out | std::ios::trunc |
                                  std::ios::binary;
     std::ofstream ArchiveFile(TmpArchive.c_str(), io_mode);
-  
+
     // Check for errors opening or creating archive file.
     if ( !ArchiveFile.is_open() || ArchiveFile.bad() ) {
       throw std::string("Error opening archive file: ") + archPath.toString();
@@ -444,7 +444,7 @@
 
       // Copy the temporary file contents being sure to skip the file's magic
       // number.
-      FinalFile.write(base + sizeof(ARFILE_MAGIC)-1, 
+      FinalFile.write(base + sizeof(ARFILE_MAGIC)-1,
         arch.size()-sizeof(ARFILE_MAGIC)+1);
 
       // Close up shop






More information about the llvm-commits mailing list