don't alias input/output in ExtractDeps (i.e. actually works now)
authorScott Graham <scottmg@chromium.org>
Thu, 18 Jun 2015 22:52:25 +0000 (15:52 -0700)
committerScott Graham <scottmg@chromium.org>
Thu, 18 Jun 2015 22:52:25 +0000 (15:52 -0700)
src/build.cc
src/msvc_helper-win32.cc
src/msvc_helper.h

index fcde626..e4820d0 100644 (file)
@@ -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<string>::iterator i = parser.includes_.begin();
          i != parser.includes_.end(); ++i) {
       // ~0 is assuming that with MSVC-parsed headers, it's ok to always make
index 78b79b0..d516240 100644 (file)
@@ -15,6 +15,7 @@
 #include "msvc_helper.h"
 
 #include <algorithm>
+#include <assert.h>
 #include <stdio.h>
 #include <string.h>
 #include <windows.h>
@@ -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);
index 08c0ad5..30f87f3 100644 (file)
@@ -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);