This revision was automatically updated to reflect the committed changes.
Closed by commit rL313156: Update users of llvm::sys::ExecuteAndWait etc. 
(authored by alexfh).

Repository:
  rL LLVM

https://reviews.llvm.org/D37564

Files:
  cfe/trunk/include/clang/Driver/Compilation.h
  cfe/trunk/include/clang/Driver/Job.h
  cfe/trunk/lib/Driver/Compilation.cpp
  cfe/trunk/lib/Driver/Job.cpp
  cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp

Index: cfe/trunk/include/clang/Driver/Compilation.h
===================================================================
--- cfe/trunk/include/clang/Driver/Compilation.h
+++ cfe/trunk/include/clang/Driver/Compilation.h
@@ -99,8 +99,8 @@
   /// only be removed if we crash.
   ArgStringMap FailureResultFiles;
 
-  /// Redirection for stdout, stderr, etc.
-  const StringRef **Redirects;
+  /// Optional redirection for stdin, stdout, stderr.
+  std::vector<Optional<StringRef>> Redirects;
 
   /// Whether we're compiling for diagnostic purposes.
   bool ForDiagnostics;
@@ -283,12 +283,10 @@
 
   /// Redirect - Redirect output of this compilation. Can only be done once.
   ///
-  /// \param Redirects - array of pointers to paths. The array
-  /// should have a size of three. The inferior process's
-  /// stdin(0), stdout(1), and stderr(2) will be redirected to the
-  /// corresponding paths. This compilation instance becomes
-  /// the owner of Redirects and will delete the array and StringRef's.
-  void Redirect(const StringRef** Redirects);
+  /// \param Redirects - array of optional paths. The array should have a size
+  /// of three. The inferior process's stdin(0), stdout(1), and stderr(2) will
+  /// be redirected to the corresponding paths, if provided (not llvm::None).
+  void Redirect(ArrayRef<Optional<StringRef>> Redirects);
 };
 
 } // end namespace driver
Index: cfe/trunk/include/clang/Driver/Job.h
===================================================================
--- cfe/trunk/include/clang/Driver/Job.h
+++ cfe/trunk/include/clang/Driver/Job.h
@@ -97,8 +97,8 @@
   virtual void Print(llvm::raw_ostream &OS, const char *Terminator, bool Quote,
                      CrashReportInfo *CrashInfo = nullptr) const;
 
-  virtual int Execute(const StringRef **Redirects, std::string *ErrMsg,
-                      bool *ExecutionFailed) const;
+  virtual int Execute(ArrayRef<Optional<StringRef>> Redirects,
+                      std::string *ErrMsg, bool *ExecutionFailed) const;
 
   /// getSource - Return the Action which caused the creation of this job.
   const Action &getSource() const { return Source; }
@@ -141,7 +141,7 @@
   void Print(llvm::raw_ostream &OS, const char *Terminator, bool Quote,
              CrashReportInfo *CrashInfo = nullptr) const override;
 
-  int Execute(const StringRef **Redirects, std::string *ErrMsg,
+  int Execute(ArrayRef<Optional<StringRef>> Redirects, std::string *ErrMsg,
               bool *ExecutionFailed) const override;
 
 private:
@@ -158,7 +158,7 @@
   void Print(llvm::raw_ostream &OS, const char *Terminator, bool Quote,
              CrashReportInfo *CrashInfo = nullptr) const override;
 
-  int Execute(const StringRef **Redirects, std::string *ErrMsg,
+  int Execute(ArrayRef<Optional<StringRef>> Redirects, std::string *ErrMsg,
               bool *ExecutionFailed) const override;
 };
 
Index: cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
===================================================================
--- cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
@@ -854,8 +854,7 @@
     Ubiviz = *Path;
   const char *args[] = {Ubiviz.c_str(), Filename.c_str(), nullptr};
 
-  if (llvm::sys::ExecuteAndWait(Ubiviz, &args[0], nullptr, nullptr, 0, 0,
-                                &ErrMsg)) {
+  if (llvm::sys::ExecuteAndWait(Ubiviz, &args[0], nullptr, {}, 0, 0, &ErrMsg)) {
     llvm::errs() << "Error viewing graph: " << ErrMsg << "\n";
   }
 
Index: cfe/trunk/lib/Driver/Compilation.cpp
===================================================================
--- cfe/trunk/lib/Driver/Compilation.cpp
+++ cfe/trunk/lib/Driver/Compilation.cpp
@@ -26,8 +26,8 @@
                          InputArgList *_Args, DerivedArgList *_TranslatedArgs,
                          bool ContainsError)
     : TheDriver(D), DefaultToolChain(_DefaultToolChain), ActiveOffloadMask(0u),
-      Args(_Args), TranslatedArgs(_TranslatedArgs), Redirects(nullptr),
-      ForDiagnostics(false), ContainsError(ContainsError) {
+      Args(_Args), TranslatedArgs(_TranslatedArgs), ForDiagnostics(false),
+      ContainsError(ContainsError) {
   // The offloading host toolchain is the default tool chain.
   OrderedOffloadingToolchains.insert(
       std::make_pair(Action::OFK_Host, &DefaultToolChain));
@@ -41,14 +41,6 @@
   for (auto Arg : TCArgs)
     if (Arg.second != TranslatedArgs)
       delete Arg.second;
-
-  // Free redirections of stdout/stderr.
-  if (Redirects) {
-    delete Redirects[0];
-    delete Redirects[1];
-    delete Redirects[2];
-    delete [] Redirects;
-  }
 }
 
 const DerivedArgList &
@@ -214,16 +206,13 @@
   TranslatedArgs->ClaimAllArgs();
 
   // Redirect stdout/stderr to /dev/null.
-  Redirects = new const StringRef*[3]();
-  Redirects[0] = nullptr;
-  Redirects[1] = new StringRef();
-  Redirects[2] = new StringRef();
+  Redirects = {None, {""}, {""}};
 }
 
 StringRef Compilation::getSysRoot() const {
   return getDriver().SysRoot;
 }
 
-void Compilation::Redirect(const StringRef** Redirects) {
+void Compilation::Redirect(ArrayRef<Optional<StringRef>> Redirects) {
   this->Redirects = Redirects;
 }
Index: cfe/trunk/lib/Driver/Job.cpp
===================================================================
--- cfe/trunk/lib/Driver/Job.cpp
+++ cfe/trunk/lib/Driver/Job.cpp
@@ -307,8 +307,8 @@
   Environment.push_back(nullptr);
 }
 
-int Command::Execute(const StringRef **Redirects, std::string *ErrMsg,
-                     bool *ExecutionFailed) const {
+int Command::Execute(ArrayRef<Optional<StringRef>> Redirects,
+                     std::string *ErrMsg, bool *ExecutionFailed) const {
   SmallVector<const char*, 128> Argv;
 
   const char **Envp;
@@ -378,8 +378,8 @@
   return ExitCode != 0;
 }
 
-int FallbackCommand::Execute(const StringRef **Redirects, std::string *ErrMsg,
-                             bool *ExecutionFailed) const {
+int FallbackCommand::Execute(ArrayRef<Optional<StringRef>> Redirects,
+                             std::string *ErrMsg, bool *ExecutionFailed) const {
   int PrimaryStatus = Command::Execute(Redirects, ErrMsg, ExecutionFailed);
   if (!ShouldFallback(PrimaryStatus))
     return PrimaryStatus;
@@ -410,7 +410,7 @@
   OS << " || (exit 0)" << Terminator;
 }
 
-int ForceSuccessCommand::Execute(const StringRef **Redirects,
+int ForceSuccessCommand::Execute(ArrayRef<Optional<StringRef>> Redirects,
                                  std::string *ErrMsg,
                                  bool *ExecutionFailed) const {
   int Status = Command::Execute(Redirects, ErrMsg, ExecutionFailed);
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to