r313156 - Update users of llvm::sys::ExecuteAndWait etc.
Alexander Kornienko via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 13 10:03:58 PDT 2017
Author: alexfh
Date: Wed Sep 13 10:03:58 2017
New Revision: 313156
URL: http://llvm.org/viewvc/llvm-project?rev=313156&view=rev
Log:
Update users of llvm::sys::ExecuteAndWait etc.
Summary: Clang part of https://reviews.llvm.org/D37563
Reviewers: bkramer
Subscribers: vsk, cfe-commits
Differential Revision: https://reviews.llvm.org/D37564
Modified:
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
Modified: cfe/trunk/include/clang/Driver/Compilation.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Compilation.h?rev=313156&r1=313155&r2=313156&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Compilation.h (original)
+++ cfe/trunk/include/clang/Driver/Compilation.h Wed Sep 13 10:03:58 2017
@@ -99,8 +99,8 @@ class Compilation {
/// 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 @@ public:
/// 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
Modified: cfe/trunk/include/clang/Driver/Job.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Job.h?rev=313156&r1=313155&r2=313156&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Job.h (original)
+++ cfe/trunk/include/clang/Driver/Job.h Wed Sep 13 10:03:58 2017
@@ -97,8 +97,8 @@ public:
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 @@ public:
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 @@ public:
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;
};
Modified: cfe/trunk/lib/Driver/Compilation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Compilation.cpp?rev=313156&r1=313155&r2=313156&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Compilation.cpp (original)
+++ cfe/trunk/lib/Driver/Compilation.cpp Wed Sep 13 10:03:58 2017
@@ -26,8 +26,8 @@ Compilation::Compilation(const Driver &D
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 @@ Compilation::~Compilation() {
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 @@ void Compilation::initCompilationForDiag
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;
}
Modified: cfe/trunk/lib/Driver/Job.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Job.cpp?rev=313156&r1=313155&r2=313156&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Job.cpp (original)
+++ cfe/trunk/lib/Driver/Job.cpp Wed Sep 13 10:03:58 2017
@@ -307,8 +307,8 @@ void Command::setEnvironment(llvm::Array
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 @@ static bool ShouldFallback(int ExitCode)
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 @@ void ForceSuccessCommand::Print(raw_ostr
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);
Modified: cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp?rev=313156&r1=313155&r2=313156&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp Wed Sep 13 10:03:58 2017
@@ -854,8 +854,7 @@ UbigraphViz::~UbigraphViz() {
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";
}
More information about the cfe-commits
mailing list