diff options
author | David Majnemer <david.majnemer@gmail.com> | 2013-10-07 07:33:27 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2013-10-07 07:33:27 +0000 |
commit | 3f8f8c9dbd23e0da6e5d81a1ee957c1209ab0234 (patch) | |
tree | 5eec858e677fcbb89c6fcde153e84fc1b5b45aac /clang/tools | |
parent | 07ad1b23bb9f00f6b28ac55b9dece10bbb89b908 (diff) | |
download | llvm-3f8f8c9dbd23e0da6e5d81a1ee957c1209ab0234.zip llvm-3f8f8c9dbd23e0da6e5d81a1ee957c1209ab0234.tar.gz llvm-3f8f8c9dbd23e0da6e5d81a1ee957c1209ab0234.tar.bz2 |
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
llvm-svn: 192091
Diffstat (limited to 'clang/tools')
-rw-r--r-- | clang/tools/driver/driver.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/clang/tools/driver/driver.cpp b/clang/tools/driver/driver.cpp index 3c66f8a..6a1a47f 100644 --- a/clang/tools/driver/driver.cpp +++ b/clang/tools/driver/driver.cpp @@ -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); |