diff options
author | Nikolay Haustov <Nikolay.Haustov@amd.com> | 2016-06-28 08:00:42 +0000 |
---|---|---|
committer | Nikolay Haustov <Nikolay.Haustov@amd.com> | 2016-06-28 08:00:42 +0000 |
commit | 9c366cdf2a80aeaf57cb540bdc4843bc0381cafa (patch) | |
tree | 053dc218c2a0745d4db71db0b85287a0088a6a98 | |
parent | 3e176c77ab593e2edf659e7318cb41319cae10ff (diff) | |
download | bcm5719-llvm-9c366cdf2a80aeaf57cb540bdc4843bc0381cafa.tar.gz bcm5719-llvm-9c366cdf2a80aeaf57cb540bdc4843bc0381cafa.zip |
[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
llvm-svn: 273997
-rw-r--r-- | clang/include/clang/Driver/Compilation.h | 9 | ||||
-rw-r--r-- | clang/lib/Driver/Compilation.cpp | 5 |
2 files changed, 14 insertions, 0 deletions
diff --git a/clang/include/clang/Driver/Compilation.h b/clang/include/clang/Driver/Compilation.h index af5440d5536..ea84a93cf28 100644 --- a/clang/include/clang/Driver/Compilation.h +++ b/clang/include/clang/Driver/Compilation.h @@ -252,6 +252,15 @@ public: /// Return true if we're compiling for diagnostics. 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 diff --git a/clang/lib/Driver/Compilation.cpp b/clang/lib/Driver/Compilation.cpp index 46548e638a3..6a2616f0c2a 100644 --- a/clang/lib/Driver/Compilation.cpp +++ b/clang/lib/Driver/Compilation.cpp @@ -45,6 +45,7 @@ Compilation::~Compilation() { // Free redirections of stdout/stderr. if (Redirects) { + delete Redirects[0]; delete Redirects[1]; delete Redirects[2]; delete [] Redirects; @@ -213,3 +214,7 @@ void Compilation::initCompilationForDiagnostics() { StringRef Compilation::getSysRoot() const { return getDriver().SysRoot; } + +void Compilation::Redirect(const StringRef** Redirects) { + this->Redirects = Redirects; +} |