]> granicus.if.org Git - clang/commit
[analyzer] Suppress false positives in std::shared_ptr
authorDevin Coughlin <dcoughlin@apple.com>
Wed, 6 Jul 2016 21:52:55 +0000 (21:52 +0000)
committerDevin Coughlin <dcoughlin@apple.com>
Wed, 6 Jul 2016 21:52:55 +0000 (21:52 +0000)
commit20384159b6ed792f40d3b9cd906e63b911c6bafc
tree3b3167c60432083538e50ae975e1442de7b23ec8
parentcf171af0020df0bd41f8217ee3b270b2069d0f1e
[analyzer] Suppress false positives in std::shared_ptr

The analyzer does not model C++ temporary destructors completely and so
reports false alarms about leaks of memory allocated by the internals of
shared_ptr:

  std::shared_ptr<int> p(new int(1));
  p = nullptr; // 'Potential leak of memory pointed to by field __cntrl_'

This patch suppresses all diagnostics where the end of the path is inside
a method in std::shared_ptr.

It also reorganizes the tests for suppressions in the C++ standard library
to use a separate simulated header for library functions with bugs
that were deliberately inserted to test suppression. This will prevent
other tests from using these as models.

rdar://problem/23652766

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@274691 91177308-0d34-0410-b5e6-96231b3b80d8
lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
test/Analysis/Inputs/system-header-simulator-cxx-std-suppression.h [new file with mode: 0644]
test/Analysis/Inputs/system-header-simulator-cxx.h
test/Analysis/diagnostics/implicit-cxx-std-suppression.cpp [new file with mode: 0644]
test/Analysis/inlining/stl.cpp