From ab5835d3592a58fe6d065e6035cd62092bee7842 Mon Sep 17 00:00:00 2001 From: Dmitry-Me Date: Sat, 14 Mar 2020 16:41:45 +0300 Subject: [PATCH] Avoid giant C4267 warning in 64-bit Visual C++ build (#2569) --- lib/symboldatabase.cpp | 9 +++++++++ lib/symboldatabase.h | 6 +----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index a1c536a2e..2f89a4dd5 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -3776,6 +3776,15 @@ AccessControl Scope::defaultAccess() const } } +void Scope::addVariable(const Token *token_, const Token *start_, const Token *end_, + AccessControl access_, const Type *type_, const Scope *scope_, const Settings* settings) +{ + // keep possible size_t -> int truncation outside emplace_back() to have a single line + // C4267 VC++ warning instead of several dozens lines + const int varIndex = varlist.size(); + varlist.emplace_back(token_, start_, end_, varIndex, access_, type_, scope_, settings); +} + // Get variable list.. void Scope::getVariableList(const Settings* settings) { diff --git a/lib/symboldatabase.h b/lib/symboldatabase.h index 485e8af5d..8fdbc20f7 100644 --- a/lib/symboldatabase.h +++ b/lib/symboldatabase.h @@ -1081,11 +1081,7 @@ public: void addVariable(const Token *token_, const Token *start_, const Token *end_, AccessControl access_, const Type *type_, - const Scope *scope_, const Settings* settings) { - varlist.emplace_back(token_, start_, end_, varlist.size(), - access_, - type_, scope_, settings); - } + const Scope *scope_, const Settings* settings); /** @brief initialize varlist */ void getVariableList(const Settings* settings);