From b92db40cc696f331a304ea2026cfdaa633060d51 Mon Sep 17 00:00:00 2001 From: meserve-amd Date: Wed, 24 Jul 2024 14:30:42 -0500 Subject: [PATCH] SWDEV-475540: Fix build time parsing of unions - Fixes issue where types defined inside of a union were being skipped for ostream operator generation - Also fixes issue where these types were not correctly defined in the resulting operators' parameters - Fixes edge case where types with "union" in their name were being skipped as if they were union types Change-Id: I736c57788cbc461e9493d4651756dc06c278430d [ROCm/rocprofiler commit: 70268ccc9f3b8231c5c934ec75073a0c3a2e40a9] --- projects/rocprofiler/script/gen_ostream_ops.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/projects/rocprofiler/script/gen_ostream_ops.py b/projects/rocprofiler/script/gen_ostream_ops.py index d101e99c48..3e19869008 100755 --- a/projects/rocprofiler/script/gen_ostream_ops.py +++ b/projects/rocprofiler/script/gen_ostream_ops.py @@ -242,10 +242,18 @@ def gen_cppheader(infilepath, outfilepath, rank): output_filename_h.write(header_basic) output_filename_h.write("// End of basic ostream ops\n\n") + for c in cppHeader.classes.copy(): + # Types defined inside of unions are incorrectly prepended with "union " after parsing by CppHeaderParser + # Remove "union " from the beginning of the full class name to correct the eventual output + if "union " in c[0:6] and "::union" not in c[-8:]: + new_name = c[6:] + cppHeader.classes[new_name] = cppHeader.classes[c] + del cppHeader.classes[c] + for c in cppHeader.classes: if c[-2] == ":" and c[-1] == ":": continue # ostream operator cannot be overloaded for anonymous struct therefore it is skipped - if "union" in c: + if "::union" in c: continue if c in structs_analyzed: continue