Skip to content

[analyzer][NFC] Remove check::BranchCondition from debug.DumpTraversal #113906

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 8 additions & 22 deletions clang/lib/StaticAnalyzer/Checkers/TraversalChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<check::BeginFunction, check::EndFunction> {
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<ObjCForCollectionStmt>(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";
}
Expand All @@ -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:
Expand Down
213 changes: 0 additions & 213 deletions clang/test/Analysis/traversal-algorithm.mm

This file was deleted.

Loading