mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
patch 9.0.1902: Vim9: Coverity complains about dead code
Problem: Vim9: Coverity complains about dead code Solution: Copy only object methods from the super class to a subclass when extending a class. Fix Coverity warning. closes: #13103 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
This commit is contained in:
parent
ad29f6af0a
commit
e2deb7e598
@ -699,6 +699,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1902,
|
||||||
/**/
|
/**/
|
||||||
1901,
|
1901,
|
||||||
/**/
|
/**/
|
||||||
|
@ -1049,9 +1049,9 @@ add_default_constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Add the class functions and object methods to the new class "cl".
|
* Add the class methods and object methods to the new class "cl".
|
||||||
* When extending a class, add the functions and methods from the parent class
|
* When extending a class "extends_cl", add the instance methods from the
|
||||||
* also.
|
* parent class also.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
add_classfuncs_objmethods(
|
add_classfuncs_objmethods(
|
||||||
@ -1095,26 +1095,19 @@ add_classfuncs_objmethods(
|
|||||||
else
|
else
|
||||||
cl->class_obj_method_count_child = gap->ga_len;
|
cl->class_obj_method_count_child = gap->ga_len;
|
||||||
|
|
||||||
int skipped = 0;
|
if (loop == 2)
|
||||||
for (int i = 0; i < parent_count; ++i)
|
|
||||||
{
|
{
|
||||||
// Copy functions from the parent. Can't use the same
|
// Copy instance methods from the parent.
|
||||||
// function, because "uf_class" is different and compilation
|
|
||||||
// will have a different result.
|
for (int i = 0; i < parent_count; ++i)
|
||||||
// Put them after the functions in the current class, object
|
|
||||||
// methods may be overruled, then "super.Method()" is used to
|
|
||||||
// find a method from the parent.
|
|
||||||
// Skip "new" functions. TODO: not all of them.
|
|
||||||
if (loop == 1 && STRNCMP(
|
|
||||||
extends_cl->class_class_functions[i]->uf_name,
|
|
||||||
"new", 3) == 0)
|
|
||||||
++skipped;
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
ufunc_T *pf = (loop == 1
|
// Can't use the same parent function, because "uf_class" is
|
||||||
? extends_cl->class_class_functions
|
// different and compilation will have a different result.
|
||||||
: extends_cl->class_obj_methods)[i];
|
// Put them after the functions in the current class, object
|
||||||
(*fup)[gap->ga_len + i - skipped] = copy_function(pf);
|
// methods may be overruled, then "super.Method()" is used to
|
||||||
|
// find a method from the parent.
|
||||||
|
ufunc_T *pf = (extends_cl->class_obj_methods)[i];
|
||||||
|
(*fup)[gap->ga_len + i] = copy_function(pf);
|
||||||
|
|
||||||
// If the child class overrides a function from the parent
|
// If the child class overrides a function from the parent
|
||||||
// the signature must be equal.
|
// the signature must be equal.
|
||||||
@ -1135,8 +1128,6 @@ add_classfuncs_objmethods(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*fcount -= skipped;
|
|
||||||
|
|
||||||
// Set the class pointer on all the functions and object methods.
|
// Set the class pointer on all the functions and object methods.
|
||||||
for (int i = 0; i < *fcount; ++i)
|
for (int i = 0; i < *fcount; ++i)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user