]> granicus.if.org Git - clang/commitdiff
[analyzer] Exit early if constraint solver is given a non-integer symbol
authorAnna Zaks <ganna@apple.com>
Thu, 10 May 2012 21:49:52 +0000 (21:49 +0000)
committerAnna Zaks <ganna@apple.com>
Thu, 10 May 2012 21:49:52 +0000 (21:49 +0000)
to reason about.

As part of taint propagation, we now allow creation of non-integer
symbolic expressions like a cast from int to float.

Addresses PR12511 (radar://11215362).

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

lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
test/Analysis/casts.c

index 92a8eb1a7aa64038a3b2ef4ee9573167d2847ae6..5568f1ca555d10fab7abf4760f46e1d7474fc780 100644 (file)
@@ -137,6 +137,11 @@ SimpleConstraintManager::assumeAuxForSymbol(ProgramStateRef State,
                                             SymbolRef Sym, bool Assumption) {
   BasicValueFactory &BVF = getBasicVals();
   QualType T = Sym->getType(BVF.getContext());
+
+  // None of the constraint solvers currently support non-integer types.
+  if (!T->isIntegerType())
+    return State;
+
   const llvm::APSInt &zero = BVF.getValue(0, T);
   if (Assumption)
     return assumeSymNE(State, Sym, zero, zero);
index 8b88a2db432e78ba2de4ed148a02935df3ce9fb7..f862ddf573157f121cb157d4dfd39b2f20ca04c6 100644 (file)
@@ -65,3 +65,11 @@ void pr6013_6035_test(void *p) {
   foo = ((long)(p));
   (void) foo;
 }
+
+// PR12511 and radar://11215362 - Test that we support SymCastExpr, which represents symbolic int to float cast.
+char ttt(int intSeconds) {
+  double seconds = intSeconds;
+  if (seconds)
+    return 0;
+  return 0;
+}