[cfe-commits] r168843 - in /cfe/trunk: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp test/Analysis/misc-ps-region-store.cpp
Eli Friedman
eli.friedman at gmail.com
Wed Nov 28 17:03:15 PST 2012
On Wed, Nov 28, 2012 at 4:50 PM, Ted Kremenek <kremenek at apple.com> wrote:
> Author: kremenek
> Date: Wed Nov 28 18:50:20 2012
> New Revision: 168843
>
> URL: http://llvm.org/viewvc/llvm-project?rev=168843&view=rev
> Log:
> Correctly handle IntegralToBool casts in C++ in the static analyzer. Fixes <rdar://problem/12759044>.
>
> Modified:
> cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
> cfe/trunk/test/Analysis/misc-ps-region-store.cpp
>
> Modified: cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp?rev=168843&r1=168842&r2=168843&view=diff
> ==============================================================================
> --- cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp (original)
> +++ cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp Wed Nov 28 18:50:20 2012
> @@ -101,6 +101,12 @@
> if (!isa<nonloc::ConcreteInt>(val))
> return UnknownVal();
>
> + // Handle casts to a boolean type.
> + if (castTy->isBooleanType()) {
> + bool b = cast<nonloc::ConcreteInt>(val).getValue().getBoolValue();
> + return makeTruthVal(b, castTy);
> + }
General observation: in Sema and CodeGen, we try to avoid figuring out
what a cast means based on the destination type of a cast; using
CastKinds generally makes code both more clear and avoids this sort of
bug.
-Eli
More information about the cfe-commits
mailing list