summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/test/AST/gen_ast_dump_json_test.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/clang/test/AST/gen_ast_dump_json_test.py b/clang/test/AST/gen_ast_dump_json_test.py
index 464987b2217..f32b69afb03 100644
--- a/clang/test/AST/gen_ast_dump_json_test.py
+++ b/clang/test/AST/gen_ast_dump_json_test.py
@@ -68,6 +68,8 @@ def main():
update_or_generate_group.add_argument("--update", help="Update the file in-place", action="store_true")
update_or_generate_group.add_argument("--opts", help="other options",
action="store", default='', type=str)
+ parser.add_argument("--update-manual", help="When using --update, also update files that do not have the "
+ "autogenerated disclaimer", action="store_true")
args = parser.parse_args()
if not args.source:
@@ -89,17 +91,20 @@ def main():
# When updating the first line of the test must be a RUN: line
with open(args.source, "r") as srcf:
first_line = srcf.readline()
- filters_line_next = False
+ found_autogenerated_line = False
filters_line = None
for i, line in enumerate(srcf.readlines()):
- if filters_line_next:
+ if found_autogenerated_line:
# print("Filters line: '", line.rstrip(), "'", sep="")
if line.startswith(filters_line_prefix):
filters_line = line[len(filters_line_prefix):].rstrip()
break
if line.startswith(note_firstline):
- filters_line_next = True
+ found_autogenerated_line = True
# print("Found autogenerated disclaimer at line", i + 1)
+ if not found_autogenerated_line and not args.update_manual:
+ print("Not updating", args.source, "since it is not autogenerated.")
+ sys.exit(0)
if not args.filters and filters_line:
args.filters = filters_line
print("Inferred filters as '" + args.filters + "'")
OpenPOWER on IntegriCloud