[PATCH] D101635: [analyzer] Fix assertion in SVals.h
Vince Bridgers via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 30 07:45:57 PDT 2021
vabridgers created this revision.
vabridgers added reviewers: ASDenysPetrov, NoQ, steakhal, martong, vsavchenko.
Herald added subscribers: dkrupp, donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware, xazax.hun, whisperity.
vabridgers requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Fix assertion in SVals.h apparently caused by
https://reviews.llvm.org/D89055.
clang:clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h:596:
clang::ento::loc::MemRegionVal::MemRegionVal(const clang::ento::MemRegion *):
Assertion `r' failed.
Backtrace:
...
clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h:597:3
clang::QualType, clang::QualType)
clang/lib/StaticAnalyzer/Core/SValBuilder.cpp:773:18
clang::QualType, clang::QualType)
clang/lib/StaticAnalyzer/Core/SValBuilder.cpp:612:12
clang::QualType) clang/lib/StaticAnalyzer/Core/SValBuilder.cpp:587:12
namespace)::RegionBindingsRef const&, clang::ento::Loc, clang::QualType)
clang/lib/StaticAnalyzer/Core/RegionStore.cpp:1510:24
...
Repository:
rG LLVM Github Monorepo
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.341902.patch
Type: text/x-patch
Size: 1212 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210430/5794e6fe/attachment.bin>
More information about the cfe-commits
mailing list