summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2012-03-01 16:34:31 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2012-03-01 16:34:31 +0000
commitcdb9f302d010ab1746de36c1d20384a654fedba1 (patch)
treeed8e1d9540774d95654bfde51a0f69f17c3e8ce6
parentb1cb18468b45634e75bffd235ea5d4cfe78b9815 (diff)
downloadbcm5719-llvm-cdb9f302d010ab1746de36c1d20384a654fedba1.tar.gz
bcm5719-llvm-cdb9f302d010ab1746de36c1d20384a654fedba1.zip
StmtProfiler: Add a null check for child statements.
llvm-svn: 151812
-rw-r--r--clang/lib/AST/StmtProfile.cpp8
-rw-r--r--clang/test/SemaCXX/warn-memset-bad-sizeof.cpp8
2 files changed, 14 insertions, 2 deletions
diff --git a/clang/lib/AST/StmtProfile.cpp b/clang/lib/AST/StmtProfile.cpp
index 643bca817c4..d9969259062 100644
--- a/clang/lib/AST/StmtProfile.cpp
+++ b/clang/lib/AST/StmtProfile.cpp
@@ -69,8 +69,12 @@ namespace {
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) {
diff --git a/clang/test/SemaCXX/warn-memset-bad-sizeof.cpp b/clang/test/SemaCXX/warn-memset-bad-sizeof.cpp
index 388e3627685..e0d28da3d58 100644
--- a/clang/test/SemaCXX/warn-memset-bad-sizeof.cpp
+++ b/clang/test/SemaCXX/warn-memset-bad-sizeof.cpp
@@ -104,6 +104,14 @@ void f(Mat m, const Foo& const_foo, char *buffer) {
// 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 {
OpenPOWER on IntegriCloud