r192091 - Driver: Use the canonical command line arguments.

Nico Weber thakis at chromium.org
Mon Oct 7 07:27:19 PDT 2013


Is it possible to write a test for this?


On Mon, Oct 7, 2013 at 12:33 AM, David Majnemer <david.majnemer at gmail.com>wrote:

> Author: majnemer
> Date: Mon Oct  7 02:33:27 2013
> New Revision: 192091
>
> URL: http://llvm.org/viewvc/llvm-project?rev=192091&view=rev
> Log:
> Driver: Use the canonical command line arguments.
>
> Summary:
> Use the arguments given to the OS at process creation-time instead of
> the arguments passed into main() by the C runtime environment.  The ones
> that main() received may not be suitable (e.g. not Unicode).
>
> Depends on D1834
>
> CC: cfe-commits
>
> Differential Revision: http://llvm-reviews.chandlerc.com/D1835
>
> Modified:
>     cfe/trunk/tools/driver/driver.cpp
>
> Modified: cfe/trunk/tools/driver/driver.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/driver.cpp?rev=192091&r1=192090&r2=192091&view=diff
>
> ==============================================================================
> --- cfe/trunk/tools/driver/driver.cpp (original)
> +++ cfe/trunk/tools/driver/driver.cpp Mon Oct  7 02:33:27 2013
> @@ -37,6 +37,7 @@
>  #include "llvm/Support/MemoryBuffer.h"
>  #include "llvm/Support/Path.h"
>  #include "llvm/Support/PrettyStackTrace.h"
> +#include "llvm/Support/Process.h"
>  #include "llvm/Support/Program.h"
>  #include "llvm/Support/Regex.h"
>  #include "llvm/Support/Signals.h"
> @@ -292,8 +293,16 @@ int main(int argc_, const char **argv_)
>    llvm::sys::PrintStackTraceOnErrorSignal();
>    llvm::PrettyStackTraceProgram X(argc_, argv_);
>
> +  SmallVector<const char *, 256> argv;
> +  llvm::SpecificBumpPtrAllocator<char> ArgAllocator;
> +  llvm::error_code EC = llvm::sys::Process::GetArgumentVector(
> +      argv, llvm::ArrayRef<const char *>(argv_, argc_), ArgAllocator);
> +  if (EC) {
> +    llvm::errs() << "error: couldn't get arguments: " << EC.message() <<
> '\n';
> +    return 1;
> +  }
> +
>    std::set<std::string> SavedStrings;
> -  SmallVector<const char*, 256> argv(argv_, argv_ + argc_);
>    StringSetSaver Saver(SavedStrings);
>    llvm::cl::ExpandResponseFiles(Saver, llvm::cl::TokenizeGNUCommandLine,
> argv);
>
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20131007/67670e7a/attachment.html>


More information about the cfe-commits mailing list