forked from OSchip/llvm-project
81 lines
2.4 KiB
C++
81 lines
2.4 KiB
C++
//==- DebugCheckers.cpp - Debugging Checkers ---------------------*- C++ -*-==//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file defines a checkers that display debugging information.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "ClangSACheckers.h"
|
|
#include "clang/StaticAnalyzer/Core/CheckerV2.h"
|
|
#include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h"
|
|
#include "clang/Analysis/Analyses/LiveVariables.h"
|
|
|
|
using namespace clang;
|
|
using namespace ento;
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// LiveVariablesDumper
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace {
|
|
class LiveVariablesDumper : public CheckerV2<check::ASTCodeBody> {
|
|
public:
|
|
void checkASTCodeBody(const Decl *D, AnalysisManager& mgr,
|
|
BugReporter &BR) const {
|
|
if (LiveVariables* L = mgr.getLiveVariables(D)) {
|
|
L->dumpBlockLiveness(mgr.getSourceManager());
|
|
}
|
|
}
|
|
};
|
|
}
|
|
|
|
void ento::registerLiveVariablesDumper(CheckerManager &mgr) {
|
|
mgr.registerChecker<LiveVariablesDumper>();
|
|
}
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// CFGViewer
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace {
|
|
class CFGViewer : public CheckerV2<check::ASTCodeBody> {
|
|
public:
|
|
void checkASTCodeBody(const Decl *D, AnalysisManager& mgr,
|
|
BugReporter &BR) const {
|
|
if (CFG *cfg = mgr.getCFG(D)) {
|
|
cfg->viewCFG(mgr.getLangOptions());
|
|
}
|
|
}
|
|
};
|
|
}
|
|
|
|
void ento::registerCFGViewer(CheckerManager &mgr) {
|
|
mgr.registerChecker<CFGViewer>();
|
|
}
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// CFGDumper
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace {
|
|
class CFGDumper : public CheckerV2<check::ASTCodeBody> {
|
|
public:
|
|
void checkASTCodeBody(const Decl *D, AnalysisManager& mgr,
|
|
BugReporter &BR) const {
|
|
if (CFG *cfg = mgr.getCFG(D)) {
|
|
cfg->dump(mgr.getLangOptions());
|
|
}
|
|
}
|
|
};
|
|
}
|
|
|
|
void ento::registerCFGDumper(CheckerManager &mgr) {
|
|
mgr.registerChecker<CFGDumper>();
|
|
}
|