aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-03-11 18:17:16 +0000
committerTed Kremenek <kremenek@apple.com>2009-03-11 18:17:16 +0000
commit344d4c8726e5fb7dfac42eeaef2c0df02d2059b0 (patch)
tree270ebb3af9b38c75e2ac8f3d97f53f3883387127
parent4fdf1faedbca40787fd277a6fbd5061fd69b2708 (diff)
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
-rw-r--r--lib/AST/StmtIterator.cpp14
-rw-r--r--test/Analysis/misc-ps.m6
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<VarDecl>(*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<VarDecl>(*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]; }