Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add diagnostic printing for actor codegen #45

Merged
merged 1 commit into from
Jun 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions codegen/actor_codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
Loading