diff --git a/clang/lib/StaticAnalyzer/Checkers/TraversalChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/TraversalChecker.cpp index 2f316bd3b20db..a5fb39be04c1d 100644 --- a/clang/lib/StaticAnalyzer/Checkers/TraversalChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/TraversalChecker.cpp @@ -23,34 +23,17 @@ using namespace clang; using namespace ento; namespace { -class TraversalDumper : public Checker< check::BranchCondition, - check::BeginFunction, - check::EndFunction > { +// TODO: This checker is only referenced from two small test files and it +// doesn't seem to be useful for manual debugging, so consider reimplementing +// those tests with more modern tools and removing this checker. +class TraversalDumper + : public Checker { public: - void checkBranchCondition(const Stmt *Condition, CheckerContext &C) const; void checkBeginFunction(CheckerContext &C) const; void checkEndFunction(const ReturnStmt *RS, CheckerContext &C) const; }; } -void TraversalDumper::checkBranchCondition(const Stmt *Condition, - CheckerContext &C) const { - // Special-case Objective-C's for-in loop, which uses the entire loop as its - // condition. We just print the collection expression. - const Stmt *Parent = dyn_cast(Condition); - if (!Parent) { - const ParentMap &Parents = C.getLocationContext()->getParentMap(); - Parent = Parents.getParent(Condition); - } - - // It is mildly evil to print directly to llvm::outs() rather than emitting - // warnings, but this ensures things do not get filtered out by the rest of - // the static analyzer machinery. - SourceLocation Loc = Parent->getBeginLoc(); - llvm::outs() << C.getSourceManager().getSpellingLineNumber(Loc) << " " - << Parent->getStmtClassName() << "\n"; -} - void TraversalDumper::checkBeginFunction(CheckerContext &C) const { llvm::outs() << "--BEGIN FUNCTION--\n"; } @@ -71,6 +54,9 @@ bool ento::shouldRegisterTraversalDumper(const CheckerManager &mgr) { //------------------------------------------------------------------------------ namespace { +// TODO: This checker appears to be a utility for creating `FileCheck` tests +// verifying its stdout output, but there are no tests that rely on it, so +// perhaps it should be removed. class CallDumper : public Checker< check::PreCall, check::PostCall > { public: diff --git a/clang/test/Analysis/traversal-algorithm.mm b/clang/test/Analysis/traversal-algorithm.mm deleted file mode 100644 index bdf576063d656..0000000000000 --- a/clang/test/Analysis/traversal-algorithm.mm +++ /dev/null @@ -1,213 +0,0 @@ -// RUN: %clang_analyze_cc1 -analyzer-checker=debug.DumpTraversal -analyzer-max-loop 4 -std=c++11 %s | FileCheck -check-prefix=DFS %s - -int a(); -int b(); -int c(); - -int work(); - -void test(id input) { - if (a()) { - if (a()) - b(); - else - c(); - } else { - if (b()) - a(); - else - c(); - } - - if (a()) - work(); -} - -void testLoops(id input) { - while (a()) { - work(); - work(); - work(); - } - - for (int i = 0; i != b(); ++i) { - work(); - } - - for (id x in input) { - work(); - work(); - work(); - } - - int z[] = {1,2,3}; - for (int y : z) { - work(); - work(); - work(); - } -} - -// This ordering assumes that false cases happen before the true cases. - -// DFS:27 WhileStmt -// DFS-next:33 ForStmt -// DFS-next:37 ObjCForCollectionStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:--END PATH-- -// DFS-next:37 ObjCForCollectionStmt -// DFS-next:37 ObjCForCollectionStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:--END PATH-- -// DFS-next:37 ObjCForCollectionStmt -// DFS-next:37 ObjCForCollectionStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:37 ObjCForCollectionStmt -// DFS-next:37 ObjCForCollectionStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:37 ObjCForCollectionStmt -// DFS-next:33 ForStmt -// DFS-next:37 ObjCForCollectionStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:--END PATH-- -// DFS-next:37 ObjCForCollectionStmt -// DFS-next:33 ForStmt -// DFS-next:37 ObjCForCollectionStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:--END PATH-- -// DFS-next:37 ObjCForCollectionStmt -// DFS-next:33 ForStmt -// DFS-next:37 ObjCForCollectionStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:--END PATH-- -// DFS-next:37 ObjCForCollectionStmt -// DFS-next:27 WhileStmt -// DFS-next:33 ForStmt -// DFS-next:37 ObjCForCollectionStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:--END PATH-- -// DFS-next:37 ObjCForCollectionStmt -// DFS-next:33 ForStmt -// DFS-next:37 ObjCForCollectionStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:--END PATH-- -// DFS-next:37 ObjCForCollectionStmt -// DFS-next:33 ForStmt -// DFS-next:37 ObjCForCollectionStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:--END PATH-- -// DFS-next:37 ObjCForCollectionStmt -// DFS-next:33 ForStmt -// DFS-next:37 ObjCForCollectionStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:--END PATH-- -// DFS-next:37 ObjCForCollectionStmt -// DFS-next:27 WhileStmt -// DFS-next:33 ForStmt -// DFS-next:37 ObjCForCollectionStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:--END PATH-- -// DFS-next:37 ObjCForCollectionStmt -// DFS-next:33 ForStmt -// DFS-next:37 ObjCForCollectionStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:--END PATH-- -// DFS-next:37 ObjCForCollectionStmt -// DFS-next:33 ForStmt -// DFS-next:37 ObjCForCollectionStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:--END PATH-- -// DFS-next:37 ObjCForCollectionStmt -// DFS-next:33 ForStmt -// DFS-next:37 ObjCForCollectionStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:--END PATH-- -// DFS-next:37 ObjCForCollectionStmt -// DFS-next:27 WhileStmt -// DFS-next:33 ForStmt -// DFS-next:37 ObjCForCollectionStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:--END PATH-- -// DFS-next:37 ObjCForCollectionStmt -// DFS-next:33 ForStmt -// DFS-next:37 ObjCForCollectionStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:--END PATH-- -// DFS-next:37 ObjCForCollectionStmt -// DFS-next:33 ForStmt -// DFS-next:37 ObjCForCollectionStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:--END PATH-- -// DFS-next:37 ObjCForCollectionStmt -// DFS-next:33 ForStmt -// DFS-next:37 ObjCForCollectionStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:44 CXXForRangeStmt -// DFS-next:--END PATH-- -// DFS-next:37 ObjCForCollectionStmt -// DFS-next:10 IfStmt -// DFS-next:16 IfStmt -// DFS-next:22 IfStmt -// DFS-next:--END PATH-- -// DFS-next:--END PATH-- -// DFS-next:22 IfStmt -// DFS-next:--END PATH-- -// DFS-next:--END PATH-- -// DFS-next:11 IfStmt -// DFS-next:22 IfStmt -// DFS-next:--END PATH-- -// DFS-next:--END PATH-- -// DFS-next:22 IfStmt -// DFS-next:--END PATH-- -// DFS-next:--END PATH-- -