components/llvm/patches/015-solaris-clang-tools-driver.patch
author Stefan Teleman <stefan.teleman@oracle.com>
Thu, 28 Jul 2016 16:25:34 -0700
changeset 6512 92717ce71105
permissions -rw-r--r--
24326140 upgrade LLVM to 3.8.1 24326159 upgrade clang to 3.8.1 22902339 memory corruption caused by undefined behavior in LLVM IR Module 22777179 implement [ -mtune= -march= -mcpu= ] in clang SPARC 22778085 LLVM is using %icc when it should be using %xcc 22778089 the SPARCV9 IS implementation is incomplete 22778098 LLVM should emit proc identifiers in SPARC assembler (capabilities) 22778650 clang should support OpenMP because it can 22859423 llvm CodeGen on Intel emits a bogus .ctors section 22902355 clang CodeGen is affected by 22902339 23701635 clang produces amd64 opcodes, but calls 32-bit assembler by default 23593143 lli JIT bitcode parsing creates a main function with wrong argc/argv 21759660 clang packages should include the scan-view and scan-build utilities 23854357 clang should check for GNU ld 17867434 clang crashed in LEXER 24306550 clang crashes in llvm::Twine::toStringRef 24311726 clang's Perl and Python utilities should not use #!/usr/bin/env 24312028 llvm::Twine needs copy constructors and assignment operators 24312221 classes must be CopyConstructible, CopyAssignable, MoveConstructible ... 24314621 LLVM should build using the new CMake based build system 24314638 LLVM CommandLine subsystem is busted 24314687 static initialization of optimization passes doesn't work as intended 21870069 clang makes incorrect assumptions about anonymous namespace instantiation order 22643565 llvm's Google test harness needs some attention 24314745 clang should support PIE executables in Solaris

# 24314638 LLVM CommandLine subsystem is busted
# Various cleanup fixes.
# 3.9.X upstream.
--- tools/clang/tools/driver/driver.cpp	2016-01-25 12:35:13.000000000 -0800
+++ tools/clang/tools/driver/driver.cpp	2016-05-11 18:39:13.438899360 -0700
@@ -48,6 +48,8 @@
 #include "llvm/Support/TargetSelect.h"
 #include "llvm/Support/Timer.h"
 #include "llvm/Support/raw_ostream.h"
+
+#include <vector>
 #include <memory>
 #include <system_error>
 using namespace clang;
@@ -97,7 +99,7 @@
 /// \param Edit - The override command to perform.
 /// \param SavedStrings - Set to use for storing string representations.
 static void ApplyOneQAOverride(raw_ostream &OS,
-                               SmallVectorImpl<const char*> &Args,
+                               std::vector<const char*> &Args,
                                StringRef Edit,
                                std::set<std::string> &SavedStrings) {
   // This does not need to be efficient.
@@ -169,7 +171,7 @@
 
 /// ApplyQAOverride - Apply a comma separate list of edits to the
 /// input argument lists. See ApplyOneQAOverride.
-static void ApplyQAOverride(SmallVectorImpl<const char*> &Args,
+static void ApplyQAOverride(std::vector<const char*> &Args,
                             const char *OverrideStr,
                             std::set<std::string> &SavedStrings) {
   raw_ostream *OS = &llvm::errs();
@@ -202,7 +204,7 @@
                       void *MainAddr);
 
 static void insertTargetAndModeArgs(StringRef Target, StringRef Mode,
-                                    SmallVectorImpl<const char *> &ArgVector,
+                                    std::vector<const char *> &ArgVector,
                                     std::set<std::string> &SavedStrings) {
   if (!Mode.empty()) {
     // Add the mode flag to the arguments.
@@ -222,7 +224,7 @@
 }
 
 static void getCLEnvVarOptions(std::string &EnvValue, llvm::StringSaver &Saver,
-                               SmallVectorImpl<const char *> &Opts) {
+                               std::vector<const char *> &Opts) {
   llvm::cl::TokenizeWindowsCommandLine(EnvValue, Saver, Opts);
   // The first instance of '#' should be replaced with '=' in each option.
   for (const char *Opt : Opts)
@@ -260,12 +262,15 @@
 // This lets us create the DiagnosticsEngine with a properly-filled-out
 // DiagnosticOptions instance.
 static DiagnosticOptions *
-CreateAndPopulateDiagOpts(ArrayRef<const char *> argv) {
-  auto *DiagOpts = new DiagnosticOptions;
+CreateAndPopulateDiagOpts(std::vector<const char *> &Argv) {
+  auto *DiagOpts = new DiagnosticOptions();
   std::unique_ptr<OptTable> Opts(createDriverOptTable());
-  unsigned MissingArgIndex, MissingArgCount;
+  unsigned MissingArgIndex = 0U;
+  unsigned MissingArgCount = 0U;
+  llvm::ArrayRef<const char*> AAR(Argv.data(), Argv.size());
   InputArgList Args =
-      Opts->ParseArgs(argv.slice(1), MissingArgIndex, MissingArgCount);
+    Opts->ParseArgs(AAR.slice(1), MissingArgIndex, MissingArgCount);
+
   // We ignore MissingArgCount and the return value of ParseDiagnosticArgs.
   // Any errors that would be diagnosed here will also be diagnosed later,
   // when the DiagnosticsEngine actually exists.
@@ -273,12 +278,12 @@
   return DiagOpts;
 }
 
-static void SetInstallDir(SmallVectorImpl<const char *> &argv,
+static void SetInstallDir(std::vector<const char *> &argv,
                           Driver &TheDriver, bool CanonicalPrefixes) {
   // Attempt to find the original path used to invoke the driver, to determine
   // the installed path. We do this manually, because we want to support that
   // path being a symlink.
-  SmallString<128> InstalledPath(argv[0]);
+  SmallString<PATH_MAX> InstalledPath(argv[0]);
 
   // Do a PATH lookup, if there are no directory components.
   if (llvm::sys::path::filename(InstalledPath) == InstalledPath)
@@ -314,10 +319,9 @@
   if (llvm::sys::Process::FixupStandardFileDescriptors())
     return 1;
 
-  SmallVector<const char *, 256> argv;
-  llvm::SpecificBumpPtrAllocator<char> ArgAllocator;
-  std::error_code EC = llvm::sys::Process::GetArgumentVector(
-      argv, llvm::makeArrayRef(argv_, argc_), ArgAllocator);
+  std::vector<const char *> argv;
+  llvm::ArrayRef<const char*> AAR = llvm::makeArrayRef(argv_, argc_);
+  std::error_code EC = llvm::sys::Process::GetArgumentVector(argv, AAR);
   if (EC) {
     llvm::errs() << "error: couldn't get arguments: " << EC.message() << '\n';
     return 1;
@@ -383,7 +387,7 @@
     // Arguments in "CL" are prepended.
     llvm::Optional<std::string> OptCL = llvm::sys::Process::GetEnv("CL");
     if (OptCL.hasValue()) {
-      SmallVector<const char *, 8> PrependedOpts;
+      std::vector<const char*> PrependedOpts;
       getCLEnvVarOptions(OptCL.getValue(), Saver, PrependedOpts);
 
       // Insert right after the program name to prepend to the argument list.
@@ -392,11 +396,11 @@
     // Arguments in "_CL_" are appended.
     llvm::Optional<std::string> Opt_CL_ = llvm::sys::Process::GetEnv("_CL_");
     if (Opt_CL_.hasValue()) {
-      SmallVector<const char *, 8> AppendedOpts;
+      std::vector<const char*> AppendedOpts;
       getCLEnvVarOptions(Opt_CL_.getValue(), Saver, AppendedOpts);
 
       // Insert at the end of the argument list to append.
-      argv.append(AppendedOpts.begin(), AppendedOpts.end());
+      argv.insert(argv.end(), AppendedOpts.begin(), AppendedOpts.end());
     }
   }
 
@@ -441,7 +445,7 @@
 
   std::unique_ptr<Compilation> C(TheDriver.BuildCompilation(argv));
   int Res = 0;
-  SmallVector<std::pair<int, const Command *>, 4> FailingCommands;
+  SmallVector<std::pair<int, const Command *>, 8> FailingCommands;
   if (C.get())
     Res = TheDriver.ExecuteCompilation(*C, FailingCommands);