WIP: MSVC: lower C4457 warning level from 4 to 3 #105608

Draft
Germano Cavalcante wants to merge 1 commits from mano-wii/blender:w34457 into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
13 changed files with 87 additions and 86 deletions

View File

@ -1610,6 +1610,7 @@ elseif(CMAKE_C_COMPILER_ID MATCHES "MSVC")
"/w34100" # 'identifier' : unreferenced formal parameter
"/w34115" # 'type' : named type definition in parentheses
"/w34189" # local variable is initialized but not referenced
"/w34457" # declaration of 'identifier' hides function parameter
# see https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/c5038?view=vs-2017
"/w35038" # order of initialization in c++ constructors
# disable:

View File

@ -704,6 +704,7 @@ macro(remove_strict_flags)
if(MSVC)
remove_cc_flag(/w34100) # Restore warn C4100 (unreferenced formal parameter) back to w4
remove_cc_flag(/w34189) # Restore warn C4189 (unused variable) back to w4
remove_cc_flag(/w34457) # Restore warn C4457 (declaration hides parameter) back to w4
endif()
endmacro()

View File

@ -118,7 +118,7 @@ GHOST_WindowWin32::GHOST_WindowWin32(GHOST_SystemWin32 *system,
m_hDC = ::GetDC(m_hWnd);
if (!setDrawingContextType(type)) {
const char *title = "Blender - Unsupported Graphics Card Configuration";
const char *message_title = "Blender - Unsupported Graphics Card Configuration";
const char *text =
"A graphics card and driver with support for OpenGL 3.3 or higher is "
"required.\n\nInstalling the latest driver for your graphics card might resolve the "
@ -129,7 +129,7 @@ GHOST_WindowWin32::GHOST_WindowWin32(GHOST_SystemWin32 *system,
"required.\n\nPlugging all monitors into your primary graphics card might resolve "
"this issue. Installing the latest driver for your graphics card could also help.";
}
MessageBox(m_hWnd, text, title, MB_OK | MB_ICONERROR);
MessageBox(m_hWnd, text, message_title, MB_OK | MB_ICONERROR);
::ReleaseDC(m_hWnd, m_hDC);
::DestroyWindow(m_hWnd);
m_hWnd = NULL;

View File

@ -43,9 +43,9 @@ void copy_point_data(const OffsetIndices<int> src_points_by_curve,
GMutableSpan dst)
{
threading::parallel_for(curve_ranges.index_range(), 512, [&](IndexRange range) {
for (const IndexRange range : curve_ranges.slice(range)) {
const IndexRange src_points = src_points_by_curve[range];
const IndexRange dst_points = dst_points_by_curve[range];
for (const IndexRange range_points : curve_ranges.slice(range)) {
const IndexRange src_points = src_points_by_curve[range_points];
const IndexRange dst_points = dst_points_by_curve[range_points];
/* The arrays might be large, so a threaded copy might make sense here too. */
dst.slice(dst_points).copy_from(src.slice(src_points));
}
@ -91,8 +91,8 @@ void fill_points(const OffsetIndices<int> points_by_curve,
BLI_assert(*value.type() == dst.type());
const CPPType &type = dst.type();
threading::parallel_for(curve_ranges.index_range(), 512, [&](IndexRange range) {
for (const IndexRange range : curve_ranges.slice(range)) {
const IndexRange points = points_by_curve[range];
for (const IndexRange range_points : curve_ranges.slice(range)) {
const IndexRange points = points_by_curve[range_points];
type.fill_assign_n(value.get(), dst.slice(points).data(), points.size());
}
});

View File

@ -441,9 +441,9 @@ bool try_capture_field_on_geometry(GeometryComponent &component,
evaluator.set_selection(selection);
evaluator.evaluate();
const IndexMask selection = evaluator.get_evaluated_selection_as_mask();
const IndexMask selection_mask = evaluator.get_evaluated_selection_as_mask();
array_utils::copy(evaluator.get_evaluated(0), selection, dst_attribute.span);
array_utils::copy(evaluator.get_evaluated(0), selection_mask, dst_attribute.span);
dst_attribute.finish();
return true;

View File

@ -103,8 +103,7 @@ static void geometry_set_collect_recursive_collection(const Collection &collecti
}
LISTBASE_FOREACH (const CollectionChild *, collection_child, &collection.children) {
BLI_assert(collection_child->collection != nullptr);
const Collection &collection = *collection_child->collection;
geometry_set_collect_recursive_collection(collection, transform, r_sets);
geometry_set_collect_recursive_collection(*collection_child->collection, transform, r_sets);
}
}
@ -137,8 +136,7 @@ static void geometry_set_collect_recursive(const GeometrySet &geometry_set,
break;
}
case InstanceReference::Type::GeometrySet: {
const GeometrySet &geometry_set = reference.geometry_set();
geometry_set_collect_recursive(geometry_set, instance_transform, r_sets);
geometry_set_collect_recursive(reference.geometry_set(), instance_transform, r_sets);
break;
}
case InstanceReference::Type::None: {

View File

@ -103,7 +103,7 @@ bool BKE_image_save_options_init(ImageSaveOptions *opts,
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, &lock);
if (ibuf) {
Scene *scene = opts->scene;
BLI_assert(scene == opts->scene);
bool is_depth_set = false;
const char *ima_colorspace = ima->colorspace_settings.name;

View File

@ -566,7 +566,7 @@ static void outliner_do_libdata_operation_selection_set(bContext *C,
LISTBASE_FOREACH_MUTABLE (TreeElement *, element, &subtree) {
/* Get needed data out in case element gets freed. */
TreeStoreElem *tselem = TREESTORE(element);
const ListBase subtree = element->subtree;
const ListBase element_subtree = element->subtree;
bool is_selected = tselem->flag & TSE_SELECTED;
if ((is_selected && do_selected) || (has_parent_selected && do_content)) {
@ -583,7 +583,7 @@ static void outliner_do_libdata_operation_selection_set(bContext *C,
reports,
scene,
space_outliner,
subtree,
element_subtree,
is_selected || has_parent_selected,
operation_fn,
selection_set,

View File

@ -23,12 +23,12 @@ void all(const ListBase &subtree, const VisitorFn visitor)
{
LISTBASE_FOREACH_MUTABLE (TreeElement *, element, &subtree) {
/* Get needed data out in case element gets freed. */
const ListBase subtree = element->subtree;
const ListBase element_subtree = element->subtree;
visitor(element);
/* Don't access element from now on, it may be freed. */
all(subtree, visitor);
all(element_subtree, visitor);
}
}
@ -44,14 +44,14 @@ void all_open(const SpaceOutliner &space_outliner,
LISTBASE_FOREACH_MUTABLE (TreeElement *, element, &subtree) {
/* Get needed data out in case element gets freed. */
const TreeStoreElem *tselem = TREESTORE(element);
const ListBase subtree = element->subtree;
const ListBase element_subtree = element->subtree;
visitor(element);
/* Don't access element from now on, it may be freed. Note that the open/collapsed state may
* also have been changed in the visitor callback. */
if (TSELEM_OPEN(tselem, &space_outliner)) {
all_open(space_outliner, subtree, visitor);
all_open(space_outliner, element_subtree, visitor);
}
}
}

View File

@ -58,12 +58,13 @@ static void viewer_path_for_geometry_node(const SpaceNode &snode,
Vector<const bNodeTreePath *, 16> tree_path = snode.treepath;
for (const int i : tree_path.index_range().drop_back(1)) {
/* The tree path contains the name of the node but not its ID. */
const bNode *node = nodeFindNodebyName(tree_path[i]->nodetree, tree_path[i + 1]->node_name);
const bNode *tree_path_node = nodeFindNodebyName(tree_path[i]->nodetree,
tree_path[i + 1]->node_name);
/* The name in the tree path should match a group node in the tree. */
BLI_assert(node != nullptr);
BLI_assert(tree_path_node != nullptr);
NodeViewerPathElem *node_elem = BKE_viewer_path_elem_new_node();
node_elem->node_id = node->identifier;
node_elem->node_name = BLI_strdup(node->name);
node_elem->node_id = tree_path_node->identifier;
node_elem->node_name = BLI_strdup(tree_path_node->name);
BLI_addtail(&r_dst.path, node_elem);
}

View File

@ -67,7 +67,7 @@ int Operators::select(UnaryPredicate1D &pred)
return 0;
}
int Operators::chain(ViewEdgeInternal::ViewEdgeIterator &it,
int Operators::chain(ViewEdgeInternal::ViewEdgeIterator &it_edges,
UnaryPredicate1D &pred,
UnaryFunction1D_void &modifier)
{
@ -90,22 +90,22 @@ int Operators::chain(ViewEdgeInternal::ViewEdgeIterator &it,
}
edge = dynamic_cast<ViewEdge *>(*it_edge);
it.setBegin(edge);
it.setCurrentEdge(edge);
it_edges.setBegin(edge);
it_edges.setCurrentEdge(edge);
Chain *new_chain = new Chain(id);
++id;
while (true) {
new_chain->push_viewedge_back(*it, it.getOrientation());
if (modifier(**it) < 0) {
new_chain->push_viewedge_back(*it_edges, it_edges.getOrientation());
if (modifier(**it_edges) < 0) {
delete new_chain;
goto error;
}
++it;
if (it.isEnd()) {
++it_edges;
if (it_edges.isEnd()) {
break;
}
if (pred(**it) < 0) {
if (pred(**it_edges) < 0) {
delete new_chain;
goto error;
}
@ -133,7 +133,7 @@ error:
return -1;
}
int Operators::chain(ViewEdgeInternal::ViewEdgeIterator &it, UnaryPredicate1D &pred)
int Operators::chain(ViewEdgeInternal::ViewEdgeIterator &it_edges, UnaryPredicate1D &pred)
{
if (_current_view_edges_set.empty()) {
return 0;
@ -162,26 +162,26 @@ int Operators::chain(ViewEdgeInternal::ViewEdgeIterator &it, UnaryPredicate1D &p
}
edge = dynamic_cast<ViewEdge *>(*it_edge);
it.setBegin(edge);
it.setCurrentEdge(edge);
it_edges.setBegin(edge);
it_edges.setCurrentEdge(edge);
Chain *new_chain = new Chain(id);
++id;
while (true) {
new_chain->push_viewedge_back(*it, it.getOrientation());
ts(**it);
++it;
if (it.isEnd()) {
new_chain->push_viewedge_back(*it_edges, it_edges.getOrientation());
ts(**it_edges);
++it_edges;
if (it_edges.isEnd()) {
break;
}
if (pred(**it) < 0) {
if (pred(**it_edges) < 0) {
delete new_chain;
goto error;
}
if (pred.result) {
break;
}
if (pred_ts(**it) < 0) {
if (pred_ts(**it_edges) < 0) {
delete new_chain;
goto error;
}
@ -314,7 +314,7 @@ void Operators::bidirectionalChain(ViewEdgeIterator &it, UnaryPredicate1D &pred)
}
#endif
int Operators::bidirectionalChain(ChainingIterator &it, UnaryPredicate1D &pred)
int Operators::bidirectionalChain(ChainingIterator &it_edges, UnaryPredicate1D &pred)
{
if (_current_view_edges_set.empty()) {
return 0;
@ -344,10 +344,10 @@ int Operators::bidirectionalChain(ChainingIterator &it, UnaryPredicate1D &pred)
edge = dynamic_cast<ViewEdge *>(*it_edge);
// re-init iterator
it.setBegin(edge);
it.setCurrentEdge(edge);
it.setOrientation(true);
if (it.init() < 0) {
it_edges.setBegin(edge);
it_edges.setCurrentEdge(edge);
it_edges.setOrientation(true);
if (it_edges.init() < 0) {
goto error;
}
@ -358,16 +358,16 @@ int Operators::bidirectionalChain(ChainingIterator &it, UnaryPredicate1D &pred)
--it_back;
#endif
while (true) {
new_chain->push_viewedge_back(*it, it.getOrientation());
ts(**it);
if (it.increment() < 0) {
new_chain->push_viewedge_back(*it_edges, it_edges.getOrientation());
ts(**it_edges);
if (it_edges.increment() < 0) {
delete new_chain;
goto error;
}
if (it.isEnd()) {
if (it_edges.isEnd()) {
break;
}
if (pred(**it) < 0) {
if (pred(**it_edges) < 0) {
delete new_chain;
goto error;
}
@ -375,24 +375,24 @@ int Operators::bidirectionalChain(ChainingIterator &it, UnaryPredicate1D &pred)
break;
}
}
it.setBegin(edge);
it.setCurrentEdge(edge);
it.setOrientation(true);
if (it.decrement() < 0) {
it_edges.setBegin(edge);
it_edges.setCurrentEdge(edge);
it_edges.setOrientation(true);
if (it_edges.decrement() < 0) {
delete new_chain;
goto error;
}
while (!it.isEnd()) {
if (pred(**it) < 0) {
while (!it_edges.isEnd()) {
if (pred(**it_edges) < 0) {
delete new_chain;
goto error;
}
if (pred.result) {
break;
}
new_chain->push_viewedge_front(*it, it.getOrientation());
ts(**it);
if (it.decrement() < 0) {
new_chain->push_viewedge_front(*it_edges, it_edges.getOrientation());
ts(**it_edges);
if (it_edges.decrement() < 0) {
delete new_chain;
goto error;
}
@ -417,7 +417,7 @@ error:
return -1;
}
int Operators::bidirectionalChain(ChainingIterator &it)
int Operators::bidirectionalChain(ChainingIterator &it_edges)
{
if (_current_view_edges_set.empty()) {
return 0;
@ -441,10 +441,10 @@ int Operators::bidirectionalChain(ChainingIterator &it)
edge = dynamic_cast<ViewEdge *>(*it_edge);
// re-init iterator
it.setBegin(edge);
it.setCurrentEdge(edge);
it.setOrientation(true);
if (it.init() < 0) {
it_edges.setBegin(edge);
it_edges.setCurrentEdge(edge);
it_edges.setOrientation(true);
if (it_edges.init() < 0) {
goto error;
}
@ -455,24 +455,24 @@ int Operators::bidirectionalChain(ChainingIterator &it)
--it_back;
#endif
do {
new_chain->push_viewedge_back(*it, it.getOrientation());
ts(**it);
if (it.increment() < 0) { // FIXME
new_chain->push_viewedge_back(*it_edges, it_edges.getOrientation());
ts(**it_edges);
if (it_edges.increment() < 0) { // FIXME
delete new_chain;
goto error;
}
} while (!it.isEnd());
it.setBegin(edge);
it.setCurrentEdge(edge);
it.setOrientation(true);
if (it.decrement() < 0) { // FIXME
} while (!it_edges.isEnd());
it_edges.setBegin(edge);
it_edges.setCurrentEdge(edge);
it_edges.setOrientation(true);
if (it_edges.decrement() < 0) { // FIXME
delete new_chain;
goto error;
}
while (!it.isEnd()) {
new_chain->push_viewedge_front(*it, it.getOrientation());
ts(**it);
if (it.decrement() < 0) { // FIXME
while (!it_edges.isEnd()) {
new_chain->push_viewedge_front(*it_edges, it_edges.getOrientation());
ts(**it_edges);
if (it_edges.decrement() < 0) { // FIXME
delete new_chain;
goto error;
}

View File

@ -62,7 +62,7 @@ class Operators {
* processed ViewEdge state (the timestamp incrementation is a typical illustration of
* such a modifier)
*/
static int chain(ViewEdgeInternal::ViewEdgeIterator &it,
static int chain(ViewEdgeInternal::ViewEdgeIterator &it_edges,
UnaryPredicate1D &pred,
UnaryFunction1D_void &modifier);
@ -79,7 +79,7 @@ class Operators {
* \param pred:
* The predicate on the ViewEdge that expresses the stopping condition.
*/
static int chain(ViewEdgeInternal::ViewEdgeIterator &it, UnaryPredicate1D &pred);
static int chain(ViewEdgeInternal::ViewEdgeIterator &it_edges, UnaryPredicate1D &pred);
/** Builds a set of chains from the current set of ViewEdges.
* Each ViewEdge of the current list potentially starts a new chain. The chaining operator then
@ -95,7 +95,7 @@ class Operators {
* \param pred:
* The predicate on the ViewEdge that expresses the stopping condition.
*/
static int bidirectionalChain(ChainingIterator &it, UnaryPredicate1D &pred);
static int bidirectionalChain(ChainingIterator &it_edges, UnaryPredicate1D &pred);
/** The only difference with the above bidirectional chaining algorithm is that we don't need to
* pass a stopping criterion. This might be desirable when the stopping criterion is already
@ -111,7 +111,7 @@ class Operators {
* \param it:
* The ChainingIterator on the ViewEdges of the ViewMap. It contains the chaining rule.
*/
static int bidirectionalChain(ChainingIterator &it);
static int bidirectionalChain(ChainingIterator &it_edges);
/** Splits each chain of the current set of chains in a sequential way.
* The points of each chain are processed (with a specified sampling) sequentially.

View File

@ -174,14 +174,14 @@ void GeoTreeLogger::log_value(const bNode &node, const bNodeSocket &socket, cons
store_logged_value(this->allocator->construct<FieldInfoLog>(*field));
}
else {
BUFFER_FOR_CPP_TYPE_VALUE(base_type, value);
fn::evaluate_constant_field(*field, value);
log_generic_value(base_type, value);
BUFFER_FOR_CPP_TYPE_VALUE(base_type, value_ptr);
fn::evaluate_constant_field(*field, value_ptr);
log_generic_value(base_type, value_ptr);
}
}
else {
const void *value = value_or_field_type->get_value_ptr(value_or_field);
log_generic_value(base_type, value);
const void *value_ptr = value_or_field_type->get_value_ptr(value_or_field);
log_generic_value(base_type, value_ptr);
}
}
else {