diff options
author | Erich Keane <erich.keane@intel.com> | 2018-05-04 15:58:31 +0000 |
---|---|---|
committer | Erich Keane <erich.keane@intel.com> | 2018-05-04 15:58:31 +0000 |
commit | 425f48d48078fb6e173b08bbdbf9129212ad85c1 (patch) | |
tree | abca04093776d564e08cf35bad6a0d38aef80d1b /clang/lib/Frontend/HeaderIncludeGen.cpp | |
parent | b18c34bc291a4e49c9399d45f25d7b11a6ccd670 (diff) | |
download | llvm-425f48d48078fb6e173b08bbdbf9129212ad85c1.zip llvm-425f48d48078fb6e173b08bbdbf9129212ad85c1.tar.gz llvm-425f48d48078fb6e173b08bbdbf9129212ad85c1.tar.bz2 |
[clang-cl] Print /showIncludes to stderr, if used in combination with /E, /EP or /P
This replicates 'cl.exe' behavior and allows for both preprocessor output and
dependency information to be extraced with a single compiler invocation.
This is especially useful for compiler caching with tools like Mozilla's sccache.
See: https://github.com/mozilla/sccache/issues/246
Patch By: fxb
Differential Revision: https://reviews.llvm.org/D46394
llvm-svn: 331533
Diffstat (limited to 'clang/lib/Frontend/HeaderIncludeGen.cpp')
-rw-r--r-- | clang/lib/Frontend/HeaderIncludeGen.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/clang/lib/Frontend/HeaderIncludeGen.cpp b/clang/lib/Frontend/HeaderIncludeGen.cpp index 5bff4ec..9dc107c 100644 --- a/clang/lib/Frontend/HeaderIncludeGen.cpp +++ b/clang/lib/Frontend/HeaderIncludeGen.cpp @@ -80,9 +80,23 @@ void clang::AttachHeaderIncludeGen(Preprocessor &PP, const DependencyOutputOptions &DepOpts, bool ShowAllHeaders, StringRef OutputPath, bool ShowDepth, bool MSStyle) { - raw_ostream *OutputFile = MSStyle ? &llvm::outs() : &llvm::errs(); + raw_ostream *OutputFile = &llvm::errs(); bool OwnsOutputFile = false; + // Choose output stream, when printing in cl.exe /showIncludes style. + if (MSStyle) { + switch (DepOpts.ShowIncludesDest) { + default: + llvm_unreachable("Invalid destination for /showIncludes output!"); + case ShowIncludesDestination::Stderr: + OutputFile = &llvm::errs(); + break; + case ShowIncludesDestination::Stdout: + OutputFile = &llvm::outs(); + break; + } + } + // Open the output file, if used. if (!OutputPath.empty()) { std::error_code EC; |