From 6c192f7e58f49a1354fb2fc184681d83afadffdf Mon Sep 17 00:00:00 2001 From: Jake Hillion Date: Wed, 20 Dec 2023 15:54:50 +0000 Subject: [PATCH] clangparser: provide correct kind for classes/unions Previously ClangTypeParser assumed all RecordTypes were structs. This is fine for structs and classes but completely incorrect for unions. Check which type it is and give type graph the correct one. Test plan: - Unions static assert without this change because their size/alignment is wrong. --- oi/type_graph/ClangTypeParser.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/oi/type_graph/ClangTypeParser.cpp b/oi/type_graph/ClangTypeParser.cpp index 5190478..2025c84 100644 --- a/oi/type_graph/ClangTypeParser.cpp +++ b/oi/type_graph/ClangTypeParser.cpp @@ -183,7 +183,12 @@ Type& ClangTypeParser::enumerateClass(const clang::RecordType& ty) { std::string name = decl->getNameAsString(); - auto kind = Class::Kind::Struct; // TODO: kind + auto kind = Class::Kind::Struct; + if (ty.isUnionType()) { + kind = Class::Kind::Union; + } else if (ty.isClassType()) { + kind = Class::Kind::Class; + } int virtuality = 0;