[PATCH] D138713: Fix assertion failure "PathDiagnosticSpotPiece's must have a valid location." in ReturnPtrRange checker on builtin functions
Balázs Benics via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 26 08:36:42 PST 2023
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();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D138713.492465.patch
Type: text/x-patch
Size: 1006 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230126/6efec48a/attachment.bin>
More information about the cfe-commits
mailing list