[PATCH] D101635: [analyzer] Fix assertion in SVals.h
Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 30 09:01:04 PDT 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa27af1d8166c: [analyzer] Fix assertion in SVals.h (authored by vabridgers, committed by einvbri <vince.a.bridgers at ericsson.com>).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D101635/new/
https://reviews.llvm.org/D101635
Files:
clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
clang/test/Analysis/casts.c
Index: clang/test/Analysis/casts.c
===================================================================
--- clang/test/Analysis/casts.c
+++ clang/test/Analysis/casts.c
@@ -250,3 +250,19 @@
if (**a == 0) // no-crash
;
}
+
+// See PR50179.
+// Just don't crash.
+typedef struct taskS {
+ void *pJob;
+} taskS;
+
+typedef struct workS {
+ taskS *pTaskList;
+} workS;
+
+void *getTaskJob(unsigned jobId, workS *pWork, unsigned taskId) {
+ const taskS *pTask = pWork->pTaskList + taskId;
+ taskS task = *pTask;
+ return task.pJob;
+}
Index: clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
===================================================================
--- clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
+++ clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
@@ -761,8 +761,8 @@
// Next fixes pointer dereference using type different from its initial
// one. See PR37503 and PR49007 for details.
if (const auto *ER = dyn_cast<ElementRegion>(R)) {
- R = StateMgr.getStoreManager().castRegion(ER, CastTy);
- return loc::MemRegionVal(R);
+ if ((R = StateMgr.getStoreManager().castRegion(ER, CastTy)))
+ return loc::MemRegionVal(R);
}
return V;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101635.341934.patch
Type: text/x-patch
Size: 1212 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210430/1e72cf05/attachment.bin>
More information about the cfe-commits
mailing list