[PATCH] D49811: [analyzer] Obtain a ReturnStmt from a CFGAutomaticObjDtor
Reka Kovacs via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 25 11:38:42 PDT 2018
rnkovacs created this revision.
rnkovacs added reviewers: NoQ, xazax.hun, george.karpenkov.
Herald added subscribers: mikhail.ramalho, a.sidorin, dkrupp, szepet, baloghadamsoftware, whisperity.
The `CoreEngine` only gives us a `ReturnStmt` if the last element in the `CFGBlock` is a `CFGStmt`, otherwise the `ReturnStmt` is `nullptr`.
This patch adds support for the case when the last element is a `CFGAutomaticObjDtor`, by returning its `TriggerStmt` as a `ReturnStmt`.
Repository:
rC Clang
https://reviews.llvm.org/D49811
Files:
lib/StaticAnalyzer/Core/CoreEngine.cpp
Index: lib/StaticAnalyzer/Core/CoreEngine.cpp
===================================================================
--- lib/StaticAnalyzer/Core/CoreEngine.cpp
+++ lib/StaticAnalyzer/Core/CoreEngine.cpp
@@ -223,8 +223,12 @@
// Get return statement..
const ReturnStmt *RS = nullptr;
if (!L.getSrc()->empty()) {
- if (Optional<CFGStmt> LastStmt = L.getSrc()->back().getAs<CFGStmt>()) {
+ CFGElement LastElement = L.getSrc()->back();
+ if (Optional<CFGStmt> LastStmt = LastElement.getAs<CFGStmt>()) {
RS = dyn_cast<ReturnStmt>(LastStmt->getStmt());
+ } else if (Optional<CFGAutomaticObjDtor> AutoDtor =
+ LastElement.getAs<CFGAutomaticObjDtor>()) {
+ RS = dyn_cast<ReturnStmt>(AutoDtor->getTriggerStmt());
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49811.157317.patch
Type: text/x-patch
Size: 785 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180725/29773402/attachment-0001.bin>
More information about the cfe-commits
mailing list