From cfd6f839342927a2d9b41a73a74a94a782edbfd7 Mon Sep 17 00:00:00 2001 From: chrchr Date: Mon, 24 Jul 2023 18:29:15 +0200 Subject: [PATCH] Code duplication, consistency --- lib/valueflow.cpp | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index a6ea2761aae..672c0129d55 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -1093,29 +1093,15 @@ static void setTokenValueCast(Token *parent, const ValueType &valueType, const V static nonneg int getSizeOfType(const Token *typeTok, const Settings *settings) { const ValueType &valueType = ValueType::parseDecl(typeTok, *settings, true); // TODO: set isCpp - if (valueType.pointer > 0) - return settings->platform.sizeof_pointer; - if (valueType.type == ValueType::Type::BOOL || valueType.type == ValueType::Type::CHAR) - return 1; - if (valueType.type == ValueType::Type::SHORT) - return settings->platform.sizeof_short; - if (valueType.type == ValueType::Type::INT) - return settings->platform.sizeof_int; - if (valueType.type == ValueType::Type::LONG) - return settings->platform.sizeof_long; - if (valueType.type == ValueType::Type::LONGLONG) - return settings->platform.sizeof_long_long; - if (valueType.type == ValueType::Type::WCHAR_T) - return settings->platform.sizeof_wchar_t; - - return 0; + + return ValueFlow::getSizeOf(valueType, settings); } size_t ValueFlow::getSizeOf(const ValueType &vt, const Settings *settings) { if (vt.pointer) return settings->platform.sizeof_pointer; - if (vt.type == ValueType::Type::CHAR) + if (vt.type == ValueType::Type::BOOL || vt.type == ValueType::Type::CHAR) return 1; if (vt.type == ValueType::Type::SHORT) return settings->platform.sizeof_short;