From 344d4c8726e5fb7dfac42eeaef2c0df02d2059b0 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Wed, 11 Mar 2009 18:17:16 +0000 Subject: [PATCH] Fix StmtIterator bug reported in PR 3780 where a VLA within a DeclGroup would not be consulted for its size expression when operator* was called in the StmtIterator (this resulted in an assertion failure). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66679 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/StmtIterator.cpp | 14 +++++++------- test/Analysis/misc-ps.m | 6 ++++-- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/lib/AST/StmtIterator.cpp b/lib/AST/StmtIterator.cpp index 5e42e31b28..94829c01e3 100644 --- a/lib/AST/StmtIterator.cpp +++ b/lib/AST/StmtIterator.cpp @@ -132,17 +132,17 @@ StmtIteratorBase::StmtIteratorBase(VariableArrayType* t) Stmt*& StmtIteratorBase::GetDeclExpr() const { - if (inDeclGroup()) { - VarDecl* VD = cast(*DGI); - return VD->Init; - } - - assert (inDecl() || inSizeOfTypeVA()); - if (VariableArrayType* VAPtr = getVAPtr()) { assert (VAPtr->SizeExpr); return VAPtr->SizeExpr; } + + assert (inDecl() || inDeclGroup()); + + if (inDeclGroup()) { + VarDecl* VD = cast(*DGI); + return VD->Init; + } assert (inDecl()); diff --git a/test/Analysis/misc-ps.m b/test/Analysis/misc-ps.m index 50dda78cdb..08de2f4aac 100644 --- a/test/Analysis/misc-ps.m +++ b/test/Analysis/misc-ps.m @@ -178,13 +178,13 @@ char pr3770(int x) { return 'a'; } -// PR 3780 +// PR 3772 // - We just want to test that this doesn't crash the analyzer. typedef struct st ST; struct st { char *name; }; extern ST *Cur_Pu; -void pr3780(void) +void pr3772(void) { static ST *last_Cur_Pu; if (last_Cur_Pu == Cur_Pu) { @@ -192,4 +192,6 @@ void pr3780(void) } } +// PR 3780 - This tests that StmtIterator isn't broken for VLAs in DeclGroups. +void pr3780(int sz) { typedef double MAT[sz][sz]; } -- 2.40.0