[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / utils / make-ast-dump-check.sh
blobcb4c7924e4c3ee81484f1dc1b5174c2f05a53538
1 #!/usr/bin/env bash
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-*
15 prefix=CHECK
17 if [ -z ${generate_serialization_test+x} ];
18 then generate_serialization_test=0;
21 while [[ "$#" -ne 0 ]]; do
22 case "$1" in
23 --check-prefix)
24 shift
25 prefix="$1"
27 --implicit-check-not)
28 shift
30 -*)
33 file="$1"
35 esac
36 shift
37 done
39 testdir="$(dirname "$file")"
41 read -r -d '' script <<REWRITE
42 BEGIN {
43 skipping_builtins = 0
44 matched_last_line = 0
47 /^[\`|].* line:/ {
48 skipping_builtins = 0
51 /^[\`|].* col:/ {
52 skipping_builtins = 0
56 if (skipping_builtins == 1) {
57 matched_last_line = 0
58 next
62 /TranslationUnitDecl/ {
63 skipping_builtins = 1
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)
80 matched_last_line == 0 {
81 print "// ${prefix}:" s
84 matched_last_line == 1 {
85 print "// ${prefix}-NEXT:" s
89 matched_last_line = 1
91 REWRITE
93 echo "$script"
96 cat "$file" | grep -v "$prefix"
97 awk "$script"
98 } > "$file.new"
100 mv "$file.new" "$file"