This revision was automatically updated to reflect the committed changes. Closed by commit rG985e399647d5: [analyzer] Fix assertion on casting SVal to NonLoc inside the IteratorRange… (authored by steakhal).
Changed prior to commit: https://reviews.llvm.org/D158968?vs=553858&id=553879#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D158968/new/ https://reviews.llvm.org/D158968 Files: clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp clang/test/Analysis/iterator-range.cpp Index: clang/test/Analysis/iterator-range.cpp =================================================================== --- clang/test/Analysis/iterator-range.cpp +++ clang/test/Analysis/iterator-range.cpp @@ -946,3 +946,14 @@ // expected-warning@-1 {{The right operand of '-' is a garbage value}} // expected-note@-2 {{The right operand of '-' is a garbage value}} } + +namespace std { +namespace ranges { + template <class InOutIter, class Sentinel> + InOutIter next(InOutIter, Sentinel); +} // namespace ranges +} // namespace std + +void gh65009__no_crash_on_ranges_next(int **begin, int **end) { + (void)std::ranges::next(begin, end); // no-crash +} Index: clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp @@ -228,7 +228,7 @@ Value = State->getRawSVal(*ValAsLoc); } - if (Value.isUnknownOrUndef()) + if (Value.isUnknownOrUndef() || !isa<NonLoc>(Value)) return; // Incremention or decremention by 0 is never a bug.
Index: clang/test/Analysis/iterator-range.cpp =================================================================== --- clang/test/Analysis/iterator-range.cpp +++ clang/test/Analysis/iterator-range.cpp @@ -946,3 +946,14 @@ // expected-warning@-1 {{The right operand of '-' is a garbage value}} // expected-note@-2 {{The right operand of '-' is a garbage value}} } + +namespace std { +namespace ranges { + template <class InOutIter, class Sentinel> + InOutIter next(InOutIter, Sentinel); +} // namespace ranges +} // namespace std + +void gh65009__no_crash_on_ranges_next(int **begin, int **end) { + (void)std::ranges::next(begin, end); // no-crash +} Index: clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp @@ -228,7 +228,7 @@ Value = State->getRawSVal(*ValAsLoc); } - if (Value.isUnknownOrUndef()) + if (Value.isUnknownOrUndef() || !isa<NonLoc>(Value)) return; // Incremention or decremention by 0 is never a bug.
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits