Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 1db054b

Browse files
committed
When building clang-tidy commands, filter out the sed command that may be appended to each compile command
See #49542
1 parent 1255754 commit 1db054b

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

tools/clang_tidy/lib/src/command.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ class Command {
5858
static final RegExp _pathRegex = RegExp(r'\S*clang/bin/clang');
5959
static final RegExp _argRegex = RegExp(r'-MF \S*');
6060

61+
// Filter out any extra commands that were appended to the compile command.
62+
static final RegExp _extraCommandRegex = RegExp(r'&&.*$');
63+
6164
String? _tidyArgs;
6265

6366
/// The command line arguments of the command.
@@ -66,6 +69,7 @@ class Command {
6669
String result = command;
6770
result = result.replaceAll(_pathRegex, '');
6871
result = result.replaceAll(_argRegex, '');
72+
result = result.replaceAll(_extraCommandRegex, '');
6973
return result;
7074
})();
7175
}

tools/clang_tidy/test/clang_tidy_test.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,5 +575,16 @@ Future<int> main(List<String> args) async {
575575
expect(lintAction, equals(LintAction.lint));
576576
});
577577

578+
test('Command filters out sed command after a compile command', () {
579+
final Command command = Command.fromMap(<String, String>{
580+
'directory': '/unused',
581+
'command':
582+
'../../buildtools/mac-x64/clang/bin/clang filename '
583+
"&& sed -i 's@/b/f/w@../..@g' filename",
584+
'file': 'unused',
585+
});
586+
expect(command.tidyArgs.trim(), 'filename');
587+
});
588+
578589
return 0;
579590
}

0 commit comments

Comments
 (0)