From 0e163b4ee1e2fef35ae06e37284000a16276ebac Mon Sep 17 00:00:00 2001 From: zhanglei1949 Date: Fri, 14 Jun 2024 08:40:07 +0000 Subject: [PATCH] add disgonostic printing --- codegen/actor_codegen.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/codegen/actor_codegen.py b/codegen/actor_codegen.py index 5c04453..40a2245 100755 --- a/codegen/actor_codegen.py +++ b/codegen/actor_codegen.py @@ -34,6 +34,19 @@ def process_actor_groups(process_args): p.close() p.join() +def check_diagnostics_and_print(unit): + if unit.diagnostics: + parse_success = False + for diag in unit.diagnostics: + if diag.severity > clang.cindex.Diagnostic.Warning: + print(f"Error: {diag.spelling}") + print(f" File: {diag.location.file.name}") + print(f" Line: {diag.location.line}") + print(f" Column: {diag.location.column}") + print(f" Severity: {diag.severity}") + else: + parse_success = True + return parse_success def process_one_actor_group(arg: ActorGroupProcessArgument): include_path = os.path.relpath(arg.filepath, arg.source_dir) @@ -42,6 +55,9 @@ def process_one_actor_group(arg: ActorGroupProcessArgument): index = clang.cindex.Index.create() unit = index.parse(arg.filepath, ['-nostdinc++', '-x', 'c++', '-std=gnu++17'] + arg.include_list) + if not check_diagnostics_and_print(unit): + raise Exception("Failed to parse %s" % arg.filepath) + actg_list = [] ns_list = [] traverse_actor_group_types(unit.cursor, arg.filepath, actg_list, ns_list) @@ -81,6 +97,9 @@ def process_one_actor(arg: ActorProcessArgument): index = clang.cindex.Index.create() unit = index.parse(arg.filepath, ['-nostdinc++', '-x', 'c++', '-std=gnu++17'] + arg.include_list) + if not check_diagnostics_and_print(unit): + raise Exception("Failed to parse %s" % arg.filepath) + act_list = [] ns_list = [] traverse_actor_types(unit.cursor, arg.filepath, act_list, ns_list)