Added support to StmtIterator to traverse the size expression of a VLA type
declared in a sizeof. For example:
sizeof(int[foo()]);
the expression "foo()" is an expression that is executed during the evaluation
of sizeof.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45043 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/AST/Expr.cpp b/AST/Expr.cpp
index 11aef7f..2276705 100644
--- a/AST/Expr.cpp
+++ b/AST/Expr.cpp
@@ -1036,10 +1036,15 @@
// SizeOfAlignOfTypeExpr
Stmt::child_iterator SizeOfAlignOfTypeExpr::child_begin() {
- return child_iterator();
+ // If the type is a VLA type (and not a typedef), the size expression of the
+ // VLA needs to be treated as an executable expression.
+ if (VariableArrayType* T = dyn_cast<VariableArrayType>(Ty.getTypePtr()))
+ return child_iterator(T);
+ else
+ return child_iterator();
}
Stmt::child_iterator SizeOfAlignOfTypeExpr::child_end() {
- return child_iterator();
+ return child_iterator();
}
// ArraySubscriptExpr