Index: include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h =================================================================== --- include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h +++ include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h @@ -824,8 +824,9 @@ } /// \class ScanReachableSymbols -/// A Utility class that allows to visit the reachable symbols using a custom -/// SymbolVisitor. +/// A utility class that visits the reachable symbols using a custom +/// SymbolVisitor. Terminates recursive traversal when the visitor function +/// returns false. class ScanReachableSymbols { typedef llvm::DenseSet VisitedItems; Index: lib/StaticAnalyzer/Core/ProgramState.cpp =================================================================== --- lib/StaticAnalyzer/Core/ProgramState.cpp +++ lib/StaticAnalyzer/Core/ProgramState.cpp @@ -527,32 +527,17 @@ } bool ScanReachableSymbols::scan(const SymExpr *sym) { - bool wasVisited = !visited.insert(sym).second; - if (wasVisited) - return true; - - if (!visitor.VisitSymbol(sym)) - return false; + for (SymExpr::symbol_iterator SI = sym->symbol_begin(), + SE = sym->symbol_end(); + SI != SE; ++SI) { + bool wasVisited = !visited.insert(*SI).second; + if (wasVisited) + continue; - // TODO: should be rewritten using SymExpr::symbol_iterator. - switch (sym->getKind()) { - case SymExpr::SymbolRegionValueKind: - case SymExpr::SymbolConjuredKind: - case SymExpr::SymbolDerivedKind: - case SymExpr::SymbolExtentKind: - case SymExpr::SymbolMetadataKind: - break; - case SymExpr::SymbolCastKind: - return scan(cast(sym)->getOperand()); - case SymExpr::SymIntExprKind: - return scan(cast(sym)->getLHS()); - case SymExpr::IntSymExprKind: - return scan(cast(sym)->getRHS()); - case SymExpr::SymSymExprKind: { - const SymSymExpr *x = cast(sym); - return scan(x->getLHS()) && scan(x->getRHS()); - } + if (!visitor.VisitSymbol(*SI)) + return false; } + return true; }