[PATCH] D30593: Add correct "-isystem"/"-isysroot" warning handling to static analysis' BugReporter.
Kevin Marshall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 6 17:22:26 PST 2017
kmarshall added a comment.
Also, it looks like some instances of safe unique_ptr assignment using std::move() are tripping up the analyzer.
Error:
../../build/linux/debian_wheezy_amd64-sysroot/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../include/c++/4.6/bits/unique_ptr.h:190:4: warning: Potential memory leak
**C++ library code:**
template<typename _Up, typename _Ep, typename = typename
std::enable_if
<std::is_convertible<typename unique_ptr<_Up, _Ep>::pointer,
pointer>::value
&& !std::is_array<_Up>::value>::type>
unique_ptr&
operator=(unique_ptr<_Up, _Ep>&& __u)
{
reset(__u.release());
get_deleter() = std::forward<_Ep>(__u.get_deleter());
return *this; // <------------------ GENERATES WARNING
}
**Call site:**
case Message::STRUCT: {
MessageReader sub_reader(NULL);
if (reader->PopStruct(&sub_reader)) {
std::unique_ptr<base::ListValue> list_value(new base::ListValue);
if (PopListElements(&sub_reader, list_value.get()))
result = std::move(list_value); // <-- GENERATES WARNING. |result| is a std::unique_ptr<base::Value>, so the std::move should be safe.
}
break;
}
**Analysis trace:**
In file included from ../../build/linux/debian_wheezy_amd64-sysroot/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../include/c++/4.6/memory:85:
../../build/linux/debian_wheezy_amd64-sysroot/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../include/c++/4.6/bits/unique_ptr.h:190:4: warning: Potential memory leak
return *this;
^
../../dbus/values_util.cc:94:3: note: Control jumps to 'case STRUCT:' at line 197
switch (reader->GetDataType()) {
^
../../dbus/values_util.cc:199:11: note: Assuming the condition is true
if (reader->PopStruct(&sub_reader)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../dbus/values_util.cc:199:7: note: Taking true branch
if (reader->PopStruct(&sub_reader)) {
^
../../dbus/values_util.cc:200:53: note: Memory is allocated
std::unique_ptr<base::ListValue> list_value(new base::ListValue);
^~~~~~~~~~~~~~~~~~~
../../dbus/values_util.cc:201:9: note: Taking true branch
if (PopListElements(&sub_reader, list_value.get()))
^
../../dbus/values_util.cc:202:11: note: Calling 'unique_ptr::operator='
result = std::move(list_value);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../build/linux/debian_wheezy_amd64-sysroot/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../include/c++/4.6/bits/unique_ptr.h:190:4: note: Potential memory leak
return *this;
^
Repository:
rL LLVM
https://reviews.llvm.org/D30593
More information about the cfe-commits
mailing list