1#! /bin/bash 2 3# This script is intended as a FileCheck replacement to update the test 4# expectations in a -ast-dump test. 5# 6# Usage: 7# 8# $ lit -DFileCheck=$PWD/utils/make-ast-dump-check.sh test/AST/ast-dump-openmp-* 9 10prefix=CHECK 11 12while [[ "$#" -ne 0 ]]; do 13 case "$1" in 14 --check-prefix) 15 shift 16 prefix="$1" 17 ;; 18 --implicit-check-not) 19 shift 20 ;; 21 -*) 22 ;; 23 *) 24 file="$1" 25 ;; 26 esac 27 shift 28done 29 30testdir="$(dirname "$file")" 31 32read -r -d '' script <<REWRITE 33BEGIN { 34 skipping_builtins = 0 35 matched_last_line = 0 36} 37 38/^[\`|].* line:/ { 39 skipping_builtins = 0 40} 41 42{ 43 if (skipping_builtins == 1) { 44 matched_last_line = 0 45 next 46 } 47} 48 49/TranslationUnitDecl/ { 50 skipping_builtins = 1 51} 52 53{ 54 s = \$0 55 gsub("0x[0-9a-fA-F]+", "{{.*}}", s) 56 gsub("$testdir/", "{{.*}}", s) 57} 58 59matched_last_line == 0 { 60 print "// ${prefix}: " s 61} 62 63matched_last_line == 1 { 64 print "// ${prefix}-NEXT: " s 65} 66 67{ 68 matched_last_line = 1 69} 70REWRITE 71 72echo "$script" 73 74{ 75 cat "$file" | grep -v "$prefix" 76 awk "$script" 77} > "$file.new" 78 79mv "$file.new" "$file" 80