[cfe-commits] r44306 - in /cfe/trunk: Analysis/UninitializedValues.cpp test/Analysis/uninit-vals.c
Bill Wendling
isanbard at gmail.com
Sun Nov 25 02:51:32 PST 2007
Hi Ted,
I think you'll need {{ }} instead of {} in the expected warnings
output of the testcase.
-bw
Am Nov 24, 2007 um 2:07 PM schrieb Ted Kremenek <kremenek at apple.com>:
> Author: kremenek
> Date: Sat Nov 24 14:07:36 2007
> New Revision: 44306
>
> URL: http://llvm.org/viewvc/llvm-project?rev=44306&view=rev
> Log:
> Fixed bogus culling of uninitialized-values "taint" propagation
> during assignments.
> We accidentally were throttling the propagation of uninitialized
> state across
> assignments (e.g. x = y). Thanks to Anders Carlsson for spotting
> this problem.
>
> Added test cases to test suite to provide regression testing for the
> uninitialized values analysis.
>
> Added:
> cfe/trunk/test/Analysis/uninit-vals.c
> Modified:
> cfe/trunk/Analysis/UninitializedValues.cpp
>
> Modified: cfe/trunk/Analysis/UninitializedValues.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Analysis/UninitializedValues.cpp?rev=44306&r1=44305&r2=44306&view=diff
>
> ===
> ===
> ===
> =====================================================================
> --- cfe/trunk/Analysis/UninitializedValues.cpp (original)
> +++ cfe/trunk/Analysis/UninitializedValues.cpp Sat Nov 24 14:07:36
> 2007
> @@ -101,6 +101,8 @@
> else if (DeclRefExpr* DR = dyn_cast<DeclRefExpr>(S)) {
> if (BlockVarDecl* VD = dyn_cast<BlockVarDecl>(DR->getDecl()))
> return VD;
> + else
> + return NULL;
> }
> else return NULL;
> }
> @@ -108,16 +110,10 @@
> bool TransferFuncs::VisitBinaryOperator(BinaryOperator* B) {
> if (BlockVarDecl* VD = FindBlockVarDecl(B->getLHS()))
> if (B->isAssignmentOp()) {
> - if (AD.FullUninitTaint) {
> - if (B->getOpcode() == BinaryOperator::Assign)
> - return V(VD,AD) = Visit(B->getRHS());
> - else // Handle +=, -=, *=, etc. We do want '&', not '&&'.
> - return V(VD,AD) = Visit(B->getLHS()) & Visit(B->getRHS());
> - }
> - else {
> - Visit(B->getLHS()); Visit(B->getRHS());
> - return Initialized;
> - }
> + if (B->getOpcode() == BinaryOperator::Assign)
> + return V(VD,AD) = Visit(B->getRHS());
> + else // Handle +=, -=, *=, etc. We do want '&', not '&&'.
> + return V(VD,AD) = Visit(B->getLHS()) & Visit(B->getRHS());
> }
>
> return VisitStmt(B);
>
> Added: cfe/trunk/test/Analysis/uninit-vals.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/uninit-vals.c?rev=44306&view=auto
>
> ===
> ===
> ===
> =====================================================================
> --- cfe/trunk/test/Analysis/uninit-vals.c (added)
> +++ cfe/trunk/test/Analysis/uninit-vals.c Sat Nov 24 14:07:36 2007
> @@ -0,0 +1,29 @@
> +// RUN: clang -warn-uninit-values -verify %s
> +
> +int f1() {
> + int x;
> + return x; // expected-warning{use of uninitialized variable}
> +}
> +
> +int f2(int x) {
> + int y;
> + int z = x + y; // expected-warning {use of uninitialized variable}
> + return z;
> +}
> +
> +
> +int f3(int x) {
> + int y;
> + return x ? 1 : y; // expected-warning {use of uninitialized
> variable}
> +}
> +
> +int f4(int x) {
> + int y;
> + if (x) y = 1;
> + return y; // no-warning
> +}
> +
> +int f5() {
> + int a;
> + a = 30; // no-warning
> +}
>
>
> _______________________________________________
> 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