MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / combineValueProperties

Method combineValueProperties

lib/valueflow.cpp:382–423  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

380}
381
382void ValueFlow::combineValueProperties(const ValueFlow::Value &value1, const ValueFlow::Value &value2, ValueFlow::Value &result)
383{
384 if (value1.isKnown() && value2.isKnown())
385 result.setKnown();
386 else if (value1.isImpossible() || value2.isImpossible())
387 result.setImpossible();
388 else if (value1.isInconclusive() || value2.isInconclusive())
389 result.setInconclusive();
390 else
391 result.setPossible();
392 if (value1.tokvalue)
393 result.tokvalue = value1.tokvalue;
394 else if (value2.tokvalue)
395 result.tokvalue = value2.tokvalue;
396 if (value1.isSymbolicValue()) {
397 result.valueType = value1.valueType;
398 result.tokvalue = value1.tokvalue;
399 }
400 if (value2.isSymbolicValue()) {
401 result.valueType = value2.valueType;
402 result.tokvalue = value2.tokvalue;
403 }
404 if (value1.isIteratorValue())
405 result.valueType = value1.valueType;
406 if (value2.isIteratorValue())
407 result.valueType = value2.valueType;
408 result.condition = value1.condition ? value1.condition : value2.condition;
409 result.varId = (value1.varId != 0) ? value1.varId : value2.varId;
410 result.varvalue = (result.varId == value1.varId) ? value1.varvalue : value2.varvalue;
411 result.errorPath = (value1.errorPath.empty() ? value2 : value1).errorPath;
412 result.safe = value1.safe || value2.safe;
413 if (value1.bound == ValueFlow::Value::Bound::Point || value2.bound == ValueFlow::Value::Bound::Point) {
414 if (value1.bound == ValueFlow::Value::Bound::Upper || value2.bound == ValueFlow::Value::Bound::Upper)
415 result.bound = ValueFlow::Value::Bound::Upper;
416 if (value1.bound == ValueFlow::Value::Bound::Lower || value2.bound == ValueFlow::Value::Bound::Lower)
417 result.bound = ValueFlow::Value::Bound::Lower;
418 }
419 if (value1.path != value2.path)
420 result.path = -1;
421 else
422 result.path = value1.path;
423}
424
425static void valueFlowNumber(TokenList &tokenlist, const Settings& settings)
426{

Callers

nothing calls this directly

Calls 5

isKnownMethod · 0.80
isImpossibleMethod · 0.80
setInconclusiveMethod · 0.80
isInconclusiveMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected