From 312c6aa131943408e9a0268c11806369f84063e3 Mon Sep 17 00:00:00 2001 From: Scott Graham Date: Thu, 18 Jun 2015 15:52:25 -0700 Subject: [PATCH] don't alias input/output in ExtractDeps (i.e. actually works now) --- src/build.cc | 4 +++- src/msvc_helper-win32.cc | 2 ++ src/msvc_helper.h | 5 +++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/build.cc b/src/build.cc index fcde626..e4820d0 100644 --- a/src/build.cc +++ b/src/build.cc @@ -849,8 +849,10 @@ bool Builder::ExtractDeps(CommandRunner::Result* result, #ifdef _WIN32 if (deps_type == "msvc") { CLParser parser; - if (!parser.Parse(result->output, deps_prefix, &result->output, err)) + string output; + if (!parser.Parse(result->output, deps_prefix, &output, err)) return false; + result->output = output; for (set::iterator i = parser.includes_.begin(); i != parser.includes_.end(); ++i) { // ~0 is assuming that with MSVC-parsed headers, it's ok to always make diff --git a/src/msvc_helper-win32.cc b/src/msvc_helper-win32.cc index 78b79b0..d516240 100644 --- a/src/msvc_helper-win32.cc +++ b/src/msvc_helper-win32.cc @@ -15,6 +15,7 @@ #include "msvc_helper.h" #include +#include #include #include #include @@ -85,6 +86,7 @@ bool CLParser::FilterInputFilename(string line) { bool CLParser::Parse(const string& output, const string& deps_prefix, string* filtered_output, string* err) { // Loop over all lines in the output to process them. + assert(&output != filtered_output); size_t start = 0; while (start < output.size()) { size_t end = output.find_first_of("\r\n", start); diff --git a/src/msvc_helper.h b/src/msvc_helper.h index 08c0ad5..30f87f3 100644 --- a/src/msvc_helper.h +++ b/src/msvc_helper.h @@ -40,8 +40,9 @@ struct CLParser { /// Exposed for testing. static bool FilterInputFilename(string line); - /// Parse the full output of cl, returning the output (if any) that - /// should printed. Returns true on success, or false with err filled. + /// Parse the full output of cl, filling filtered_output with the text that + /// should be printed (if any). Returns true on success, or false with err + /// filled. output must not be the same object as filtered_object. bool Parse(const string& output, const string& deps_prefix, string* filtered_output, string* err); -- 2.7.4