[all-commits] [llvm/llvm-project] a763d9: [gen_ast_dump_json_test.py] Add a --update flag

Alexander Richardson via All-commits all-commits at lists.llvm.org
Fri Nov 15 04:53:15 PST 2019


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: a763d985012bdc5c5fc7bbc836b0dfddbb9af2d8
      https://github.com/llvm/llvm-project/commit/a763d985012bdc5c5fc7bbc836b0dfddbb9af2d8
  Author: Alex Richardson <Alexander.Richardson at cl.cam.ac.uk>
  Date:   2019-11-15 (Fri, 15 Nov 2019)

  Changed paths:
    M clang/test/AST/gen_ast_dump_json_test.py

  Log Message:
  -----------
  [gen_ast_dump_json_test.py] Add a --update flag

This will allow updating the JSON tests for new format changes. Instead of
simply appending the JSON to the input file, the script will now make a
copy of the input file up to the "CHECK lines have been autogenerated"
disclaimer and then append the new JSON.

See https://reviews.llvm.org/D70119


  Commit: 698ea9cb21e7edd6c1119367243a0134d0bb22d7
      https://github.com/llvm/llvm-project/commit/698ea9cb21e7edd6c1119367243a0134d0bb22d7
  Author: Alex Richardson <Alexander.Richardson at cl.cam.ac.uk>
  Date:   2019-11-15 (Fri, 15 Nov 2019)

  Changed paths:
    M clang/test/AST/gen_ast_dump_json_test.py

  Log Message:
  -----------
  [gen_ast_dump_json_test.py] Parse RUN: lines with --update

See https://reviews.llvm.org/D70119


  Commit: 049f4c90eb146f80f0f8ca2c7341547b67513e3c
      https://github.com/llvm/llvm-project/commit/049f4c90eb146f80f0f8ca2c7341547b67513e3c
  Author: Alex Richardson <Alexander.Richardson at cl.cam.ac.uk>
  Date:   2019-11-15 (Fri, 15 Nov 2019)

  Changed paths:
    M clang/test/AST/gen_ast_dump_json_test.py

  Log Message:
  -----------
  [gen_ast_dump_json_test.py] Infer --filters flags when using --update

See https://reviews.llvm.org/D70119


  Commit: 90dbb47616da69d9cb41e9dfd520ef90b8afa26f
      https://github.com/llvm/llvm-project/commit/90dbb47616da69d9cb41e9dfd520ef90b8afa26f
  Author: Alex Richardson <Alexander.Richardson at cl.cam.ac.uk>
  Date:   2019-11-15 (Fri, 15 Nov 2019)

  Changed paths:
    M clang/test/AST/gen_ast_dump_json_test.py

  Log Message:
  -----------
  [gen_ast_dump_json_test.py] Skip manual tests when using --update

See https://reviews.llvm.org/D70119


  Commit: d09e811cb4da3fab554f8a189a79f9ac74cb8d0d
      https://github.com/llvm/llvm-project/commit/d09e811cb4da3fab554f8a189a79f9ac74cb8d0d
  Author: Alex Richardson <Alexander.Richardson at cl.cam.ac.uk>
  Date:   2019-11-15 (Fri, 15 Nov 2019)

  Changed paths:
    M clang/test/AST/gen_ast_dump_json_test.py
    M clang/test/CMakeLists.txt

  Log Message:
  -----------
  [gen_ast_dump_json_test.py] Copy to binary directory to omit --clang argument

The script will now check if a clang binary exists in the same directory
and default to that instead of requiring a --clang argument. The script
is copied to the clang build directory using CMake configure_file() with
COPYONLY. This ensures that the version in the build directory is updated
any time the source version changes.

See https://reviews.llvm.org/D70119


  Commit: 7debe5132c06c8dc53517ed2bd38d4a2f8cee126
      https://github.com/llvm/llvm-project/commit/7debe5132c06c8dc53517ed2bd38d4a2f8cee126
  Author: Alex Richardson <Alexander.Richardson at cl.cam.ac.uk>
  Date:   2019-11-15 (Fri, 15 Nov 2019)

  Changed paths:
    M clang/test/AST/gen_ast_dump_json_test.py

  Log Message:
  -----------
  [gen_ast_dump_json_test.py] Allow updating multiple files in one go

With this change it is possible to update all JSON dump tests using the
following command:
python $LLVM_BINDIR/gen_ast_dump_json_test.py --update --source $LLVM_SRC/clang/test/AST/*-json.*

See https://reviews.llvm.org/D70119


  Commit: 709ea1720799b788b3c8c59f5571134e983f9cc6
      https://github.com/llvm/llvm-project/commit/709ea1720799b788b3c8c59f5571134e983f9cc6
  Author: Alex Richardson <Alexander.Richardson at cl.cam.ac.uk>
  Date:   2019-11-15 (Fri, 15 Nov 2019)

  Changed paths:
    M clang/test/AST/ast-dump-decl-json.m
    M clang/test/AST/ast-dump-expr-json.c

  Log Message:
  -----------
  [NFC] Regenerate ast-dump-json tests

This was done by running `python $LLVM_BINDIR/gen_ast_dump_json_test.py --update --source $LLVM_SRC/clang/test/AST/*-json.*`
Only changes are whitespace and line endings.

Differential Revision: https://reviews.llvm.org/D70119


  Commit: 3c3048c18b09cac5f7d17fc0655d781e457fd006
      https://github.com/llvm/llvm-project/commit/3c3048c18b09cac5f7d17fc0655d781e457fd006
  Author: Alex Richardson <Alexander.Richardson at cl.cam.ac.uk>
  Date:   2019-11-15 (Fri, 15 Nov 2019)

  Changed paths:
    M clang/include/clang/AST/JSONNodeDumper.h
    M clang/lib/AST/JSONNodeDumper.cpp
    M clang/test/AST/ast-dump-decl-context-json.cpp
    M clang/test/AST/ast-dump-decl-json.c
    M clang/test/AST/ast-dump-decl-json.m
    M clang/test/AST/ast-dump-expr-json.c
    M clang/test/AST/ast-dump-expr-json.cpp
    M clang/test/AST/ast-dump-expr-json.m
    M clang/test/AST/ast-dump-funcs-json.cpp
    M clang/test/AST/ast-dump-if-json.cpp
    M clang/test/AST/ast-dump-macro-json.c
    M clang/test/AST/ast-dump-record-definition-data-json.cpp
    M clang/test/AST/ast-dump-records-json.cpp
    M clang/test/AST/ast-dump-stmt-json.c
    M clang/test/AST/ast-dump-stmt-json.cpp
    M clang/test/AST/ast-dump-stmt-json.m
    M clang/test/AST/ast-dump-template-decls-json.cpp

  Log Message:
  -----------
  Include the mangled name in -ast-dump=json

I am planning to use this feature to make update_cc_test_checks.py less fragile
by obtaining the mangled names directly from -ast-dump=json. Currently,
it uses c-index-test which ignores the -triple=, etc. arguments that are
in the RUN: line and therefore does not generate checks for some targets.

The AST dump tests were updated using the following command:
`python $LLVM_BINDIR/gen_ast_dump_json_test.py --update --source $LLVM_SRC/clang/test/AST/*-json.*`

Reviewers: aaron.ballman

Reviewed By: aaron.ballman

Subscribers: rsmith, MaskRay, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D69564


  Commit: 0df4a8f72a4fadc1e0978a0aa1786afa34945046
      https://github.com/llvm/llvm-project/commit/0df4a8f72a4fadc1e0978a0aa1786afa34945046
  Author: Alex Richardson <Alexander.Richardson at cl.cam.ac.uk>
  Date:   2019-11-15 (Fri, 15 Nov 2019)

  Changed paths:
    M llvm/utils/update_cc_test_checks.py

  Log Message:
  -----------
  [update_cc_test_checks.py] Use -ast-dump=json to get mangled name

Summary:
Using c-index-test is fragile since it does not parse all the clang
arguments that are used in the RUN: line. This can result in incorrect
mangled names that do not match any of the generated IR.
For example macOS triples include a leading underscore (which was handled
with a hack in the current script). For the CHERI target we have added
new qualifiers which affect C++ name mangling, but will be included added
by update_cc_test_checks since it parses the source file with the host
triple because it ignores the -triple= argument passed to clang -cc1.

Using the new feature of including the mangled name in the JSON AST dump
(see D69564), we can parse the output of the RUN: command with
"-fsyntax-only -ast-dump=json" appended.
This should make the script less fragile and also forks one process less.

Reviewers: MaskRay, xbolva00

Reviewed By: MaskRay

Subscribers: llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D69565


Compare: https://github.com/llvm/llvm-project/compare/0908093977b2...0df4a8f72a4f


More information about the All-commits mailing list