Added decl_iterator to DeclStmt to provide an abstract interface to iterate over the ScopedDecls of a DeclStmt.
Updated a few clients of DeclStmt::getNextDeclarator() to use decl_iterator instead. Will update other clients after additional testing.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54368 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/CheckDeadStores.cpp b/lib/Analysis/CheckDeadStores.cpp
index f0d3dd1..38078e3 100644
--- a/lib/Analysis/CheckDeadStores.cpp
+++ b/lib/Analysis/CheckDeadStores.cpp
@@ -161,9 +161,10 @@
else if (DeclStmt* DS = dyn_cast<DeclStmt>(S))
// Iterate through the decls. Warn if any initializers are complex
// expressions that are not live (never used).
- for (ScopedDecl* SD = DS->getDecl(); SD; SD = SD->getNextDeclarator()) {
+ for (DeclStmt::decl_iterator DI=DS->decl_begin(), DE=DS->decl_end();
+ DI != DE; ++DI) {
- VarDecl* V = dyn_cast<VarDecl>(SD);
+ VarDecl* V = dyn_cast<VarDecl>(*DI);
if (!V)
continue;
diff --git a/lib/Analysis/LiveVariables.cpp b/lib/Analysis/LiveVariables.cpp
index 8f391dc..f5a7fb4 100644
--- a/lib/Analysis/LiveVariables.cpp
+++ b/lib/Analysis/LiveVariables.cpp
@@ -229,8 +229,9 @@
void TransferFuncs::VisitDeclStmt(DeclStmt* DS) {
// Declarations effectively "kill" a variable since they cannot
// possibly be live before they are declared.
- for (ScopedDecl* D = DS->getDecl(); D != NULL; D = D->getNextDeclarator())
- if (VarDecl* VD = dyn_cast<VarDecl>(D)) {
+ for (DeclStmt::decl_iterator DI=DS->decl_begin(), DE = DS->decl_end();
+ DI != DE; ++DI)
+ if (VarDecl* VD = dyn_cast<VarDecl>(*DI)) {
// Update liveness information.
unsigned bit = AD.getIdx(VD);
diff --git a/lib/Analysis/UninitializedValues.cpp b/lib/Analysis/UninitializedValues.cpp
index 15c11ba..83f1a70 100644
--- a/lib/Analysis/UninitializedValues.cpp
+++ b/lib/Analysis/UninitializedValues.cpp
@@ -131,8 +131,8 @@
}
bool TransferFuncs::VisitDeclStmt(DeclStmt* S) {
- for (ScopedDecl* D = S->getDecl(); D != NULL; D = D->getNextDeclarator()) {
- VarDecl *VD = dyn_cast<VarDecl>(D);
+ for (DeclStmt::decl_iterator I=S->decl_begin(), E=S->decl_end(); I!=E; ++I) {
+ VarDecl *VD = dyn_cast<VarDecl>(*I);
if (VD && VD->isBlockVarDecl()) {
if (Stmt* I = VD->getInit())
V(VD,AD) = AD.FullUninitTaint ? V(cast<Expr>(I),AD) : Initialized;