else if (DeclRefExpr* DR = dyn_cast<DeclRefExpr>(S)) {
if (BlockVarDecl* VD = dyn_cast<BlockVarDecl>(DR->getDecl()))
return VD;
+ else
+ return NULL;
}
else return NULL;
}
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);
--- /dev/null
+// 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
+}