Skip to content

Commit 7bbf261

Browse files
authored
Fix gnuld error parsing false positive on make errors, false negative due to trailing \r, and false parsing of new "multiple definitions" error (#4341)
* Fix gnuld error parsing false positive on make errors, false negative due to trailing \r, and false parsing of new "multiple definitions" error * Move bug fix entry in CHANGELOG to 1.21 section
1 parent 4dc5400 commit 7bbf261

3 files changed

Lines changed: 37 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Bug Fixes:
1414

1515
- Fix bug that makes `Configure Task` lists only first folder in workspace. [#3232](https//github.com/microsoft/vscode-cmake-tools/issues/3232)
1616
- Fix displaying "Go to Test" in the Test Explorer when the DEF_SOURCE_LINE property is set, but there is no backtrace information present. [4321](https://github.com/microsoft/vscode-cmake-tools/pull/4321) [@rjaegers](https://github.com/rjaegers)
17+
- Fix gnuld error parsing false positive on make errors, false negative due to trailing \r, and false parsing of new "multiple definitions" error [#2864](https://github.com/microsoft/vscode-cmake-tools/issues/2864) [@0xemgy](https://github.com/0xemgy)
1718

1819
## 1.20.53
1920

src/diagnostics/gnu-ld.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ const regexPatterns: RegexPattern[] = [
1212
regexPattern: /^(?:.*ld(?:\.exe)?:)(?:\s*)?(.+):(\d+):\s+(?:fatal )?(\w+):\s+(.+)/,
1313
matchTypes: [MatchType.Full, MatchType.File, MatchType.Line, MatchType.Severity, MatchType.Message]
1414
},
15+
{ // path/to/ld[.exe]:[ ]path/to/file.obj:path/to/file:line: message
16+
regexPattern: /^(?:.*ld(?:\.exe)?\:)(?:\s*)(?:.+?\.obj:)(.+?):(\d+):\s+(.+)/,
17+
matchTypes: [MatchType.Full, MatchType.File, MatchType.Line, MatchType.Message]
18+
},
1519
{ // path/to/ld[.exe]:[ ]path/to/file:line: message
1620
regexPattern: /^(?:.*ld(?:\.exe)?\:)(?:\s*)?(.+):(\d+):\s+(.+)/,
1721
matchTypes: [MatchType.Full, MatchType.File, MatchType.Line, MatchType.Message]
@@ -21,11 +25,11 @@ const regexPatterns: RegexPattern[] = [
2125
matchTypes: [MatchType.Full, MatchType.File, MatchType.Severity, MatchType.Message]
2226
},
2327
{ // path/to/ld[.exe]: message (without trailing colon)
24-
regexPattern: /^(.*ld(?:\.exe)?):\s+(.+)(?<!:)$/,
28+
regexPattern: /^(.*ld(?:\.exe)?):\s+(.+)(?<!:)\s*$/,
2529
matchTypes: [MatchType.Full, MatchType.File, MatchType.Message]
2630
},
27-
{ // /path/to/file:line: message (without "[fatal] severity:" or trailing colon)
28-
regexPattern: /^(.+?):(\d+):\s+(?!fatal\s+\w+:)(?!\w+:)(.+)(?<!:)$/,
31+
{ // path/to/file:line: message (with neither "[fatal] severity:" nor trailing colon nor leading "make: *** [" nor leading "make[line]: *** [")
32+
regexPattern: /^(?!\s*make.*:\s\*\*\*\s\[)(.+?):(\d+):\s+(?!fatal\s+\w+:)(?!\w+:)(.+)(?<!:)\s*$/,
2933
matchTypes: [MatchType.Full, MatchType.File, MatchType.Line, MatchType.Message]
3034
}
3135
];

test/unit-tests/diagnostics.test.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,34 @@ suite('Diagnostics', () => {
323323
expect(path.posix.normalize(diag.file)).to.eq(diag.file);
324324
expect(path.posix.isAbsolute(diag.file)).to.be.false;
325325
});
326+
test('Parsing linker error of type "/path/to/ld: path/to/file.obj:path/to/file:line: message"', () => {
327+
const lines = ['/path/to/ld: path/to/file.obj:path/to/file:42: message'];
328+
feedLines(build_consumer, [], lines);
329+
expect(build_consumer.compilers.gnuld.diagnostics).to.have.length(1);
330+
const diag = build_consumer.compilers.gnuld.diagnostics[0];
331+
332+
expect(diag.location.start.line).to.eq(41);
333+
expect(diag.location.start.character).to.eq(0);
334+
expect(diag.message).to.eq('message');
335+
expect(diag.file).to.eq('path/to/file');
336+
expect(diag.severity).to.eq('error');
337+
expect(path.posix.normalize(diag.file)).to.eq(diag.file);
338+
expect(path.posix.isAbsolute(diag.file)).to.be.false;
339+
});
340+
test('Parsing linker error of type "/path/to/ld.exe: path/to/file.obj:path/to/file:line: message"', () => {
341+
const lines = ['/path/to/ld.exe: path/to/file.obj:path/to/file:42: message'];
342+
feedLines(build_consumer, [], lines);
343+
expect(build_consumer.compilers.gnuld.diagnostics).to.have.length(1);
344+
const diag = build_consumer.compilers.gnuld.diagnostics[0];
345+
346+
expect(diag.location.start.line).to.eq(41);
347+
expect(diag.location.start.character).to.eq(0);
348+
expect(diag.message).to.eq('message');
349+
expect(diag.file).to.eq('path/to/file');
350+
expect(diag.severity).to.eq('error');
351+
expect(path.posix.normalize(diag.file)).to.eq(diag.file);
352+
expect(path.posix.isAbsolute(diag.file)).to.be.false;
353+
});
326354
test('Parsing linker error of type "/path/to/ld: path/to/file:line: message"', () => {
327355
const lines = ['/path/to/ld: path/to/file:42: message'];
328356
feedLines(build_consumer, [], lines);
@@ -663,6 +691,7 @@ suite('Diagnostics', () => {
663691
];
664692
feedLines(build_consumer, [], lines);
665693
expect(build_consumer.compilers.gcc.diagnostics).to.have.length(0);
694+
expect(build_consumer.compilers.gnuld.diagnostics).to.have.length(0);
666695
});
667696

668697
test('Parse MSVC single proc error', () => {

0 commit comments

Comments
 (0)