From 531026b55b455c450a80bffe38030d6a26ae06cf Mon Sep 17 00:00:00 2001 From: Fred Chow Date: Tue, 30 Mar 2021 19:20:56 -0700 Subject: [PATCH 1/2] a couple of small fixes from testing with C code --- src/mapleall/maple_ir/src/mir_function.cpp | 3 ++- src/mapleall/maple_ir/src/mir_nodes.cpp | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/mapleall/maple_ir/src/mir_function.cpp b/src/mapleall/maple_ir/src/mir_function.cpp index 46a5384bee..42195d17df 100644 --- a/src/mapleall/maple_ir/src/mir_function.cpp +++ b/src/mapleall/maple_ir/src/mir_function.cpp @@ -297,7 +297,8 @@ void MIRFunction::Dump(bool withoutBody) { // class and interface decls. these has nothing in formals // they do have paramtypelist_. this can not skip ones without args // but for them at least the func decls are valid - if (GetParamSize() != formalDefVec.size() || GetAttr(FUNCATTR_optimized)) { + if ((module->IsJavaModule() && GetParamSize() != formalDefVec.size()) || + GetAttr(FUNCATTR_optimized)) { return; } diff --git a/src/mapleall/maple_ir/src/mir_nodes.cpp b/src/mapleall/maple_ir/src/mir_nodes.cpp index bfffaa1fa2..c02fe724b3 100644 --- a/src/mapleall/maple_ir/src/mir_nodes.cpp +++ b/src/mapleall/maple_ir/src/mir_nodes.cpp @@ -166,6 +166,9 @@ void BlockNode::AddStatement(StmtNode *stmt) { } void BlockNode::AppendStatementsFromBlock(BlockNode &blk) { + if (blk.GetStmtNodes().empty()) { + return; + } stmtNodeList.splice(stmtNodeList.end(), blk.GetStmtNodes()); } -- Gitee From 5fb235b9d66ff44108df47a23498c01b9213d9b4 Mon Sep 17 00:00:00 2001 From: Fred Chow Date: Tue, 30 Mar 2021 22:31:43 -0700 Subject: [PATCH 2/2] Fix bug in binary import of union type --- src/mapleall/maple_ir/src/bin_mpl_import.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mapleall/maple_ir/src/bin_mpl_import.cpp b/src/mapleall/maple_ir/src/bin_mpl_import.cpp index 9a3645c0c8..73077f9b06 100644 --- a/src/mapleall/maple_ir/src/bin_mpl_import.cpp +++ b/src/mapleall/maple_ir/src/bin_mpl_import.cpp @@ -509,7 +509,7 @@ void BinaryMplImport::CompleteAggInfo(TyIdx tyIdx) { auto *classType = static_cast(type); ImportStructTypeData(*classType); ImportClassTypeData(*classType); - } else if (type->GetKind() == kTypeStruct) { + } else if (type->GetKind() == kTypeStruct || type->GetKind() == kTypeUnion) { auto *structType = static_cast(type); ImportStructTypeData(*structType); } else { @@ -741,7 +741,7 @@ MIRType &BinaryMplImport::InsertInTypeTables(MIRType &type) { (!IsIncomplete(*prevType) && !IsIncomplete(type)) || (!IsIncomplete(*prevType) && IsIncomplete(type)))) { resultTypePtr = prevType->CopyMIRTypeNode(); - if (resultTypePtr->GetKind() == kTypeStruct || resultTypePtr->GetKind() == kTypeStructIncomplete) { + if (resultTypePtr->GetKind() == kTypeStruct || resultTypePtr->GetKind() == kTypeUnion || resultTypePtr->GetKind() == kTypeStructIncomplete) { tmpStruct.push_back(static_cast(resultTypePtr)); } else if (resultTypePtr->GetKind() == kTypeClass || resultTypePtr->GetKind() == kTypeClassIncomplete) { tmpClass.push_back(static_cast(resultTypePtr)); -- Gitee