[cfe-commits] r156578 - in /cfe/trunk: lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp test/Analysis/casts.c

Ted Kremenek kremenek at apple.com
Thu May 10 16:15:16 PDT 2012


Will this also prune pointer types (which is not what we want)?

On May 10, 2012, at 2:49 PM, Anna Zaks <ganna at apple.com> wrote:

> Author: zaks
> Date: Thu May 10 16:49:52 2012
> New Revision: 156578
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=156578&view=rev
> Log:
> [analyzer] Exit early if constraint solver is given a non-integer symbol
> 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).
> 
> Modified:
>    cfe/trunk/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
>    cfe/trunk/test/Analysis/casts.c
> 
> Modified: cfe/trunk/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp?rev=156578&r1=156577&r2=156578&view=diff
> ==============================================================================
> --- cfe/trunk/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp (original)
> +++ cfe/trunk/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp Thu May 10 16:49:52 2012
> @@ -137,6 +137,11 @@
>                                             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);
> 
> Modified: cfe/trunk/test/Analysis/casts.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/casts.c?rev=156578&r1=156577&r2=156578&view=diff
> ==============================================================================
> --- cfe/trunk/test/Analysis/casts.c (original)
> +++ cfe/trunk/test/Analysis/casts.c Thu May 10 16:49:52 2012
> @@ -65,3 +65,11 @@
>   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;
> +}
> 
> 
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits




More information about the cfe-commits mailing list