diff options
author | Ted Kremenek <kremenek@apple.com> | 2007-10-29 21:38:03 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2007-10-29 21:38:03 +0000 |
commit | 771fe16a5e5cbd80902f44b1286985654ffec751 (patch) | |
tree | e14554eb4d887bf27337695b4a6bf713fe1efa5b | |
parent | 103a1b45a9167ced1816101d9fb198848f05e2e4 (diff) |
Added support for StmtIterators to iterate over the size expressions
of VariableArrayTypes that appear in TypedefDecls.
for example:
typedef int T[x][x];
the StmtIterator will iterate over "x" and "x" as subexpressions of
the DeclStmt for T.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43474 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | AST/StmtIterator.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/AST/StmtIterator.cpp b/AST/StmtIterator.cpp index 89d17bd340..ae6de11e11 100644 --- a/AST/StmtIterator.cpp +++ b/AST/StmtIterator.cpp @@ -38,10 +38,11 @@ void StmtIteratorBase::NextVA() { setVAPtr(p); if (!p) { - VarDecl* VD = cast<VarDecl>(decl); - - if (!VD->Init) - NextDecl(); + if (VarDecl* VD = dyn_cast<VarDecl>(decl)) + if (VD->Init) + return; + + NextDecl(); } } @@ -69,6 +70,13 @@ void StmtIteratorBase::NextDecl(bool ImmediateAdvance) { if (VD->getInit()) return; } + else if (TypedefDecl* TD = dyn_cast<TypedefDecl>(decl)) { + if (VariableArrayType* VAPtr = + FindVA(TD->getUnderlyingType().getTypePtr())) { + setVAPtr(VAPtr); + return; + } + } else if (EnumConstantDecl* ECD = dyn_cast<EnumConstantDecl>(decl)) if (ECD->getInitExpr()) return; |