Fix some clang-analyzer warnings

This commit is contained in:
Wilson Snyder 2017-11-25 15:41:49 -05:00
parent fe9f1add6f
commit 38b0e8a777
4 changed files with 15 additions and 7 deletions

View File

@ -214,7 +214,7 @@ test_regress: all_nomsg
examples: all_nomsg
for p in examples/* ; do \
$(MAKE) -C $$p VERILATOR_ROOT=`pwd` ; \
$(MAKE) -C $$p VERILATOR_ROOT=`pwd` || exit 10; \
done
info: $(INFOS)
@ -430,6 +430,14 @@ cppcheck: $(CPPCHECK_DEP)
%.cppcheck: %.cpp
$(CPPCHECK) $(CPPCHECK_FLAGS) -DVL_DEBUG=1 -DVL_CPPCHECK=1 $(CPPCHECK_INC) $<
analyzer-src:
-rm -rf src/obj_dbg
scan-build $(MAKE) -k verilator_coverage_bin_dbg verilator_bin_dbg
analyzer-include:
-rm -rf examples/*/obj*
scan-build $(MAKE) -k examples
ftp: info
install-msg:

View File

@ -621,7 +621,7 @@ class GaterVisitor : public GaterBaseVisitor {
}
// Top level we could choose to make multiple gaters, or ORs under the gater
// Right now we'll put OR lower down and let other optimizations deal
if (nodep) nodep = new AstOr(eqnp->fileline(),nodep,eqnp);
if (nodep) nodep = new AstOr(nodep->fileline(), nodep, eqnp);
else nodep = eqnp;
//if (debug()>=9) nodep->dumpTree(cout," followExpr: ");
}

View File

@ -416,7 +416,7 @@ private:
}
if (splitAlwaysp) {
++m_statSplits;
AstAlways* alwaysp = new AstAlways(newListp->fileline(), VAlwaysKwd::ALWAYS, NULL, NULL);
AstAlways* alwaysp = new AstAlways(nodep->fileline(), VAlwaysKwd::ALWAYS, NULL, NULL);
addAfterp->addNextHere(alwaysp); addAfterp=alwaysp;
alwaysp->addStmtp(newListp);
} else {

View File

@ -1727,7 +1727,7 @@ private:
}
if (patp) {
// Determine initial values
vdtypep = memp;
vdtypep = memp; if (vdtypep) {}
patp->dtypep(memp);
userIterate(patp, WidthVP(memp,BOTH).p()); // See visit(AstPatMember*
@ -3058,9 +3058,9 @@ private:
// Underp is used in a self-determined but boolean context, reduce a multibit number to one bit
// stage is always BOTH so not passed as argument
// underp may change as a result of replacement
if (!underp) underp->v3fatalSrc("Node has no type");
if (!underp) nodep->v3fatalSrc("Node has no type");
underp = userIterateSubtreeReturnEdits(underp, WidthVP(SELF,BOTH).p());
if (!underp || !underp->dtypep()) underp->v3fatalSrc("Node has no type"); // Perhaps forgot to do a prelim visit on it?
if (!underp || !underp->dtypep()) nodep->v3fatalSrc("Node has no type"); // Perhaps forgot to do a prelim visit on it?
//
// For DOUBLE under a logical op, add implied test against zero, never a warning
if (underp && underp->isDouble()) {
@ -3101,7 +3101,7 @@ private:
// Returns the new underp
// Conversion to/from doubles and integers are before iterating.
if (stage != FINAL) nodep->v3fatalSrc("Bad state to iterateCheck");
if (!underp || !underp->dtypep()) underp->v3fatalSrc("Node has no type"); // Perhaps forgot to do a prelim visit on it?
if (!underp || !underp->dtypep()) nodep->v3fatalSrc("Node has no type"); // Perhaps forgot to do a prelim visit on it?
if (expDTypep == underp->dtypep()) { // Perfect
underp = userIterateSubtreeReturnEdits(underp, WidthVP(SELF,FINAL).p());
} else if (expDTypep->isDouble() && underp->isDouble()) { // Also good