]> granicus.if.org Git - clang/commitdiff
[analyzer] Fix null tracking for the given test case, by using the proper state and...
authorAnna Zaks <ganna@apple.com>
Fri, 5 Apr 2013 23:50:11 +0000 (23:50 +0000)
committerAnna Zaks <ganna@apple.com>
Fri, 5 Apr 2013 23:50:11 +0000 (23:50 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178933 91177308-0d34-0410-b5e6-96231b3b80d8

lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
test/Analysis/inlining/inline-defensive-checks.cpp

index f600362da94b743c17ce30e3f96d4487a61da274..536064e1ad4a9e1381ea3ad93c705f30344bc722 100644 (file)
@@ -926,22 +926,7 @@ bool bugreporter::trackNullOrUndefValue(const ExplodedNode *N,
 
     if (R) {
       // Mark both the variable region and its contents as interesting.
-      SVal V = state->getRawSVal(loc::MemRegionVal(R));
-
-      // If the value matches the default for the variable region, that
-      // might mean that it's been cleared out of the state. Fall back to
-      // the full argument expression (with casts and such intact).
-      if (IsArg) {
-        bool UseArgValue = V.isUnknownOrUndef() || V.isZeroConstant();
-        if (!UseArgValue) {
-          const SymbolRegionValue *SRV =
-            dyn_cast_or_null<SymbolRegionValue>(V.getAsLocSymbol());
-          if (SRV)
-            UseArgValue = (SRV->getRegion() == R);
-        }
-        if (UseArgValue)
-          V = state->getSValAsScalarOrLoc(S, N->getLocationContext());
-      }
+      SVal V = LVState->getRawSVal(loc::MemRegionVal(R));
 
       report.markInteresting(R);
       report.markInteresting(V);
@@ -960,11 +945,11 @@ bool bugreporter::trackNullOrUndefValue(const ExplodedNode *N,
         report.addVisitor(ConstraintTracker);
 
         // Add visitor, which will suppress inline defensive checks.
-        if (N->getState()->isNull(V).isConstrainedTrue() &&
+        if (LVState->isNull(V).isConstrainedTrue() &&
             EnableNullFPSuppression) {
           BugReporterVisitor *IDCSuppressor =
             new SuppressInlineDefensiveChecksVisitor(V.castAs<DefinedSVal>(),
-                                                     N);
+                                                     LVNode);
           report.addVisitor(IDCSuppressor);
         }
       }
index 37bccbdc5b9b8aed369643201bc926e9d9d665d4..b69c53565784db544355f320a62b88e58bbeacfe 100644 (file)
@@ -52,4 +52,22 @@ void radar13224271_caller()
        Ty value;
        radar13224271_callee(getTyVal(), value );
        notNullArg(value); // no-warning
+}
+
+struct Foo {
+       int *ptr;
+       Foo(int *p)  {
+               *p = 1; // no-warning
+       }
+};
+void idc(int *p3) {
+  if (p3)
+    ;
+}
+int *retNull() {
+  return 0;
+}
+void test(int *p1, int *p2) {
+  idc(p1);
+       Foo f(p1);
 }
\ No newline at end of file