[llvm-commits] CVS: llvm/lib/Bytecode/Reader/ReadArchive.cpp Reader.cpp ReaderInternals.h

Chris Lattner lattner at cs.uiuc.edu
Tue Apr 22 13:04:03 PDT 2003


Changes in directory llvm/lib/Bytecode/Reader:

ReadArchive.cpp updated: 1.1 -> 1.2
Reader.cpp updated: 1.52 -> 1.53
ReaderInternals.h updated: 1.34 -> 1.35

---
Log message:

Preserve module source information in the ModuleID


---
Diffs of the changes:

Index: llvm/lib/Bytecode/Reader/ReadArchive.cpp
diff -u llvm/lib/Bytecode/Reader/ReadArchive.cpp:1.1 llvm/lib/Bytecode/Reader/ReadArchive.cpp:1.2
--- llvm/lib/Bytecode/Reader/ReadArchive.cpp:1.1	Sat Apr 19 16:45:34 2003
+++ llvm/lib/Bytecode/Reader/ReadArchive.cpp	Tue Apr 22 13:02:51 2003
@@ -82,7 +82,8 @@
 }
 
 
-static bool ReadArchiveBuffer(unsigned char *Buffer, unsigned Length,
+static bool ReadArchiveBuffer(const std::string &Filename,
+                              unsigned char *Buffer, unsigned Length,
                               std::vector<Module*> &Objects,
                               std::string *ErrorStr) {
   if (Length < 8 || memcmp(Buffer, "!<arch>\n", 8))
@@ -107,7 +108,8 @@
         return true;
       break;
     case UserObject: {
-      Module *M = ParseBytecodeBuffer(Buffer+sizeof(ar_hdr), Size, ErrorStr);
+      Module *M = ParseBytecodeBuffer(Buffer+sizeof(ar_hdr), Size,
+                                      Filename+":somefile", ErrorStr);
       if (!M) return true;
       Objects.push_back(M);
       break;
@@ -151,7 +153,7 @@
     return Error(ErrorStr, "Error mmapping file!");
   
   // Parse the archive files we mmap'ped in
-  bool Result = ReadArchiveBuffer(Buffer, Length, Objects, ErrorStr);
+  bool Result = ReadArchiveBuffer(Filename, Buffer, Length, Objects, ErrorStr);
   
   // Unmmap the archive...
   munmap((char*)Buffer, Length);


Index: llvm/lib/Bytecode/Reader/Reader.cpp
diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.52 llvm/lib/Bytecode/Reader/Reader.cpp:1.53
--- llvm/lib/Bytecode/Reader/Reader.cpp:1.52	Sat Apr 19 16:45:17 2003
+++ llvm/lib/Bytecode/Reader/Reader.cpp	Tue Apr 22 13:02:51 2003
@@ -620,14 +620,15 @@
   return 0;
 }
 
-Module *BytecodeParser::ParseBytecode(const uchar *Buf, const uchar *EndBuf) {
+Module *BytecodeParser::ParseBytecode(const uchar *Buf, const uchar *EndBuf,
+                                      const std::string &ModuleID) {
   unsigned Sig;
   // Read and check signature...
   if (read(Buf, EndBuf, Sig) ||
       Sig != ('l' | ('l' << 8) | ('v' << 16) | 'm' << 24))
     return ::Error(&Error, "Invalid bytecode signature!");
 
-  TheModule = new Module();
+  TheModule = new Module(ModuleID);
   if (ParseModule(Buf, EndBuf)) {
     delete TheModule;
     TheModule = 0;
@@ -637,7 +638,7 @@
 
 
 Module *ParseBytecodeBuffer(const unsigned char *Buffer, unsigned Length,
-                            std::string *ErrorStr) {
+                            const std::string &ModuleID, std::string *ErrorStr){
   BytecodeParser Parser;
   unsigned char *PtrToDelete = 0;
   if ((intptr_t)Buffer & 3) {         // If the buffer is not 4 byte aligned...
@@ -648,7 +649,7 @@
     Buffer = PtrToDelete+Offset;
   }
 
-  Module *R = Parser.ParseBytecode(Buffer, Buffer+Length);
+  Module *R = Parser.ParseBytecode(Buffer, Buffer+Length, ModuleID);
   if (ErrorStr) *ErrorStr = Parser.getError();
 
   delete [] PtrToDelete;   // Delete alignment buffer if neccesary
@@ -691,7 +692,7 @@
       return Error(ErrorStr, "Error mmapping file!");
 
     // Parse the bytecode we mmapped in
-    Result = ParseBytecodeBuffer(Buffer, Length, ErrorStr);
+    Result = ParseBytecodeBuffer(Buffer, Length, Filename, ErrorStr);
 
     // Unmmap the bytecode...
     munmap((char*)Buffer, Length);
@@ -721,7 +722,7 @@
     unsigned char *Buf = &FileData[0];
 #endif
 
-    Result = ParseBytecodeBuffer(Buf, FileData.size(), ErrorStr);
+    Result = ParseBytecodeBuffer(Buf, FileData.size(), "<stdin>", ErrorStr);
 
 #if ALIGN_PTRS
     munmap((char*)Buf, FileData.size());   // Free mmap'd data area


Index: llvm/lib/Bytecode/Reader/ReaderInternals.h
diff -u llvm/lib/Bytecode/Reader/ReaderInternals.h:1.34 llvm/lib/Bytecode/Reader/ReaderInternals.h:1.35
--- llvm/lib/Bytecode/Reader/ReaderInternals.h:1.34	Wed Apr 16 16:16:03 2003
+++ llvm/lib/Bytecode/Reader/ReaderInternals.h	Tue Apr 22 13:02:51 2003
@@ -52,7 +52,8 @@
     freeTable(ModuleValues);
   }
 
-  Module *ParseBytecode(const uchar *Buf, const uchar *EndBuf);
+  Module *ParseBytecode(const uchar *Buf, const uchar *EndBuf,
+                        const std::string &ModuleID);
 
   std::string getError() const { return Error; }
 





More information about the llvm-commits mailing list