<commit_before>#!/usr/bin/env perl

my %noninlined;
my %mocked;

# Functions in public header don't get the noinline annotation
# so whitelist them here
$noninlined{"virEventAddTimeout"} = 1;
# This one confuses the script as its defined in the mock file
# but is actually just a local helper
$noninlined{"virMockStatRedirect"} = 1;

foreach my $arg (@ARGV) {
    if ($arg =~ /\.h$/) {
        #print "Scan header $arg\n";
        &scan_annotations($arg);
    } elsif ($arg =~ /mock\.c$/) {
        #print "Scan mock $arg\n";
        &scan_overrides($arg);
    }
}

my $warned = 0;
foreach my $func (keys %mocked) {
    next if exists $noninlined{$func};

    $warned++;
    print STDERR "$func is mocked at $mocked{$func} but missing noinline annotation\n";
}

exit $warned ? 1 : 0;


sub scan_annotations {
    my $file = shift;

    open FH, $file or die "cannot read $file: $!";

    my $func;
    while (<FH>) {
        if (/^\s*(\w+)\(/ || /^(?:\w+\*?\s+)+(?:\*\s*)?(\w+)\(/) {
            my $name = $1;
            if ($name !~ /ATTRIBUTE/) {
                $func = $name;
            }
        } elsif (/^\s*$/) {
            $func = undef;
        }
        if (/ATTRIBUTE_NOINLINE/) {<commit_msg>syntax-check: mock-noinline: fix after G_GNUC attribute invocations<commit_after>#!/usr/bin/env perl

my %noninlined;
my %mocked;

# Functions in public header don't get the noinline annotation
# so whitelist them here
$noninlined{"virEventAddTimeout"} = 1;
# This one confuses the script as its defined in the mock file
# but is actually just a local helper
$noninlined{"virMockStatRedirect"} = 1;

foreach my $arg (@ARGV) {
    if ($arg =~ /\.h$/) {
        #print "Scan header $arg\n";
        &scan_annotations($arg);
    } elsif ($arg =~ /mock\.c$/) {
        #print "Scan mock $arg\n";
        &scan_overrides($arg);
    }
}

my $warned = 0;
foreach my $func (keys %mocked) {
    next if exists $noninlined{$func};

    $warned++;
    print STDERR "$func is mocked at $mocked{$func} but missing noinline annotation\n";
}

exit $warned ? 1 : 0;


sub scan_annotations {
    my $file = shift;

    open FH, $file or die "cannot read $file: $!";

    my $func;
    while (<FH>) {
        if (/^\s*(\w+)\(/ || /^(?:\w+\*?\s+)+(?:\*\s*)?(\w+)\(/) {
            my $name = $1;
            if ($name !~ /(?:G_GNUC|ATTRIBUTE)/) {
                $func = $name;
            }
        } elsif (/^\s*$/) {
            $func = undef;
        }
        if (/ATTRIBUTE_NOINLINE/) {
{'fraction_non_alphanumeric': 0.1777509068923821, 'fraction_numerical': 0.0048367593712212815, 'mean_word_length': 2.3049267643142475, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7429768', 'n_tokens_mistral': 921, 'n_tokens_neox': 872, 'n_words': 256}