Skip to content
Snippets Groups Projects
Commit e6404a0d authored by Nikolay Haustov's avatar Nikolay Haustov
Browse files

[Driver] Add method to redirect output of Compilation.

Summary:
Currently output of child process, however in my use case, it
needs to be captured and presented to the user.

Add Redirect method to Compilation and use existing infrastructure
for redirecting output of commands.

Reviewers: tstellarAMD

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D21224

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@273997 91177308-0d34-0410-b5e6-96231b3b80d8
parent 9b8dfc46
No related branches found
No related tags found
No related merge requests found
...@@ -252,6 +252,15 @@ public: ...@@ -252,6 +252,15 @@ public:
/// Return true if we're compiling for diagnostics. /// Return true if we're compiling for diagnostics.
bool isForDiagnostics() const { return ForDiagnostics; } bool isForDiagnostics() const { return ForDiagnostics; }
/// 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);
}; };
} // end namespace driver } // end namespace driver
......
...@@ -45,6 +45,7 @@ Compilation::~Compilation() { ...@@ -45,6 +45,7 @@ Compilation::~Compilation() {
// Free redirections of stdout/stderr. // Free redirections of stdout/stderr.
if (Redirects) { if (Redirects) {
delete Redirects[0];
delete Redirects[1]; delete Redirects[1];
delete Redirects[2]; delete Redirects[2];
delete [] Redirects; delete [] Redirects;
...@@ -213,3 +214,7 @@ void Compilation::initCompilationForDiagnostics() { ...@@ -213,3 +214,7 @@ void Compilation::initCompilationForDiagnostics() {
StringRef Compilation::getSysRoot() const { StringRef Compilation::getSysRoot() const {
return getDriver().SysRoot; return getDriver().SysRoot;
} }
void Compilation::Redirect(const StringRef** Redirects) {
this->Redirects = Redirects;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment