This is an archive of the discontinued LLVM Phabricator instance.

[update_cc_test_checks.py] Use -ast-dump=json to get mangled name
ClosedPublic

Authored by arichardson on Oct 29 2019, 7:47 AM.

Details

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 simply 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.

Diff Detail

Event Timeline

arichardson created this revision.Oct 29 2019, 7:47 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 29 2019, 7:47 AM
MaskRay added inline comments.Oct 29 2019, 9:01 AM
llvm/utils/update_cc_test_checks.py
47

json_dump_args = [args.clang, *clang_args]

48

Can you switch to single quotes? I think that is preferred style and is consistent with other occurrences of string literals.

50

Capitalize for

63

This script is Python 3 only. No need to check sys.version_info

arichardson marked 4 inline comments as done.

Address review commments

MaskRay added inline comments.Oct 29 2019, 2:56 PM
llvm/utils/update_cc_test_checks.py
46

json_dump_args = [args.clang, *clang_args, '-fsyntax-only', '-o', '-']

55

!= 0

Make the type clear

60

Delete the variable output

222

Delete unrelated changes.

232

ditto

arichardson marked 3 inline comments as done.

Address comments

llvm/utils/update_cc_test_checks.py
46

I think this syntax requires python 3.5. Is that a reasonable baseline?

For me 3.5 is the oldest version I use this script with. However, that might not be true for everyone?

arichardson marked 2 inline comments as done.

Use python 3.5 unpacking syntax

llvm/utils/update_cc_test_checks.py
46

Never mind, subprocess.run() is already python 3.5 only. I'll make that change

MaskRay accepted this revision.Oct 30 2019, 2:06 PM
MaskRay added inline comments.
llvm/utils/update_cc_test_checks.py
269–270

-ast-dump=json -> -Xclang -ast-dump=json

This revision is now accepted and ready to land.Oct 30 2019, 2:06 PM
This revision was automatically updated to reflect the committed changes.