Skip to content

Commit e40a31b

Browse files
authored
[analyzer][NFC] Remove check::BranchCondition from debug.DumpTraversal (#113906)
This commit removes the `check::BranchCondition` callback of the debug checker `debug.DumpTraversal` (in `TraversalChecker.cpp`) and the single broken testcase that was referring to it. The testcase `traversal-algorithm.mm` was added in 2012 to verify that we're using DFS traversal -- however it failed to detect that we're no longer using DFS traversal and in fact it continues to pass even if I remove large random portions of its code. This change was motivated by the plan discussed at https://discourse.llvm.org/t/fixing-or-removing-check-branchcondition/82738 I also added some TODO notes to mark the rest of `TraversalChecker.cpp` for removal in follow-up commits.
1 parent 16cd5cd commit e40a31b

File tree

2 files changed

+8
-235
lines changed

2 files changed

+8
-235
lines changed

clang/lib/StaticAnalyzer/Checkers/TraversalChecker.cpp

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,34 +23,17 @@ using namespace clang;
2323
using namespace ento;
2424

2525
namespace {
26-
class TraversalDumper : public Checker< check::BranchCondition,
27-
check::BeginFunction,
28-
check::EndFunction > {
26+
// TODO: This checker is only referenced from two small test files and it
27+
// doesn't seem to be useful for manual debugging, so consider reimplementing
28+
// those tests with more modern tools and removing this checker.
29+
class TraversalDumper
30+
: public Checker<check::BeginFunction, check::EndFunction> {
2931
public:
30-
void checkBranchCondition(const Stmt *Condition, CheckerContext &C) const;
3132
void checkBeginFunction(CheckerContext &C) const;
3233
void checkEndFunction(const ReturnStmt *RS, CheckerContext &C) const;
3334
};
3435
}
3536

36-
void TraversalDumper::checkBranchCondition(const Stmt *Condition,
37-
CheckerContext &C) const {
38-
// Special-case Objective-C's for-in loop, which uses the entire loop as its
39-
// condition. We just print the collection expression.
40-
const Stmt *Parent = dyn_cast<ObjCForCollectionStmt>(Condition);
41-
if (!Parent) {
42-
const ParentMap &Parents = C.getLocationContext()->getParentMap();
43-
Parent = Parents.getParent(Condition);
44-
}
45-
46-
// It is mildly evil to print directly to llvm::outs() rather than emitting
47-
// warnings, but this ensures things do not get filtered out by the rest of
48-
// the static analyzer machinery.
49-
SourceLocation Loc = Parent->getBeginLoc();
50-
llvm::outs() << C.getSourceManager().getSpellingLineNumber(Loc) << " "
51-
<< Parent->getStmtClassName() << "\n";
52-
}
53-
5437
void TraversalDumper::checkBeginFunction(CheckerContext &C) const {
5538
llvm::outs() << "--BEGIN FUNCTION--\n";
5639
}
@@ -71,6 +54,9 @@ bool ento::shouldRegisterTraversalDumper(const CheckerManager &mgr) {
7154
//------------------------------------------------------------------------------
7255

7356
namespace {
57+
// TODO: This checker appears to be a utility for creating `FileCheck` tests
58+
// verifying its stdout output, but there are no tests that rely on it, so
59+
// perhaps it should be removed.
7460
class CallDumper : public Checker< check::PreCall,
7561
check::PostCall > {
7662
public:

clang/test/Analysis/traversal-algorithm.mm

Lines changed: 0 additions & 213 deletions
This file was deleted.

0 commit comments

Comments
 (0)