[PATCH] Teach Clang how to use response files when calling other tools
Sean Silva
chisophugis at gmail.com
Mon Aug 25 11:06:34 PDT 2014
Lots of naked const char * type stuff here (that includes unique_ptr<char[]>). Better to use StringRef, SmallVectorImpl<char>&, and raw_ostream& where possible, maybe with judicious use of BumpPtrAllocator, memcpy, and strcpy.
There are a lot of places where you have to separate loops: one for computing a buffer size, and another for actually doing work. This is a maintenance problem (will the length computation stay in sync with the code?) and also causes two traversals over the memory. By directly doing push_back's onto a vector or writing into a raw_ostream, you avoid doing two traversals.
================
Comment at: lib/Driver/Job.cpp:122
@@ +121,3 @@
+/// will escape the regular backslashes (used in Windows paths) and quotes.
+static std::unique_ptr<char[]> FlattenArgs(const char **args) {
+ // First, determine the length of the command line.
----------------
This would be a lot nicer with ArrayRef<const char *>; that way, you won't lose the length.
================
Comment at: lib/Driver/Job.cpp:169
@@ +168,3 @@
+ llvm::SmallVector<const char *, 128> NewArgv;
+ unsigned len = 0;
+ for (auto Input : Inputs) {
----------------
Check your naming here and in other places.
================
Comment at: lib/Driver/Tools.h:546-550
@@ +545,7 @@
+ llvm::sys::EncodingMethod getResponseFileEncoding() const override {
+#if defined(LLVM_ON_WIN32)
+ return llvm::sys::EM_CurrentCodePage;
+#else
+ return llvm::sys::EM_UTF8;
+#endif
+ }
----------------
Ew... let's not have a bunch of random #ifdef's all over the code outside libSupport.
http://reviews.llvm.org/D4897
More information about the cfe-commits
mailing list