From: Ted Kremenek Date: Fri, 28 Sep 2007 17:55:50 +0000 (+0000) Subject: Fixed bug where declaration initializer expressions were not X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=677190ffddcc12fc57d10e217ee7b61c87d4edc3;p=clang Fixed bug where declaration initializer expressions were not traversed by the visitor. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42438 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Analysis/Visitors/CFGRecStmtDeclVisitor.h b/include/clang/Analysis/Visitors/CFGRecStmtDeclVisitor.h index e46ee11ff4..e8f74c0a7b 100644 --- a/include/clang/Analysis/Visitors/CFGRecStmtDeclVisitor.h +++ b/include/clang/Analysis/Visitors/CFGRecStmtDeclVisitor.h @@ -27,7 +27,7 @@ break; #define DEFAULT_DISPATCH(CLASS) void Visit##CLASS(CLASS* D) {} #define DEFAULT_DISPATCH_VARDECL(CLASS) void Visit##CLASS(CLASS* D)\ - { static_cast(this)->Visit##VarDecl(D); } + { static_cast(this)->VisitVarDecl(D); } namespace clang { @@ -36,18 +36,20 @@ class CFGRecStmtDeclVisitor : public CFGRecStmtVisitor { public: void VisitDeclRefExpr(DeclRefExpr* DR) { - static_cast(this)->VisitDeclChain(DR->getDecl()); + for (ScopedDecl* D = DR->getDecl(); D != NULL; D = D->getNextDeclarator()) + static_cast(this)->VisitScopedDecl(D); } - void VisitDeclStmt(DeclStmt* DS) { - static_cast(this)->VisitDeclChain(DS->getDecl()); - } - - void VisitDeclChain(ScopedDecl* D) { - for (; D != NULL; D = D->getNextDeclarator()) - static_cast(this)->VisitScopedDecl(D); + void VisitDeclStmt(DeclStmt* DS) { + for (ScopedDecl* D = DS->getDecl(); D != NULL; D = D->getNextDeclarator()) { + static_cast(this)->VisitScopedDecl(D); + // Visit the initializer. + if (VarDecl* VD = dyn_cast(D)) + if (Expr* I = VD->getInit()) + static_cast(this)->Visit(I); + } } - + void VisitScopedDecl(ScopedDecl* D) { switch (D->getKind()) { DISPATCH_CASE(Function,FunctionDecl)