[PATCH] D14736: [analyzer] DeadStoresChecker: Treat locals captured by reference in C++ lambdas as escaped.
Devin Coughlin via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 16 16:23:17 PST 2015
dcoughlin created this revision.
dcoughlin added reviewers: zaks.anna, xazax.hun.
dcoughlin added a subscriber: cfe-commits.
The analyzer currently reports dead store false positives when a local variable is captured by reference in a C++ lambda.
For example:
int local = 0;
auto lambda = [&local]() {
local++;
};
local = 7; // False Positive: Value stored to 'local' is never read
lambda();
In this case, the assignment setting `local` to 7 is not a dead store because the called lambda will later read that assigned value.
This patch silences this source of false positives by treating locals captured by reference in C++ lambdas as escaped, similarly to how the DeadStoresChecker deals with locals whose address is taken.
http://reviews.llvm.org/D14736
Files:
lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
test/Analysis/lambdas.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14736.40362.patch
Type: text/x-patch
Size: 3474 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20151117/c75192c8/attachment.bin>
More information about the cfe-commits
mailing list