summaryrefslogtreecommitdiffstats
path: root/clang/test/AST/gen_ast_dump_json_test.py
diff options
context:
space:
mode:
authorAaron Ballman <aaron@aaronballman.com>2019-12-03 13:04:45 -0500
committerAaron Ballman <aaron@aaronballman.com>2019-12-03 13:05:59 -0500
commitfa6c157ebeef55fd1e00266d1d1ad6aaa6161ef2 (patch)
treee993d3ddb2c7556b6eaa3c3da16c6fd9fdebf8ac /clang/test/AST/gen_ast_dump_json_test.py
parent6ed9cef25f915d4533f261c401cee29d8d8012d5 (diff)
downloadbcm5719-llvm-fa6c157ebeef55fd1e00266d1d1ad6aaa6161ef2.tar.gz
bcm5719-llvm-fa6c157ebeef55fd1e00266d1d1ad6aaa6161ef2.zip
Differentiate between the presumed and actual file when dumping the AST to JSON
Currently, when dumping the AST to JSON, the presumed file is what is included when dumping a source location. This patch changes the behavior to instead dump the actual file, and only dump a presumed file name when it differs from the actual file. This also corrects an issue with the test script generator that would prevent it from working on Windows due to file permissions issues.
Diffstat (limited to 'clang/test/AST/gen_ast_dump_json_test.py')
-rw-r--r--clang/test/AST/gen_ast_dump_json_test.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/clang/test/AST/gen_ast_dump_json_test.py b/clang/test/AST/gen_ast_dump_json_test.py
index 3a406469965..87b3318f76c 100644
--- a/clang/test/AST/gen_ast_dump_json_test.py
+++ b/clang/test/AST/gen_ast_dump_json_test.py
@@ -180,7 +180,7 @@ def process_file(source_file, clang_binary, cmdline_filters, cmdline_opts,
filter_json(j, filters, out_asts)
- with tempfile.NamedTemporaryFile("w") as f:
+ with tempfile.NamedTemporaryFile("w", delete=False) as f:
with open(source_file, "r") as srcf:
for line in srcf.readlines():
# copy up to the note:
@@ -201,6 +201,7 @@ def process_file(source_file, clang_binary, cmdline_filters, cmdline_opts,
f.write(out_str)
f.flush()
+ f.close()
if do_update:
print("Updating json appended source file to %s." % source_file)
copyfile(f.name, source_file)
@@ -209,6 +210,7 @@ def process_file(source_file, clang_binary, cmdline_filters, cmdline_opts,
dest_path = '%s-json%s%s' % (partition[0], partition[1], partition[2])
print("Writing json appended source file to %s." % dest_path)
copyfile(f.name, dest_path)
+ os.remove(f.name)
return 0
OpenPOWER on IntegriCloud