Fix LGTM warnings in script_opt/CPP code

i.e. shadowed variables and "missing return values" (scare quotes)
This commit is contained in:
Jon Siwek 2021-05-06 12:06:57 -07:00
parent ac257e4a86
commit 1b825c51de
3 changed files with 18 additions and 11 deletions

View file

@ -219,12 +219,12 @@ string CPPCompile::BindArgs(const FuncTypePtr& ft, const IDPList* lambda_ids)
for ( auto i = 0; i < n; ++i )
{
auto arg_i = string("f->GetElement(") + Fmt(i) + ")";
const auto& ft = params->GetFieldType(i);
const auto& pt = params->GetFieldType(i);
if ( IsNativeType(ft) )
res += arg_i + NativeAccessor(ft);
if ( IsNativeType(pt) )
res += arg_i + NativeAccessor(pt);
else
res += GenericValPtrToGT(arg_i, ft, GEN_VAL_PTR);
res += GenericValPtrToGT(arg_i, pt, GEN_VAL_PTR);
res += ", ";
}

View file

@ -620,11 +620,11 @@ string CPPCompile::GenRecordConstructorExpr(const Expr* e)
for ( auto i = 0; i < n; ++i )
{
const auto& e = exprs[i];
const auto& expr = exprs[i];
ASSERT(e->Tag() == EXPR_FIELD_ASSIGN);
ASSERT(expr->Tag() == EXPR_FIELD_ASSIGN);
vals += GenExpr(e->GetOp1(), GEN_VAL_PTR);
vals += GenExpr(expr->GetOp1(), GEN_VAL_PTR);
if ( i < n - 1 )
vals += ", ";
@ -668,12 +668,12 @@ string CPPCompile::GenTableConstructorExpr(const Expr* e)
for ( auto i = 0; i < n; ++i )
{
const auto& e = exprs[i];
const auto& expr = exprs[i];
ASSERT(e->Tag() == EXPR_ASSIGN);
ASSERT(expr->Tag() == EXPR_ASSIGN);
auto index = e->GetOp1();
auto v = e->GetOp2();
auto index = expr->GetOp1();
auto v = expr->GetOp2();
if ( index->Tag() == EXPR_LIST )
// Multiple indices.

View file

@ -44,6 +44,7 @@ bool CPPCompile::IsNativeType(const TypePtr& t) const
default:
reporter->InternalError("bad type in CPPCompile::IsNativeType");
return false;
}
}
@ -287,6 +288,7 @@ const char* CPPCompile::TypeTagName(TypeTag tag) const
default:
reporter->InternalError("bad type in CPPCompile::TypeTagName");
return nullptr;
}
}
@ -318,6 +320,7 @@ const char* CPPCompile::TypeName(const TypePtr& t)
default:
reporter->InternalError("bad type in CPPCompile::TypeName");
return nullptr;
}
}
@ -353,6 +356,7 @@ const char* CPPCompile::FullTypeName(const TypePtr& t)
default:
reporter->InternalError("bad type in CPPCompile::FullTypeName");
return nullptr;
}
}
@ -365,6 +369,7 @@ const char* CPPCompile::TypeType(const TypePtr& t)
default:
reporter->InternalError("bad type in CPPCompile::TypeType");
return nullptr;
}
}
@ -542,6 +547,7 @@ const char* CPPCompile::NativeAccessor(const TypePtr& t)
default:
reporter->InternalError("bad type in CPPCompile::NativeAccessor");
return nullptr;
}
}
@ -572,6 +578,7 @@ const char* CPPCompile::IntrusiveVal(const TypePtr& t)
default:
reporter->InternalError("bad type in CPPCompile::IntrusiveVal");
return nullptr;
}
}