[cfe-commits] r151812 - in /cfe/trunk: lib/AST/StmtProfile.cpp test/SemaCXX/warn-memset-bad-sizeof.cpp
Peter Collingbourne
peter at pcc.me.uk
Thu Mar 1 08:34:31 PST 2012
Author: pcc
Date: Thu Mar 1 10:34:31 2012
New Revision: 151812
URL: http://llvm.org/viewvc/llvm-project?rev=151812&view=rev
Log:
StmtProfiler: Add a null check for child statements.
Modified:
cfe/trunk/lib/AST/StmtProfile.cpp
cfe/trunk/test/SemaCXX/warn-memset-bad-sizeof.cpp
Modified: cfe/trunk/lib/AST/StmtProfile.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtProfile.cpp?rev=151812&r1=151811&r2=151812&view=diff
==============================================================================
--- cfe/trunk/lib/AST/StmtProfile.cpp (original)
+++ cfe/trunk/lib/AST/StmtProfile.cpp Thu Mar 1 10:34:31 2012
@@ -69,8 +69,12 @@
void StmtProfiler::VisitStmt(const Stmt *S) {
ID.AddInteger(S->getStmtClass());
- for (Stmt::const_child_range C = S->children(); C; ++C)
- Visit(*C);
+ for (Stmt::const_child_range C = S->children(); C; ++C) {
+ if (*C)
+ Visit(*C);
+ else
+ ID.AddInteger(0);
+ }
}
void StmtProfiler::VisitDeclStmt(const DeclStmt *S) {
Modified: cfe/trunk/test/SemaCXX/warn-memset-bad-sizeof.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-memset-bad-sizeof.cpp?rev=151812&r1=151811&r2=151812&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/warn-memset-bad-sizeof.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-memset-bad-sizeof.cpp Thu Mar 1 10:34:31 2012
@@ -104,6 +104,14 @@
// Copy to raw buffer shouldn't warn either
memcpy(&foo, &arr, sizeof(Foo));
memcpy(&arr, &foo, sizeof(Foo));
+
+ // Shouldn't warn, and shouldn't crash either.
+ memset(({
+ if (0) {}
+ while (0) {}
+ for (;;) {}
+ &s;
+ }), 0, sizeof(s));
}
namespace ns {
More information about the cfe-commits
mailing list