+# Check if any of \@bad_flags occurs after $good_flag. Doesn't check if
+# $good_flag is present.
+sub flag_overwritten {
+ my ($line, $good_flag, $bad_flags) = @_;
+
+ if (not any_flags_used($line, @{$bad_flags})) {
+ return 0;
+ }
+
+ my $bad_pos = 0;
+ foreach my $flag (@{$bad_flags}) {
+ while ($line =~ /$flag/g) {
+ if ($bad_pos < $+[0]) {
+ $bad_pos = $+[0];
+ }
+ }
+ }
+ my $good_pos = 0;
+ while ($line =~ /$good_flag/g) {
+ $good_pos = $+[0];
+ }
+ if ($good_pos > $bad_pos) {
+ return 0;
+ }
+ return 1;
+}