r185898 - [analyzer] Fixup for r185609: actually do suppress warnings coming out of std::list.
Anna Zaks
ganna at apple.com
Mon Jul 8 18:55:00 PDT 2013
Author: zaks
Date: Mon Jul 8 20:55:00 2013
New Revision: 185898
URL: http://llvm.org/viewvc/llvm-project?rev=185898&view=rev
Log:
[analyzer] Fixup for r185609: actually do suppress warnings coming out of std::list.
list is the name of a class, not a namespace. Change the test as well - the previous
version did not test properly.
Fixes radar://14317928.
Modified:
cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
cfe/trunk/test/Analysis/Inputs/system-header-simulator-cxx.h
Modified: cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp?rev=185898&r1=185897&r2=185898&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp Mon Jul 8 20:55:00 2013
@@ -1541,12 +1541,12 @@ LikelyFalsePositiveSuppressionBRVisitor:
// The analyzer issues a false use-after-free when std::list::pop_front
// or std::list::pop_back are called multiple times because we cannot
// reason about the internal invariants of the datastructure.
- const DeclContext *DC =
- D->getDeclContext()->getEnclosingNamespaceContext();
- const NamespaceDecl *ND = dyn_cast<NamespaceDecl>(DC);
- if (ND && ND->getName() == "list") {
+ if (const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(D)) {
+ const CXXRecordDecl *CD = MD->getParent();
+ if (CD->getName() == "list") {
BR.markInvalid(getTag(), 0);
return 0;
+ }
}
}
}
Modified: cfe/trunk/test/Analysis/Inputs/system-header-simulator-cxx.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/Inputs/system-header-simulator-cxx.h?rev=185898&r1=185897&r2=185898&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/Inputs/system-header-simulator-cxx.h (original)
+++ cfe/trunk/test/Analysis/Inputs/system-header-simulator-cxx.h Mon Jul 8 20:55:00 2013
@@ -99,7 +99,13 @@ namespace std {
: private __list_imp<_Tp, _Alloc>
{
public:
- void pop_front();
+ void pop_front() {
+ // Fake use-after-free.
+ // No warning is expected as we are suppressing warning comming
+ // out of std::list.
+ int z = 0;
+ z = 5/z;
+ }
bool empty() const;
};
More information about the cfe-commits
mailing list