]> granicus.if.org Git - clang/commitdiff
Fix bug in GRExprEngine::VisitSizeOfAlignOfExpr() where we do not add
authorTed Kremenek <kremenek@apple.com>
Tue, 2 Feb 2010 02:01:51 +0000 (02:01 +0000)
committerTed Kremenek <kremenek@apple.com>
Tue, 2 Feb 2010 02:01:51 +0000 (02:01 +0000)
'Pred' to 'Dst' for cases we currently don't handle.  This fixes
<rdar://problem/7593875>.

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

lib/Checker/GRExprEngine.cpp
test/Analysis/misc-ps.m

index 77715ac6217e44b720ae3ae41b809531a7776855..52e4fc12f8b18f7b88eae2fb537fc8d6cc505f6b 100644 (file)
@@ -2461,12 +2461,14 @@ void GRExprEngine::VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr* Ex,
     }
     else if (!T.getTypePtr()->isConstantSizeType()) {
       // FIXME: Add support for VLAs.
+      Dst.Add(Pred);
       return;
     }
     else if (T->isObjCInterfaceType()) {
       // Some code tries to take the sizeof an ObjCInterfaceType, relying that
       // the compiler has laid out its representation.  Just report Unknown
       // for these.
+      Dst.Add(Pred);
       return;
     }
     else {
index dea09367d1a399e15c69510e66b57ec306f02a2d..acf49f8e6773b49e15ca7555644c3952ce3dba3c 100644 (file)
@@ -837,3 +837,17 @@ void f(kwset_t *kws, char const *p, char const *q) {
   d = delta[c = (end+=d)[-1]]; // no-warning
   trie = next[c];
 }
+
+//===----------------------------------------------------------------------===//
+// <rdar://problem/7593875> When handling sizeof(VLA) it leads to a hole in
+// the ExplodedGraph (causing a false positive)
+//===----------------------------------------------------------------------===//
+
+int rdar_7593875_aux(int x);
+int rdar_7593875(int n) {
+  int z[n > 10 ? 10 : n]; // VLA.
+  int v;
+  v = rdar_7593875_aux(sizeof(z));
+  // Previously we got a false positive about 'v' being uninitialized.
+  return v; // no-warning
+}