This revision was automatically updated to reflect the committed changes. Closed by commit rG98d55095d851: Fix assertion failure "PathDiagnosticSpotPiece's must have a valid location."… (authored by arseniy-sonar, committed by steakhal).
Changed prior to commit: https://reviews.llvm.org/D138713?vs=477952&id=492465#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D138713/new/ https://reviews.llvm.org/D138713 Files: clang/lib/StaticAnalyzer/Checkers/ReturnPointerRangeChecker.cpp clang/test/Analysis/return-ptr-range.cpp Index: clang/test/Analysis/return-ptr-range.cpp =================================================================== --- clang/test/Analysis/return-ptr-range.cpp +++ clang/test/Analysis/return-ptr-range.cpp @@ -115,3 +115,14 @@ } +namespace std { +// A builtin function with the body generated on the fly. +template <typename T> T&& move(T &&) noexcept; +} // namespace std + +char buf[2]; + +void top() { + // see https://github.com/llvm/llvm-project/issues/55347 + (void)std::move(*(buf + 3)); // no-crash +} Index: clang/lib/StaticAnalyzer/Checkers/ReturnPointerRangeChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/ReturnPointerRangeChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/ReturnPointerRangeChecker.cpp @@ -41,6 +41,10 @@ if (!RetE) return; + // Skip "body farmed" functions. + if (RetE->getSourceRange().isInvalid()) + return; + SVal V = C.getSVal(RetE); const MemRegion *R = V.getAsRegion();
Index: clang/test/Analysis/return-ptr-range.cpp =================================================================== --- clang/test/Analysis/return-ptr-range.cpp +++ clang/test/Analysis/return-ptr-range.cpp @@ -115,3 +115,14 @@ } +namespace std { +// A builtin function with the body generated on the fly. +template <typename T> T&& move(T &&) noexcept; +} // namespace std + +char buf[2]; + +void top() { + // see https://github.com/llvm/llvm-project/issues/55347 + (void)std::move(*(buf + 3)); // no-crash +} Index: clang/lib/StaticAnalyzer/Checkers/ReturnPointerRangeChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/ReturnPointerRangeChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/ReturnPointerRangeChecker.cpp @@ -41,6 +41,10 @@ if (!RetE) return; + // Skip "body farmed" functions. + if (RetE->getSourceRange().isInvalid()) + return; + SVal V = C.getSVal(RetE); const MemRegion *R = V.getAsRegion();
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits