From: Andrew Lenharth Date: Thu, 28 Feb 2008 22:24:48 +0000 (+0000) Subject: Make llvm-ar behave like ar, if you create an empty archive, ar creates an empty... X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=63b8c1f6f118dfef44422283947bdc3388c0fcb4;p=oota-llvm.git Make llvm-ar behave like ar, if you create an empty archive, ar creates an empty archive. llvm-ar would not generate an output file in this case git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47733 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Archive/ArchiveWriter.cpp b/lib/Archive/ArchiveWriter.cpp index 07f7d88dd82..04cc981f796 100644 --- a/lib/Archive/ArchiveWriter.cpp +++ b/lib/Archive/ArchiveWriter.cpp @@ -348,7 +348,7 @@ 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. - if (members.empty() && mapfile->size() > 8) { + if (members.empty() && mapfile && mapfile->size() > 8) { if (ErrMsg) *ErrMsg = "Can't write an archive not opened for writing"; return true; diff --git a/tools/llvm-ar/llvm-ar.cpp b/tools/llvm-ar/llvm-ar.cpp index a72a4c00190..a6611a3e809 100644 --- a/tools/llvm-ar/llvm-ar.cpp +++ b/tools/llvm-ar/llvm-ar.cpp @@ -717,6 +717,7 @@ int main(int argc, char **argv) { if (!Create) std::cerr << argv[0] << ": creating " << ArchivePath.toString() << "\n"; TheArchive = Archive::CreateEmpty(ArchivePath); + TheArchive->writeToDisk(); } else { std::string Error; TheArchive = Archive::OpenAndLoad(ArchivePath, &Error);