summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikhail Glushenkov <foldr@codedgers.com>2009-01-21 13:14:02 +0000
committerMikhail Glushenkov <foldr@codedgers.com>2009-01-21 13:14:02 +0000
commit1421b7bc23f39e57052a51f4647512936f45b12f (patch)
tree3cbe15d8ab68490fde67c224556ccf19271da865
parente441b831c0ff12f86a10b60bf4fb7b7b9efa35e4 (diff)
downloadexternal_llvm-1421b7bc23f39e57052a51f4647512936f45b12f.zip
external_llvm-1421b7bc23f39e57052a51f4647512936f45b12f.tar.gz
external_llvm-1421b7bc23f39e57052a51f4647512936f45b12f.tar.bz2
Mimic gcc behaviour with regard to response files.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62688 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--docs/CommandGuide/llvmc.pod16
-rw-r--r--lib/Support/CommandLine.cpp31
2 files changed, 31 insertions, 16 deletions
diff --git a/docs/CommandGuide/llvmc.pod b/docs/CommandGuide/llvmc.pod
index 17d85d7..53eecaf 100644
--- a/docs/CommandGuide/llvmc.pod
+++ b/docs/CommandGuide/llvmc.pod
@@ -78,8 +78,24 @@ options intended for developers.
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
diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp
index 87dfc5a..8cd483a 100644
--- a/lib/Support/CommandLine.cpp
+++ b/lib/Support/CommandLine.cpp
@@ -388,23 +388,22 @@ static void ExpandResponseFiles(int argc, char** argv,
// 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;
-
- ParseCStringVector(newArgv, respFilePtr->getBufferStart());
- }
- else {
- newArgv.push_back(strdup(arg));
+ if (FileStat && FileStat->getSize() != 0) {
+
+ // 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));
}
}