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

llvm-svn: 47733
This commit is contained in:
Andrew Lenharth 2008-02-28 22:24:48 +00:00
parent 714eeb2d55
commit 09b64a4ed1
2 changed files with 2 additions and 1 deletions

View File

@ -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;

View File

@ -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);