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
diff --git a/lib/AST/StmtIterator.cpp b/lib/AST/StmtIterator.cpp
index 5e42e31..94829c0 100644
--- a/lib/AST/StmtIterator.cpp
+++ b/lib/AST/StmtIterator.cpp
@@ -132,17 +132,17 @@
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());