diff options
author | Chris Lattner <sabre@nondot.org> | 2003-04-22 18:02:52 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-04-22 18:02:52 +0000 |
commit | 75f20532ec768308767328a1234cbea38d115e6a (patch) | |
tree | 641aae08d612db6f1d92fd7d32421474b41affab | |
parent | 37f59419b8680fd1814e71387c8354ad64bd670b (diff) | |
download | external_llvm-75f20532ec768308767328a1234cbea38d115e6a.zip external_llvm-75f20532ec768308767328a1234cbea38d115e6a.tar.gz external_llvm-75f20532ec768308767328a1234cbea38d115e6a.tar.bz2 |
Preserve module source information in the ModuleID
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5836 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Archive/ArchiveReader.cpp | 8 | ||||
-rw-r--r-- | lib/AsmParser/llvmAsmParser.y | 3 | ||||
-rw-r--r-- | lib/Bytecode/Archive/ArchiveReader.cpp | 8 | ||||
-rw-r--r-- | lib/Bytecode/Reader/ArchiveReader.cpp | 8 | ||||
-rw-r--r-- | lib/Bytecode/Reader/Reader.cpp | 13 | ||||
-rw-r--r-- | lib/Bytecode/Reader/ReaderInternals.h | 3 |
6 files changed, 26 insertions, 17 deletions
diff --git a/lib/Archive/ArchiveReader.cpp b/lib/Archive/ArchiveReader.cpp index b6c3895..afa2c63 100644 --- a/lib/Archive/ArchiveReader.cpp +++ b/lib/Archive/ArchiveReader.cpp @@ -82,7 +82,8 @@ static bool ParseLongFilenameSection(unsigned char *Buffer, unsigned Size, } -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 @@ static bool ReadArchiveBuffer(unsigned char *Buffer, unsigned Length, 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 @@ bool ReadArchiveFile(const std::string &Filename, std::vector<Module*> &Objects, 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); diff --git a/lib/AsmParser/llvmAsmParser.y b/lib/AsmParser/llvmAsmParser.y index b265651..dcb53ed 100644 --- a/lib/AsmParser/llvmAsmParser.y +++ b/lib/AsmParser/llvmAsmParser.y @@ -591,7 +591,8 @@ Module *RunVMAsmParser(const string &Filename, FILE *F) { CurFilename = Filename; llvmAsmlineno = 1; // Reset the current line number... - CurModule.CurrentModule = new Module(); // Allocate a new module to read + // Allocate a new module to read + CurModule.CurrentModule = new Module(Filename); yyparse(); // Parse the file. Module *Result = ParserResult; llvmAsmin = stdin; // F is about to go away, don't use it anymore... diff --git a/lib/Bytecode/Archive/ArchiveReader.cpp b/lib/Bytecode/Archive/ArchiveReader.cpp index b6c3895..afa2c63 100644 --- a/lib/Bytecode/Archive/ArchiveReader.cpp +++ b/lib/Bytecode/Archive/ArchiveReader.cpp @@ -82,7 +82,8 @@ static bool ParseLongFilenameSection(unsigned char *Buffer, unsigned Size, } -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 @@ static bool ReadArchiveBuffer(unsigned char *Buffer, unsigned Length, 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 @@ bool ReadArchiveFile(const std::string &Filename, std::vector<Module*> &Objects, 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); diff --git a/lib/Bytecode/Reader/ArchiveReader.cpp b/lib/Bytecode/Reader/ArchiveReader.cpp index b6c3895..afa2c63 100644 --- a/lib/Bytecode/Reader/ArchiveReader.cpp +++ b/lib/Bytecode/Reader/ArchiveReader.cpp @@ -82,7 +82,8 @@ static bool ParseLongFilenameSection(unsigned char *Buffer, unsigned Size, } -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 @@ static bool ReadArchiveBuffer(unsigned char *Buffer, unsigned Length, 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 @@ bool ReadArchiveFile(const std::string &Filename, std::vector<Module*> &Objects, 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); diff --git a/lib/Bytecode/Reader/Reader.cpp b/lib/Bytecode/Reader/Reader.cpp index 3e495f4..5eb3861 100644 --- a/lib/Bytecode/Reader/Reader.cpp +++ b/lib/Bytecode/Reader/Reader.cpp @@ -620,14 +620,15 @@ static inline Module *Error(std::string *ErrorStr, const char *Message) { 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 *BytecodeParser::ParseBytecode(const uchar *Buf, const uchar *EndBuf) { 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 @@ Module *ParseBytecodeBuffer(const unsigned char *Buffer, unsigned Length, 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 @@ Module *ParseBytecodeFile(const std::string &Filename, std::string *ErrorStr) { 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 @@ Module *ParseBytecodeFile(const std::string &Filename, std::string *ErrorStr) { 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 diff --git a/lib/Bytecode/Reader/ReaderInternals.h b/lib/Bytecode/Reader/ReaderInternals.h index dd2a08f..a8528e4 100644 --- a/lib/Bytecode/Reader/ReaderInternals.h +++ b/lib/Bytecode/Reader/ReaderInternals.h @@ -52,7 +52,8 @@ public: 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; } |