diff options
author | Hans Wennborg <hans@chromium.org> | 2021-06-25 11:59:34 (GMT) |
---|---|---|
committer | Hans Wennborg <hans@chromium.org> | 2021-06-25 12:41:24 (GMT) |
commit | c7b2cf60f4c07440728307c0e68f99c464ac7f7b (patch) | |
tree | d234b6f38dcc1eea40b5ba918500318f057da9db /src | |
parent | d68f107f7a80d552d764c8cd0545955be02debe2 (diff) | |
download | Ninja-c7b2cf60f4c07440728307c0e68f99c464ac7f7b.zip Ninja-c7b2cf60f4c07440728307c0e68f99c464ac7f7b.tar.gz Ninja-c7b2cf60f4c07440728307c0e68f99c464ac7f7b.tar.bz2 |
CLParser: Don't filter filename lines after seeing /showIncludes
The /showIncludes output always comes after cl.exe echos the filename,
so there is no need to filter out filename lines afterwards.
This makes it less likely that CLParser will "over filter" the compiler
output. For example, using the -H flag with clang-cl may lead to output
lines ending in .cc, which are not supposed to be filtered out.
Diffstat (limited to 'src')
-rw-r--r-- | src/clparser.cc | 4 | ||||
-rw-r--r-- | src/clparser_test.cc | 11 |
2 files changed, 14 insertions, 1 deletions
diff --git a/src/clparser.cc b/src/clparser.cc index 40e9407..070bcfd 100644 --- a/src/clparser.cc +++ b/src/clparser.cc @@ -83,6 +83,7 @@ bool CLParser::Parse(const string& output, const string& deps_prefix, // Loop over all lines in the output to process them. assert(&output != filtered_output); size_t start = 0; + bool seen_show_includes = false; #ifdef _WIN32 IncludesNormalize normalizer("."); #endif @@ -95,6 +96,7 @@ bool CLParser::Parse(const string& output, const string& deps_prefix, string include = FilterShowIncludes(line, deps_prefix); if (!include.empty()) { + seen_show_includes = true; string normalized; #ifdef _WIN32 if (!normalizer.Normalize(include, &normalized, err)) @@ -107,7 +109,7 @@ bool CLParser::Parse(const string& output, const string& deps_prefix, #endif if (!IsSystemInclude(normalized)) includes_.insert(normalized); - } else if (FilterInputFilename(line)) { + } else if (!seen_show_includes && FilterInputFilename(line)) { // Drop it. // TODO: if we support compiling multiple output files in a single // cl.exe invocation, we should stash the filename. diff --git a/src/clparser_test.cc b/src/clparser_test.cc index 0b829c1..f141680 100644 --- a/src/clparser_test.cc +++ b/src/clparser_test.cc @@ -70,6 +70,17 @@ TEST(CLParserTest, ParseFilenameFilter) { ASSERT_EQ("cl: warning\n", output); } +TEST(CLParserTest, NoFilenameFilterAfterShowIncludes) { + CLParser parser; + string output, err; + ASSERT_TRUE(parser.Parse( + "foo.cc\r\n" + "Note: including file: foo.h\r\n" + "something something foo.cc\r\n", + "", &output, &err)); + ASSERT_EQ("something something foo.cc\n", output); +} + TEST(CLParserTest, ParseSystemInclude) { CLParser parser; string output, err; |