[PATCH] D81786: [clang][utils] Modify make-ast-dump-check.sh to generate AST serialization dump tests

Bruno Ricci via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Jun 13 05:22:22 PDT 2020


riccibruno created this revision.
riccibruno added reviewers: aaron.ballman, stephenkelly.
riccibruno added a project: clang.
Herald added a reviewer: jdoerfert.
Herald added subscribers: cfe-commits, sstefan1.
riccibruno added a comment.

Example of a test: F12153075: ast-dump-lambda.cpp <https://reviews.llvm.org/F12153075>


An AST serialization dump test is a test which compares the output of `-ast-dump` on the source and of `-ast-dump-all` on a PCH generated from the source. Modulo a few differences the outputs should match.

This patch to `make-ast-dump-check.sh` enables automatically generating these tests.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81786

Files:
  clang/utils/make-ast-dump-check.sh


Index: clang/utils/make-ast-dump-check.sh
===================================================================
--- clang/utils/make-ast-dump-check.sh
+++ clang/utils/make-ast-dump-check.sh
@@ -3,12 +3,21 @@
 # This script is intended as a FileCheck replacement to update the test
 # expectations in a -ast-dump test.
 #
-# Usage:
+# Usage (to generate normal AST dump tests):
 #
 # $ lit -DFileCheck=$PWD/utils/make-ast-dump-check.sh test/AST/ast-dump-openmp-*
+#
+# Usage (to generate serialization AST dump tests):
+#
+# $ lit -DFileCheck="generate_serialization_test=1 $PWD/utils/make-ast-dump-check.sh"
+#     test/AST/ast-dump-openmp-*
 
 prefix=CHECK
 
+if [ -z ${generate_serialization_test+x} ];
+  then generate_serialization_test=0;
+fi
+
 while [[ "$#" -ne 0 ]]; do
   case "$1" in
   --check-prefix)
@@ -54,6 +63,10 @@
   s = \$0
   gsub("0x[0-9a-fA-F]+", "{{.*}}", s)
   gsub("$testdir/", "{{.*}}", s)
+  if ($generate_serialization_test == 1) {
+    gsub(" imported", "{{( imported)?}}", s)
+    gsub(" <undeserialized declarations>", "{{( <undeserialized declarations>)?}}", s)
+  }
 }
 
 matched_last_line == 0 {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81786.270571.patch
Type: text/x-patch
Size: 1128 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200613/23e291b7/attachment-0001.bin>


More information about the cfe-commits mailing list