From 488dd883cc924bb5b3ba59017f6a11410be6ab53 Mon Sep 17 00:00:00 2001 From: Bartek Kryza Date: Tue, 1 Nov 2022 23:33:47 +0100 Subject: [PATCH] Fixed test case t20003 crash on LLVM 12 --- .../visitor/translation_unit_visitor.cc | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/sequence_diagram/visitor/translation_unit_visitor.cc b/src/sequence_diagram/visitor/translation_unit_visitor.cc index a277888d..0a8e0ff1 100644 --- a/src/sequence_diagram/visitor/translation_unit_visitor.cc +++ b/src/sequence_diagram/visitor/translation_unit_visitor.cc @@ -467,9 +467,19 @@ bool translation_unit_visitor::VisitCallExpr(clang::CallExpr *expr) .substr(); m.message_name = message_name.substr(0, message_name.size() - 2); } - m.return_type = - function_call_expr->getCallReturnType(current_ast_context) - .getAsString(); + + const auto &return_type = + function_call_expr->getCallReturnType(current_ast_context); + + // + // Without this if, this crashes test case t20003 on LLVM <= 12 + // + if (!clang::dyn_cast_or_null( + function_call_expr->getCallee())) { + m.return_type = return_type.getAsString(); + } + else + m.return_type = ""; } else { return true;