Skip to content

Commit

Permalink
fix some warnings from static code analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
hkiel authored and OpenModelica-Hudson committed Oct 7, 2017
1 parent fe07041 commit 0e625e9
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 23 deletions.
4 changes: 2 additions & 2 deletions Compiler/BackEnd/BackendDAECreate.mo
Expand Up @@ -256,8 +256,8 @@ protected function chooseExternalAlias "Chooses a alias variable depending on wh
author: waurich TUD 2016-10"
input BackendDAE.Var var1;
input BackendDAE.Var var2;
output BackendDAE.Var simVar = var1;
output BackendDAE.Var aliasVar = var2;
output BackendDAE.Var simVar;
output BackendDAE.Var aliasVar;
algorithm
if BackendVariable.varHasBindExp(var1) and not BackendVariable.varHasBindExp(var2)then
simVar := var1;
Expand Down
2 changes: 1 addition & 1 deletion Compiler/BackEnd/BackendEquation.mo
Expand Up @@ -238,7 +238,7 @@ public function traverseEquationArray_WithStop<T> "author: lochel
output T outExtraArg;
end FuncWithStop;
protected
Boolean continue_ = true;
Boolean continue_;
BackendDAE.Equation eqn;
algorithm
for i in 1:ExpandableArray.getLastUsedIndex(equationArray) loop
Expand Down
2 changes: 1 addition & 1 deletion Compiler/BackEnd/BackendInline.mo
Expand Up @@ -224,7 +224,7 @@ algorithm
then
(BackendDAE.RESIDUAL_EQUATION(e_1,source,attr),true);

case(BackendDAE.ALGORITHM(size,alg as DAE.ALGORITHM_STMTS(statementLst=stmts),source,crefExpand,attr),_)
case(BackendDAE.ALGORITHM(size,DAE.ALGORITHM_STMTS(statementLst=stmts),source,crefExpand,attr),_)
equation
(stmts1,true) = Inline.inlineStatements(stmts,fns,{},false);
alg = DAE.ALGORITHM_STMTS(stmts1);
Expand Down
8 changes: 3 additions & 5 deletions Compiler/BackEnd/BackendVarTransform.mo
Expand Up @@ -130,13 +130,11 @@ the extendhashtable is not updated"
end FuncTypeExp_ExpToBoolean;
protected
DAE.Exp dst;
HashTable2.HashTable ht,ht_1,eht,eht_1;
HashTable2.HashTable ht,ht_1;
HashTable3.HashTable invHt,invHt_1;
list<DAE.Ident> iv;
String s;
Option<HashTable2.HashTable> derConst;
algorithm
REPLACEMENTS(ht,invHt,eht,iv,derConst) := repl;
REPLACEMENTS(ht,invHt,_,_,_) := repl;
if not BaseHashTable.hasKey(inSrc,ht) then
return;
end if;
Expand Down Expand Up @@ -1729,7 +1727,7 @@ algorithm
then
(BackendDAE.EQUATION(e1_2,e2_2,source,eqAttr)::inAcc,true);

case (BackendDAE.ALGORITHM(size=size, alg=alg as DAE.ALGORITHM_STMTS(statementLst=stmts), source=source, expand=crefExpand, attr=eqAttr), repl, _, _, _)
case (BackendDAE.ALGORITHM(size=size, alg=DAE.ALGORITHM_STMTS(statementLst=stmts), source=source, expand=crefExpand, attr=eqAttr), repl, _, _, _)
equation
(crefs,_) = Expression.extractUniqueCrefsFromStatmentS(stmts);
// if there is no need for expanding the original equation, the replaced one shouldn't either
Expand Down
15 changes: 7 additions & 8 deletions Compiler/BackEnd/FindZeroCrossings.mo
Expand Up @@ -91,7 +91,7 @@ algorithm
(systs, index, ht) := List.mapFold2(systs, encapsulateWhenConditions_EqSystem, 1, ht);

// shared removedEqns
((removedEqs, vars, eqns, index, ht)) :=
((removedEqs, vars, eqns, index, _)) :=
BackendEquation.traverseEquationArray(shared.removedEqs, encapsulateWhenConditions_Equation,
(BackendEquation.emptyEqnsSized(BackendEquation.getNumberOfEquations(shared.removedEqs)), DoubleEndedList.fromList({}), DoubleEndedList.fromList({}), index, ht) );
shared.removedEqs := removedEqs;
Expand Down Expand Up @@ -408,7 +408,6 @@ algorithm
DoubleEndedList.push_list_front(vars, vars1);

(elseWhenList, preStmts2, index) = encapsulateWhenConditions_Algorithms({elseWhen}, vars, index);
elseWhen = List.last(elseWhenList);

if listEmpty(elseWhenList) then
(stmts, preStmts, index) = encapsulateWhenConditions_Algorithms(rest, vars, inIndex);
Expand All @@ -429,7 +428,7 @@ algorithm
stmts_ = stmt2::listAppend(stmts_, stmts);
else
(stmts, preStmts, index) = encapsulateWhenConditions_Algorithms(rest, vars, inIndex);
stmts = listAppend(preStmts, stmts);
stmts_ = listAppend(preStmts, stmts);
end if;
end if;
then (stmts_, preStmts, index);
Expand Down Expand Up @@ -562,9 +561,8 @@ protected function findZeroCrossings1 "
protected
BackendDAE.Variables vars;
BackendDAE.EquationArray eqns;
BackendDAE.BaseClockPartitionKind partitionKind;
algorithm
BackendDAE.EQSYSTEM(orderedVars=vars, orderedEqs=eqns, partitionKind=partitionKind) := inSyst;
BackendDAE.EQSYSTEM(orderedVars=vars, orderedEqs=eqns) := inSyst;
(outSyst, outShared) := match BackendDAEUtil.getSubClock(inSyst, inShared)
local
BackendDAE.Variables globalKnownVars;
Expand Down Expand Up @@ -1069,7 +1067,7 @@ algorithm
DAE.Exp e, e1, e2, e_1, e_2, eres, iterator, range, range2;
list<DAE.Exp> inExpLst, explst;
BackendDAE.Variables vars, globalKnownVars;
BackendDAE.ZeroCrossingSet zeroCrossings, zeroCrossingsDummy, samples;
BackendDAE.ZeroCrossingSet zeroCrossings, samples;
DoubleEndedList<BackendDAE.ZeroCrossing> relations;
list<BackendDAE.ZeroCrossing> zcLstNew, zc_lst;
DAE.Operator op;
Expand All @@ -1084,6 +1082,7 @@ algorithm
list<DAE.Exp> le;
tuple<Integer, BackendDAE.Variables, BackendDAE.Variables> tp1;
ForArgType tpl;
tuple<BackendDAE.ZeroCrossingSet, DoubleEndedList<BackendDAE.ZeroCrossing>, BackendDAE.ZeroCrossingSet, Integer> tp2;

case (DAE.CALL(path=Absyn.IDENT(name="noEvent")), _)
then (inExp, false, inTpl);
Expand Down Expand Up @@ -1148,8 +1147,8 @@ algorithm
BackendDump.debugExpStr(inExp, "\n");
end if;
oldNumRelations := DoubleEndedList.length(relations);
(e_1, (_, inExpLst, range, (zeroCrossingsDummy, relations, samples, numMathFunctions), tp1)) := Expression.traverseExpTopDown(e1, collectZCAlgsFor, (iterator, inExpLst, range, (ZeroCrossings.new(), relations, samples, numMathFunctions), tp1));
(e_2, (_, inExpLst, range, (zeroCrossingsDummy, relations, samples, numMathFunctions), tp1 as (alg_indx, _, _))) := Expression.traverseExpTopDown(e2, collectZCAlgsFor, (iterator, inExpLst, range, (zeroCrossingsDummy, relations, samples, numMathFunctions), tp1));
(e_1, (_, inExpLst, range, tp2, tp1)) := Expression.traverseExpTopDown(e1, collectZCAlgsFor, (iterator, inExpLst, range, (ZeroCrossings.new(), relations, samples, numMathFunctions), tp1));
(e_2, (_, inExpLst, range, (_, relations, samples, numMathFunctions), tp1 as (alg_indx, _, _))) := Expression.traverseExpTopDown(e2, collectZCAlgsFor, (iterator, inExpLst, range, tp2, tp1));
if intGt(DoubleEndedList.length(relations), oldNumRelations) then
e_1 := DAE.LBINARY(e_1, op, e_2);
if Expression.expContains(e1, iterator) or Expression.expContains(e2, iterator) then
Expand Down
6 changes: 2 additions & 4 deletions Compiler/BackEnd/RemoveSimpleEquations.mo
Expand Up @@ -4668,7 +4668,7 @@ algorithm
res = BackendEquation.getEquationRHS(eq);
(_, (cr_lst,_,count,paramCount,true)) = Expression.traverseExpTopDown(res, findCrefs, ({},vars,0,0,true));
res = BackendEquation.getEquationLHS(eq);
(_, (cr_lst,_,count,paramCount,true)) = Expression.traverseExpTopDown(res, findCrefs, (cr_lst,vars,count,paramCount,true));
(_, (cr_lst,_,count,_,true)) = Expression.traverseExpTopDown(res, findCrefs, (cr_lst,vars,count,paramCount,true));
keepEquation = true;
if (count == 1) then
if Flags.isSet(Flags.DEBUG_ALIAS) then
Expand Down Expand Up @@ -4987,11 +4987,9 @@ start module for detecting simple equation/expressions
"
input DAE.Exp inExp;
output Boolean outIsSimple;
protected
DAE.Exp outExp;
algorithm
//print("Traverse " + ExpressionDump.printExpStr(inExp) + "\n");
(outExp,outIsSimple) := Expression.traverseExpTopDown(inExp, checkOperator, true);
(_,outIsSimple) := Expression.traverseExpTopDown(inExp, checkOperator, true);
//print("Simple: " + boolString(outIsSimple) + "\n");
end isSimple;

Expand Down
4 changes: 2 additions & 2 deletions Compiler/FrontEnd/InstUtil.mo
Expand Up @@ -8676,8 +8676,8 @@ protected function getDomNFields
input DomainFieldsLst inDomFieldLst;
input Absyn.ComponentRef inDomainCr;
input SCode.SourceInfo info;
output Integer outN;
output List<Absyn.ComponentRef> outFieldLst;
output Integer outN = 0;
output List<Absyn.ComponentRef> outFieldLst = {};
algorithm
try
(outN,outFieldLst) := List.findSome1(inDomFieldLst,domNFieldsFindFun,inDomainCr);
Expand Down

0 comments on commit 0e625e9

Please sign in to comment.