void VisitUnaryOperator(UnaryOperator *uo);
void VisitBinaryOperator(BinaryOperator *bo);
void VisitCastExpr(CastExpr *ce);
+ void VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *se);
};
}
Visit(ce->getSubExpr());
}
+void TransferFunctions::VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *se) {
+ if (se->isSizeOf()) {
+ if (se->getType()->isConstantSizeType())
+ return;
+ // Handle VLAs.
+ Visit(se->getArgumentExpr());
+ }
+}
+
//------------------------------------------------------------------------====//
// High-level "driver" logic for uninitialized values analysis.
//====------------------------------------------------------------------------//
MyInt x; // expected-warning{{use of uninitialized variable 'x'}} expected-note{{add initialization to silence this warning}}
return x; // expected-note{{variable 'x' is possibly uninitialized when used here}}
}
+
+// Test handling of sizeof().
+int test27() {
+ struct test_27 { int x; } *y;
+ return sizeof(y->x); // no-warning
+}
+
+int test28() {
+ int len; // expected-warning{{use of uninitialized variable 'len'}} expected-note{{add initialization to silence this warning}}
+ return sizeof(int[len]); // expected-note{{variable 'len' is possibly uninitialized when used here}}
+}
+