From 772d4f3501c55b63b7290727f685417b81df05e4 Mon Sep 17 00:00:00 2001 From: Stephane Del Pino <stephane.delpino44@gmail.com> Date: Wed, 15 Jan 2020 14:56:46 +0100 Subject: [PATCH] Add a bunch of lcov exclusion directives This is only related to debugging helpers that cannot be reached when everything is fine. Fix issue #13 --- src/language/ASTNodeAffectationExpressionBuilder.cpp | 4 ++++ src/language/ASTNodeCFunctionExpressionBuilder.cpp | 4 ++++ src/language/ASTNodeFunctionExpressionBuilder.cpp | 2 ++ src/language/ASTNodeListAffectationExpressionBuilder.cpp | 9 ++++++++- src/language/ASTNodeNaturalConversionChecker.cpp | 5 +++-- .../node_processor/BinaryExpressionProcessor.hpp | 2 ++ 6 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/language/ASTNodeAffectationExpressionBuilder.cpp b/src/language/ASTNodeAffectationExpressionBuilder.cpp index 2b037d9ed..f0b5a93be 100644 --- a/src/language/ASTNodeAffectationExpressionBuilder.cpp +++ b/src/language/ASTNodeAffectationExpressionBuilder.cpp @@ -29,10 +29,12 @@ ASTNodeAffectationExpressionBuilder::ASTNodeAffectationExpressionBuilder(ASTNode n.m_node_processor = std::make_unique<AffectationProcessor<OperatorT, ValueT, double>>(n); break; } + // LCOV_EXCL_START default: { throw parse_error("unexpected error: undefined operand type for affectation", std::vector{n.children[1]->begin()}); } + // LCOV_EXCL_STOP } }; @@ -61,10 +63,12 @@ ASTNodeAffectationExpressionBuilder::ASTNodeAffectationExpressionBuilder(ASTNode n.m_node_processor = std::make_unique<AffectationProcessor<OperatorT, std::string, std::string>>(n); break; } + // LCOV_EXCL_START default: { throw parse_error("unexpected error: undefined operand type for string affectation", std::vector{n.children[1]->begin()}); } + // LCOV_EXCL_STOP } } else { throw parse_error("unexpected error: undefined operator type", std::vector{n.children[0]->begin()}); diff --git a/src/language/ASTNodeCFunctionExpressionBuilder.cpp b/src/language/ASTNodeCFunctionExpressionBuilder.cpp index d3491746c..6e93f998a 100644 --- a/src/language/ASTNodeCFunctionExpressionBuilder.cpp +++ b/src/language/ASTNodeCFunctionExpressionBuilder.cpp @@ -29,10 +29,12 @@ ASTNodeCFunctionExpressionBuilder::_getArgumentConverter(const ASTNodeDataType& case ASTNodeDataType::double_t: { return std::make_unique<FunctionArgumentConverter<ParameterT, double>>(argument_number); } + // LCOV_EXCL_START default: { throw parse_error("unexpected error: invalid argument type for function", std::vector{argument_node_sub_data_type.m_parent_node.begin()}); } + // LCOV_EXCL_STOP } }; @@ -50,10 +52,12 @@ ASTNodeCFunctionExpressionBuilder::_getArgumentConverter(const ASTNodeDataType& case ASTNodeDataType::double_t: { return get_function_argument_converter_for(double{}); } + // LCOV_EXCL_START default: { throw parse_error("unexpected error: undefined parameter type for function", std::vector{argument_node_sub_data_type.m_parent_node.begin()}); } + // LCOV_EXCL_STOP } }; diff --git a/src/language/ASTNodeFunctionExpressionBuilder.cpp b/src/language/ASTNodeFunctionExpressionBuilder.cpp index afea37ad5..8b3787fd5 100644 --- a/src/language/ASTNodeFunctionExpressionBuilder.cpp +++ b/src/language/ASTNodeFunctionExpressionBuilder.cpp @@ -180,7 +180,9 @@ ASTNodeFunctionExpressionBuilder::_getFunctionProcessor(const ASTNodeDataType ex if constexpr (std::is_same_v<ReturnT, std::string>) { return std::make_unique<FunctionExpressionProcessor<ReturnT, std::string>>(function_component_expression); } else { + // LCOV_EXCL_START throw parse_error("unexpected error: invalid string conversion", std::vector{node.children[1]->begin()}); + // LCOV_EXCL_STOP } } // LCOV_EXCL_START diff --git a/src/language/ASTNodeListAffectationExpressionBuilder.cpp b/src/language/ASTNodeListAffectationExpressionBuilder.cpp index b95f4777d..a0bbeb88a 100644 --- a/src/language/ASTNodeListAffectationExpressionBuilder.cpp +++ b/src/language/ASTNodeListAffectationExpressionBuilder.cpp @@ -32,10 +32,12 @@ ASTNodeListAffectationExpressionBuilder::_buildAffectationProcessor( list_affectation_processor->template add<ValueT, double>(value_node); break; } + // LCOV_EXCL_START default: { throw parse_error("unexpected error: invalid operand type for affectation", std::vector{node_sub_data_type.m_parent_node.begin()}); } + // LCOV_EXCL_STOP } }; @@ -62,10 +64,12 @@ ASTNodeListAffectationExpressionBuilder::_buildAffectationProcessor( list_affectation_processor->template add<std::string, std::string>(value_node); break; } + // LCOV_EXCL_START default: { throw parse_error("invalid operand type for string affectation", std::vector{node_sub_data_type.m_parent_node.begin()}); } + // LCOV_EXCL_STOP } } else { throw parse_error("unexpected error: undefined operator type for string affectation", @@ -98,9 +102,12 @@ ASTNodeListAffectationExpressionBuilder::_buildAffectationProcessor( add_affectation_processor_for_string_data(node_sub_data_type); break; } + // LCOV_EXCL_START default: { - throw parse_error("undefined value type for tuple affectation", std::vector{value_node.begin()}); + throw parse_error("unexpected error: undefined value type for tuple affectation", + std::vector{value_node.begin()}); } + // LCOV_EXCL_STOP } }; diff --git a/src/language/ASTNodeNaturalConversionChecker.cpp b/src/language/ASTNodeNaturalConversionChecker.cpp index d625d639b..abf672e0d 100644 --- a/src/language/ASTNodeNaturalConversionChecker.cpp +++ b/src/language/ASTNodeNaturalConversionChecker.cpp @@ -6,8 +6,9 @@ ASTNodeNaturalConversionChecker::ASTNodeNaturalConversionChecker(const ASTNode& { if (not isNaturalConversion(data_type, target_data_type)) { std::ostringstream error_message; - error_message << "invalid implicit conversion: " << dataTypeName(data_type) << " -> " - << dataTypeName(target_data_type); + error_message << "invalid implicit conversion: "; + error_message << rang::fgB::red << dataTypeName(data_type) << " -> " << dataTypeName(target_data_type) + << rang::fg::reset; throw parse_error(error_message.str(), node.begin()); } } diff --git a/src/language/node_processor/BinaryExpressionProcessor.hpp b/src/language/node_processor/BinaryExpressionProcessor.hpp index 6a54abcfc..8089ea9d2 100644 --- a/src/language/node_processor/BinaryExpressionProcessor.hpp +++ b/src/language/node_processor/BinaryExpressionProcessor.hpp @@ -208,7 +208,9 @@ class BinaryExpressionProcessor final : public INodeProcessor BinaryExpressionProcessor(ASTNode& node) : m_node{node} { if constexpr (not _is_defined) { + // LCOV_EXCL_START throw parse_error("invalid operands to binary expression", std::vector{m_node.begin()}); + // LCOV_EXCL_STOP } } }; -- GitLab