Changes in directory llvm/lib/Bytecode/Archive:
Archive.cpp updated: 1.14 -> 1.15 ArchiveReader.cpp updated: 1.47 -> 1.48 ArchiveWriter.cpp updated: 1.32 -> 1.33 --- Log message: For PR1050: http://llvm.org/PR1050 : Convert asserts into error messages. --- Diffs of the changes: (+27 -6) Archive.cpp | 7 ++++++- ArchiveReader.cpp | 13 +++++++++++-- ArchiveWriter.cpp | 13 ++++++++++--- 3 files changed, 27 insertions(+), 6 deletions(-) Index: llvm/lib/Bytecode/Archive/Archive.cpp diff -u llvm/lib/Bytecode/Archive/Archive.cpp:1.14 llvm/lib/Bytecode/Archive/Archive.cpp:1.15 --- llvm/lib/Bytecode/Archive/Archive.cpp:1.14 Thu Aug 24 18:45:08 2006 +++ llvm/lib/Bytecode/Archive/Archive.cpp Fri Dec 15 13:44:51 2006 @@ -62,7 +62,12 @@ // different file, presumably as an update to the member. It also makes sure // the flags are reset correctly. bool ArchiveMember::replaceWith(const sys::Path& newFile, std::string* ErrMsg) { - assert(newFile.exists() && "Can't replace with a non-existent file"); + if (!newFile.exists()) { + if (ErrMsg) + *ErrMsg = "Can not replace an archive member with a non-existent file"; + return true; + } + data = 0; path = newFile; Index: llvm/lib/Bytecode/Archive/ArchiveReader.cpp diff -u llvm/lib/Bytecode/Archive/ArchiveReader.cpp:1.47 llvm/lib/Bytecode/Archive/ArchiveReader.cpp:1.48 --- llvm/lib/Bytecode/Archive/ArchiveReader.cpp:1.47 Fri Aug 25 12:43:11 2006 +++ llvm/lib/Bytecode/Archive/ArchiveReader.cpp Fri Dec 15 13:44:51 2006 @@ -68,7 +68,11 @@ ArchiveMember* Archive::parseMemberHeader(const char*& At, const char* End, std::string* error) { - assert(At + sizeof(ArchiveMemberHeader) < End && "Not enough data"); + if (At + sizeof(ArchiveMemberHeader) >= End) { + if (error) + *error = "Unexpected end of file"; + return 0; + } // Cast archive member header ArchiveMemberHeader* Hdr = (ArchiveMemberHeader*)At; @@ -498,7 +502,12 @@ std::set<ModuleProvider*>& result, std::string* error) { - assert(mapfile && base && "Can't findModulesDefiningSymbols on new archive"); + if (!mapfile || !base) { + if (error) + *error = "Empty archive invalid for finding modules defining symbols"; + return false; + } + if (symTab.empty()) { // We don't have a symbol table, so we must build it now but lets also // make sure that we populate the modules table as we do this to ensure Index: llvm/lib/Bytecode/Archive/ArchiveWriter.cpp diff -u llvm/lib/Bytecode/Archive/ArchiveWriter.cpp:1.32 llvm/lib/Bytecode/Archive/ArchiveWriter.cpp:1.33 --- llvm/lib/Bytecode/Archive/ArchiveWriter.cpp:1.32 Tue Nov 28 16:49:32 2006 +++ llvm/lib/Bytecode/Archive/ArchiveWriter.cpp Fri Dec 15 13:44:51 2006 @@ -153,7 +153,11 @@ bool Archive::addFileBefore(const sys::Path& filePath, iterator where, std::string* ErrMsg) { - assert(filePath.exists() && "Can't add a non-existent file"); + if (!filePath.exists()) { + if (ErrMsg) + *ErrMsg = "Can not add a non-existent file to archive"; + return true; + } ArchiveMember* mbr = new ArchiveMember(this); @@ -385,8 +389,11 @@ { // 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) && - "Can't write an archive not opened for writing"); + if (members.empty() && mapfile->size() > 8) { + if (ErrMsg) + *ErrMsg = "Can't write an archive not opened for writing"; + return true; + } // Create a temporary file to store the archive in sys::Path TmpArchive = archPath; _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits