[analyzer] Fix a crash for dereferencing an empty llvm::Optional variable in SMTConst...
authorElla Ma <alansnape3058@gmail.com>
Tue, 4 May 2021 14:50:21 +0000 (16:50 +0200)
committerBalazs Benics <balazs.benics@sigmatechnology.se>
Tue, 4 May 2021 14:50:21 +0000 (16:50 +0200)
commitd882750f1105b20d892545e7ebd96f82166dcb53
treea273373f71ef90be0f20269fc44c7b7b72b8662e
parent2d480abd9a908fe1c5a86ec1a67cd2e7aeeb66c9
[analyzer] Fix a crash for dereferencing an empty llvm::Optional variable in SMTConstraintManager.h.

The first crash reported in the bug report 44338.

Condition `!isSat.hasValue() || isNotSat.getValue()` here should be
`!isNotSat.hasValue() || isNotSat.getValue()`.
`getValue()` here crashed when we used the static analyzer to analyze
postgresql-12.0.

Patch By: OikawaKirie

Reviewed By: steakhal, martong

Differential Revision: https://reviews.llvm.org/D83660
clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h
clang/test/Analysis/z3/D83660.c [new file with mode: 0644]
clang/test/Analysis/z3/Inputs/MockZ3_solver_check.c [new file with mode: 0644]