[llvm-commits] [llvm] r47733 - in /llvm/trunk: lib/Archive/ArchiveWriter.cpp tools/llvm-ar/llvm-ar.cpp

Andrew Lenharth alenhar2 at cs.uiuc.edu
Thu Feb 28 14:24:49 PST 2008


Author: alenhar2
Date: Thu Feb 28 16:24:48 2008
New Revision: 47733

URL: http://llvm.org/viewvc/llvm-project?rev=47733&view=rev
Log:
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

Modified:
    llvm/trunk/lib/Archive/ArchiveWriter.cpp
    llvm/trunk/tools/llvm-ar/llvm-ar.cpp

Modified: llvm/trunk/lib/Archive/ArchiveWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Archive/ArchiveWriter.cpp?rev=47733&r1=47732&r2=47733&view=diff

==============================================================================
--- llvm/trunk/lib/Archive/ArchiveWriter.cpp (original)
+++ llvm/trunk/lib/Archive/ArchiveWriter.cpp Thu Feb 28 16:24:48 2008
@@ -348,7 +348,7 @@
 {
   // 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;

Modified: llvm/trunk/tools/llvm-ar/llvm-ar.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-ar/llvm-ar.cpp?rev=47733&r1=47732&r2=47733&view=diff

==============================================================================
--- llvm/trunk/tools/llvm-ar/llvm-ar.cpp (original)
+++ llvm/trunk/tools/llvm-ar/llvm-ar.cpp Thu Feb 28 16:24:48 2008
@@ -717,6 +717,7 @@
       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);





More information about the llvm-commits mailing list