3 # This script is intended as a FileCheck replacement to update the test
4 # expectations in a -ast-dump test.
6 # Usage (to generate normal AST dump tests):
8 # $ lit -DFileCheck=$PWD/utils/make-ast-dump-check.sh test/AST/ast-dump-openmp-*
10 # Usage (to generate serialization AST dump tests):
12 # $ lit -DFileCheck="generate_serialization_test=1 $PWD/utils/make-ast-dump-check.sh"
13 # test/AST/ast-dump-openmp-*
17 if [ -z ${generate_serialization_test+x} ];
18 then generate_serialization_test
=0;
21 while [[ "$#" -ne 0 ]]; do
39 testdir
="$(dirname "$file")"
41 read -r -d '' script <<REWRITE
56 if (skipping_builtins == 1) {
62 /TranslationUnitDecl/ {
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)
80 matched_last_line == 0 {
81 print "// ${prefix}:" s
84 matched_last_line == 1 {
85 print "// ${prefix}-NEXT:" s
96 cat "$file" |
grep -v "$prefix"
100 mv "$file.new" "$file"