]> granicus.if.org Git - clang/commitdiff
[analyzer] Fixup for r185609: actually do suppress warnings coming out of std::list.
authorAnna Zaks <ganna@apple.com>
Tue, 9 Jul 2013 01:55:00 +0000 (01:55 +0000)
committerAnna Zaks <ganna@apple.com>
Tue, 9 Jul 2013 01:55:00 +0000 (01:55 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185898 91177308-0d34-0410-b5e6-96231b3b80d8

lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
test/Analysis/Inputs/system-header-simulator-cxx.h

index 70354fe21c3fbf3464123f4ecafd0021d3875cbe..fc81d1cc11ece83189a2a720cfeaf2587f61b5c0 100644 (file)
@@ -1541,12 +1541,12 @@ LikelyFalsePositiveSuppressionBRVisitor::getEndPath(BugReporterContext &BRC,
       // 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;
+        }
       }
     }
   }
index 049d6be91b46b1b35f5150d0d74984503537fe45..8e96508ba586d61d643853b4b9453d6865e0fc0f 100644 (file)
@@ -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;
   };