Skip to content

Commit 4b66976

Browse files
authored
Fix 15042: ValueFlow: conditionally reassigned value should not be known (cppcheck-opensource#8899)
This refactors `ProgramMemory` so it can store a list of values. A condition such as `x > 3` was recorded as the possible value 4 with a lower bound, and the executor then used it as if `x` were exactly 4. Nested conditions were decided wrongly, so branches were skipped and values leaked past or were lost before them. This what lead to the FP in 15042. Now it can understand these constraints better. As new values are added, it is resolved similar to `Token::addValue`.
1 parent 7b481f4 commit 4b66976

33 files changed

Lines changed: 2288 additions & 5180 deletions

‎Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ $(libcppdir)/platform.o: lib/platform.cpp externals/tinyxml2/tinyxml2.h lib/conf
646646
$(libcppdir)/preprocessor.o: lib/preprocessor.cpp externals/simplecpp/simplecpp.h lib/checkers.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/preprocessor.h lib/refthunk.h lib/settings.h lib/standards.h lib/suppressions.h lib/utils.h
647647
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/preprocessor.cpp
648648

649-
$(libcppdir)/programmemory.o: lib/programmemory.cpp lib/astutils.h lib/calculate.h lib/checkers.h lib/config.h lib/errortypes.h lib/infer.h lib/library.h lib/mathlib.h lib/platform.h lib/programmemory.h lib/refthunk.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenlist.h lib/utils.h lib/valueflow.h lib/valueptr.h lib/vfvalue.h
649+
$(libcppdir)/programmemory.o: lib/programmemory.cpp lib/astutils.h lib/calculate.h lib/checkers.h lib/config.h lib/errortypes.h lib/infer.h lib/library.h lib/mathlib.h lib/platform.h lib/programmemory.h lib/refthunk.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenlist.h lib/utils.h lib/valueflow.h lib/valueptr.h lib/vf_common.h lib/vfvalue.h
650650
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/programmemory.cpp
651651

652652
$(libcppdir)/regex.o: lib/regex.cpp lib/config.h lib/regex.h

‎gui/cppcheck_de.ts‎

Lines changed: 0 additions & 342 deletions
Large diffs are not rendered by default.

‎gui/cppcheck_es.ts‎

Lines changed: 0 additions & 342 deletions
Large diffs are not rendered by default.

‎gui/cppcheck_fi.ts‎

Lines changed: 0 additions & 342 deletions
Large diffs are not rendered by default.

‎gui/cppcheck_fr.ts‎

Lines changed: 0 additions & 342 deletions
Large diffs are not rendered by default.

‎gui/cppcheck_it.ts‎

Lines changed: 0 additions & 342 deletions
Large diffs are not rendered by default.

‎gui/cppcheck_ja.ts‎

Lines changed: 0 additions & 342 deletions
Large diffs are not rendered by default.

‎gui/cppcheck_ka.ts‎

Lines changed: 0 additions & 342 deletions
Large diffs are not rendered by default.

‎gui/cppcheck_ko.ts‎

Lines changed: 0 additions & 342 deletions
Large diffs are not rendered by default.

‎gui/cppcheck_nl.ts‎

Lines changed: 0 additions & 342 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)