[llvm-bugs] clang-tidy weird warning for mutex lock
Abhishek Deshpande via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Sep 7 23:29:31 PDT 2016
Recently, I checked out llvm tools from following link.
http://llvm.org/docs/GettingStarted.html#getting-started-quickly-a-summary
I followed the instructions and build the tools required for clang-tidy.
At my workplace, we are modernizing our module's source code to C++11
standard and we aggressively using clang-tidy (built from the trunk as
mentioned above) for this purpose.
One of the use cases where we are stuck is a weird warning for mutex locks.
Here is a smaller reproducible version of our use case
#include <boost/thread.hpp>
void foo2()
{
boost::mutex crapmutex;
boost::mutex::scoped_lock lock(crapmutex);
}
int main() {
foo2();
return 0;
}
When we run clang-tidy with all checks enabled, specify our internal
compilation options followed by standard compiler flags, we get following
warnings for mutex locks
33110 warnings generated.
..../boost/include/boost/thread/pthread/mutex.hpp:149:23: warning: This
lock has already been acquired [clang-analyzer-alpha.unix.PthreadLock]
int res = posix::pthread_mutex_lock(&m);
^
..../Source.cpp:13:5: note: Calling 'foo2'
foo2();
^
...../Source.cpp:8:31: note: Calling constructor for 'unique_lock'
boost::mutex::scoped_lock lock(crapmutex);
^
..../boost/include/boost/thread/lock_types.hpp:157:7: note: Calling
'unique_lock::lock'
lock();
^
..../boost/include/boost/thread/lock_types.hpp:369:7: note: Taking false
branch
if (m == 0)
^
..../boost/include/boost/thread/lock_types.hpp:374:7: note: Taking false
branch
if (owns_lock())
^
..../boost/include/boost/thread/lock_types.hpp:379:7: note: Calling
'mutex::lock'
m->lock();
^
..../boost/include/boost/thread/pthread/mutex.hpp:149:23: note: This lock
has already been acquired
int res = posix::pthread_mutex_lock(&m);
^
Suppressed 33109 warnings (33109 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use
-system-headers to display errors from system headers as well.
Why is this warning coming up? These two locks are totally not related. Is
this a bug? If not then why is this warning coming up?
Please let me know if any more details are required.
Thanks,
Recker
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160908/dbe1f68f/attachment.html>
More information about the llvm-bugs
mailing list