[llvm-commits] [llvm] r62688 - in /llvm/trunk: docs/CommandGuide/llvmc.pod lib/Support/CommandLine.cpp

Mikhail Glushenkov foldr at codedgers.com
Wed Jan 21 05:14:02 PST 2009


Author: foldr
Date: Wed Jan 21 07:14:02 2009
New Revision: 62688

URL: http://llvm.org/viewvc/llvm-project?rev=62688&view=rev
Log:
Mimic gcc behaviour with regard to response files.

Modified:
    llvm/trunk/docs/CommandGuide/llvmc.pod
    llvm/trunk/lib/Support/CommandLine.cpp

Modified: llvm/trunk/docs/CommandGuide/llvmc.pod
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CommandGuide/llvmc.pod?rev=62688&r1=62687&r2=62688&view=diff

==============================================================================
--- llvm/trunk/docs/CommandGuide/llvmc.pod (original)
+++ llvm/trunk/docs/CommandGuide/llvmc.pod Wed Jan 21 07:14:02 2009
@@ -78,8 +78,24 @@
 
 Print version information and exit.
 
+=item B<@>I<file>
+
+Read command-line options from I<file>. The options read are inserted
+in place of the original @I<file> option. If I<file> does not exist, or
+cannot be read, then the option will be treated literally, and not
+removed.
+
+Options in I<file> are separated by whitespace. A whitespace character
+may be included in an option by surrounding the entire option in
+either single or double quotes. Any character (including a backslash)
+may be included by prefixing the character to be included with a
+backslash. The file may itself contain additional @I<file> options;
+any such options will be processed recursively.
+
+
 =back
 
+
 =head2 Control Options
 
 By default, LLVMC is built with some standard configuration libraries

Modified: llvm/trunk/lib/Support/CommandLine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/CommandLine.cpp?rev=62688&r1=62687&r2=62688&view=diff

==============================================================================
--- llvm/trunk/lib/Support/CommandLine.cpp (original)
+++ llvm/trunk/lib/Support/CommandLine.cpp Wed Jan 21 07:14:02 2009
@@ -388,23 +388,22 @@
       // Check that the response file is not empty (mmap'ing empty
       // files can be problematic).
       const sys::FileStatus *FileStat = respFile.getFileStatus();
-      if (!FileStat)
-        continue;
-      if (FileStat->getSize() == 0)
-        continue;
-
-      // Mmap the response file into memory.
-      OwningPtr<MemoryBuffer>
-        respFilePtr(MemoryBuffer::getFile(respFile.c_str()));
-
-      if (respFilePtr == 0)
-        continue;
+      if (FileStat && FileStat->getSize() != 0) {
 
-      ParseCStringVector(newArgv, respFilePtr->getBufferStart());
-    }
-    else {
-      newArgv.push_back(strdup(arg));
+        // Mmap the response file into memory.
+        OwningPtr<MemoryBuffer>
+          respFilePtr(MemoryBuffer::getFile(respFile.c_str()));
+
+        // If we could open the file, parse its contents, otherwise
+        // pass the @file option verbatim.
+        // TODO: support recursion.
+        if (respFilePtr != 0) {
+          ParseCStringVector(newArgv, respFilePtr->getBufferStart());
+          continue;
+        }
+      }
     }
+    newArgv.push_back(strdup(arg));
   }
 }
 





More information about the llvm-commits mailing list