| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
prefix=CHECK |
| 16 |
|
| 17 |
if [ -z ${generate_serialization_test+x} ]; |
| 18 |
then generate_serialization_test=0; |
| 19 |
fi |
| 20 |
|
| 21 |
while [[ "$#" -ne 0 ]]; do |
| 22 |
case "$1" in |
| 23 |
--check-prefix) |
| 24 |
shift |
| 25 |
prefix="$1" |
| 26 |
;; |
| 27 |
--implicit-check-not) |
| 28 |
shift |
| 29 |
;; |
| 30 |
-*) |
| 31 |
;; |
| 32 |
*) |
| 33 |
file="$1" |
| 34 |
;; |
| 35 |
esac |
| 36 |
shift |
| 37 |
done |
| 38 |
|
| 39 |
testdir="$(dirname "$file")" |
| 40 |
|
| 41 |
read -r -d '' script <<REWRITE |
| 42 |
BEGIN { |
| 43 |
skipping_builtins = 0 |
| 44 |
matched_last_line = 0 |
| 45 |
} |
| 46 |
|
| 47 |
/^[\`|].* line:/ { |
| 48 |
skipping_builtins = 0 |
| 49 |
} |
| 50 |
|
| 51 |
/^[\`|].* col:/ { |
| 52 |
skipping_builtins = 0 |
| 53 |
} |
| 54 |
|
| 55 |
{ |
| 56 |
if (skipping_builtins == 1) { |
| 57 |
matched_last_line = 0 |
| 58 |
next |
| 59 |
} |
| 60 |
} |
| 61 |
|
| 62 |
/TranslationUnitDecl/ { |
| 63 |
skipping_builtins = 1 |
| 64 |
} |
| 65 |
|
| 66 |
{ |
| 67 |
s = \$0 |
| 68 |
gsub("0x[0-9a-fA-F]+", "{{.*}}", s) |
| 69 |
gsub("$testdir/", "{{.*}}", s) |
| 70 |
if ($generate_serialization_test == 1) { |
| 71 |
gsub(" imported", "{{( imported)?}}", s) |
| 72 |
gsub(" <undeserialized declarations>", "{{( <undeserialized declarations>)?}}", s) |
| 73 |
gsub("line:[0-9]+:[0-9]+", "line:{{.*}}", s) |
| 74 |
gsub("line:[0-9]+", "line:{{.*}}", s) |
| 75 |
gsub("col:[0-9]+", "col:{{.*}}", s) |
| 76 |
gsub(":[0-9]+:[0-9]+", "{{.*}}", s) |
| 77 |
} |
| 78 |
} |
| 79 |
|
| 80 |
matched_last_line == 0 { |
| 81 |
print "// ${prefix}:" s |
| 82 |
} |
| 83 |
|
| 84 |
matched_last_line == 1 { |
| 85 |
print "// ${prefix}-NEXT:" s |
| 86 |
} |
| 87 |
|
| 88 |
{ |
| 89 |
matched_last_line = 1 |
| 90 |
} |
| 91 |
REWRITE |
| 92 |
|
| 93 |
echo "$script" |
| 94 |
|
| 95 |
{ |
| 96 |
cat "$file" | grep -v "$prefix" |
| 97 |
awk "$script" |
| 98 |
} > "$file.new" |
| 99 |
|
| 100 |
mv "$file.new" "$file" |