StmtProfiler: Add a null check for child statements.

llvm-svn: 151812
This commit is contained in:
Peter Collingbourne 2012-03-01 16:34:31 +00:00
parent b1cb18468b
commit cdb9f302d0
2 changed files with 14 additions and 2 deletions

View File

@ -69,8 +69,12 @@ namespace {
void StmtProfiler::VisitStmt(const Stmt *S) { void StmtProfiler::VisitStmt(const Stmt *S) {
ID.AddInteger(S->getStmtClass()); ID.AddInteger(S->getStmtClass());
for (Stmt::const_child_range C = S->children(); C; ++C) for (Stmt::const_child_range C = S->children(); C; ++C) {
Visit(*C); if (*C)
Visit(*C);
else
ID.AddInteger(0);
}
} }
void StmtProfiler::VisitDeclStmt(const DeclStmt *S) { void StmtProfiler::VisitDeclStmt(const DeclStmt *S) {

View File

@ -104,6 +104,14 @@ void f(Mat m, const Foo& const_foo, char *buffer) {
// Copy to raw buffer shouldn't warn either // Copy to raw buffer shouldn't warn either
memcpy(&foo, &arr, sizeof(Foo)); memcpy(&foo, &arr, sizeof(Foo));
memcpy(&arr, &foo, 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 { namespace ns {