diff options
author | George Karpenkov <ekarpenkov@apple.com> | 2018-10-03 22:31:09 +0000 |
---|---|---|
committer | George Karpenkov <ekarpenkov@apple.com> | 2018-10-03 22:31:09 +0000 |
commit | 0550dac3ed5fb7babd96ef037b11e3ebd69b4943 (patch) | |
tree | ea08b0c36b98be9f40b0cd7de6cf1c56db9c2d87 /clang/lib/StaticAnalyzer/Checkers/TrustNonnullChecker.cpp | |
parent | 371842b85353ade5b5c342ca6049daabc16df310 (diff) | |
download | bcm5719-llvm-0550dac3ed5fb7babd96ef037b11e3ebd69b4943.tar.gz bcm5719-llvm-0550dac3ed5fb7babd96ef037b11e3ebd69b4943.zip |
[analyzer] Do not crash if the assumption added in TrustNonNullChecker is enough to make the state unfeasible
rdar://43541814
Differential Revision: https://reviews.llvm.org/D52848
llvm-svn: 343735
Diffstat (limited to 'clang/lib/StaticAnalyzer/Checkers/TrustNonnullChecker.cpp')
-rw-r--r-- | clang/lib/StaticAnalyzer/Checkers/TrustNonnullChecker.cpp | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/TrustNonnullChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/TrustNonnullChecker.cpp index eed1efd10e2..515c98cd116 100644 --- a/clang/lib/StaticAnalyzer/Checkers/TrustNonnullChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/TrustNonnullChecker.cpp @@ -212,20 +212,26 @@ private: /// the negation of \p Antecedent. /// Checks NonNullImplicationMap and assumes \p Antecedent otherwise. ProgramStateRef addImplication(SymbolRef Antecedent, - ProgramStateRef State, + ProgramStateRef InputState, bool Negated) const { - SValBuilder &SVB = State->getStateManager().getSValBuilder(); + if (!InputState) + return nullptr; + SValBuilder &SVB = InputState->getStateManager().getSValBuilder(); const SymbolRef *Consequent = - Negated ? State->get<NonNullImplicationMap>(Antecedent) - : State->get<NullImplicationMap>(Antecedent); + Negated ? InputState->get<NonNullImplicationMap>(Antecedent) + : InputState->get<NullImplicationMap>(Antecedent); if (!Consequent) - return State; + return InputState; SVal AntecedentV = SVB.makeSymbolVal(Antecedent); - if ((Negated && State->isNonNull(AntecedentV).isConstrainedTrue()) - || (!Negated && State->isNull(AntecedentV).isConstrainedTrue())) { + ProgramStateRef State = InputState; + + if ((Negated && InputState->isNonNull(AntecedentV).isConstrainedTrue()) + || (!Negated && InputState->isNull(AntecedentV).isConstrainedTrue())) { SVal ConsequentS = SVB.makeSymbolVal(*Consequent); - State = State->assume(ConsequentS.castAs<DefinedSVal>(), Negated); + State = InputState->assume(ConsequentS.castAs<DefinedSVal>(), Negated); + if (!State) + return nullptr; // Drop implications from the map. if (Negated) { |