Skip to content

Commit

Permalink
[analyzer] Remove traces of ubigraph visualization
Browse files Browse the repository at this point in the history
Ubigraph project has been dead since about 2008, and to the best of my
knowledge, no one was using it.
Previously, I wasn't able to launch the existing binary at all.

Differential Revision: https://reviews.llvm.org/D51655

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@341601 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
George Karpenkov committed Sep 6, 2018
1 parent cc7b758 commit 4d1df0a
Show file tree
Hide file tree
Showing 11 changed files with 2 additions and 238 deletions.
2 changes: 0 additions & 2 deletions include/clang/Driver/CC1Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ def trim_egraph : Flag<["-"], "trim-egraph">,
HelpText<"Only show error-related paths in the analysis graph">;
def analyzer_viz_egraph_graphviz : Flag<["-"], "analyzer-viz-egraph-graphviz">,
HelpText<"Display exploded graph using GraphViz">;
def analyzer_viz_egraph_ubigraph : Flag<["-"], "analyzer-viz-egraph-ubigraph">,
HelpText<"Display exploded graph using Ubigraph">;

def analyzer_inline_max_stack_depth : Separate<["-"], "analyzer-inline-max-stack-depth">,
HelpText<"Bound on stack depth while inlining (4 by default)">;
Expand Down
3 changes: 1 addition & 2 deletions include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ class AnalyzerOptions : public RefCountedBase<AnalyzerOptions> {

unsigned TrimGraph : 1;
unsigned visualizeExplodedGraphWithGraphViz : 1;
unsigned visualizeExplodedGraphWithUbiGraph : 1;
unsigned UnoptimizedCFG : 1;
unsigned PrintStats : 1;

Expand Down Expand Up @@ -361,7 +360,7 @@ class AnalyzerOptions : public RefCountedBase<AnalyzerOptions> {
AnalyzerDisplayProgress(false), AnalyzeNestedBlocks(false),
eagerlyAssumeBinOpBifurcation(false), TrimGraph(false),
visualizeExplodedGraphWithGraphViz(false),
visualizeExplodedGraphWithUbiGraph(false), UnoptimizedCFG(false),
UnoptimizedCFG(false),
PrintStats(false), NoRetryExhausted(false), CXXMemberInliningMode() {}

/// Interprets an option's string value as a boolean. The "true" string is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ class AnalysisManager : public BugReporterData {
void FlushDiagnostics();

bool shouldVisualize() const {
return options.visualizeExplodedGraphWithGraphViz ||
options.visualizeExplodedGraphWithUbiGraph;
return options.visualizeExplodedGraphWithGraphViz;
}

bool shouldInlineCall() const {
Expand Down
12 changes: 0 additions & 12 deletions include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,18 +240,6 @@ class ExplodedNode : public llvm::FoldingSetNode {
return const_cast<ExplodedNode*>(this)->succ_end();
}

// For debugging.

public:
class Auditor {
public:
virtual ~Auditor();

virtual void AddEdge(ExplodedNode *Src, ExplodedNode *Dst) = 0;
};

static void SetAuditor(Auditor* A);

private:
void replaceSuccessor(ExplodedNode *node) { Succs.replaceNode(node); }
void replacePredecessor(ExplodedNode *node) { Preds.replaceNode(node); }
Expand Down
2 changes: 0 additions & 2 deletions lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,6 @@ static bool ParseAnalyzerArgs(AnalyzerOptions &Opts, ArgList &Args,

Opts.visualizeExplodedGraphWithGraphViz =
Args.hasArg(OPT_analyzer_viz_egraph_graphviz);
Opts.visualizeExplodedGraphWithUbiGraph =
Args.hasArg(OPT_analyzer_viz_egraph_ubigraph);
Opts.NoRetryExhausted = Args.hasArg(OPT_analyzer_disable_retry_exhausted);
Opts.AnalyzeAll = Args.hasArg(OPT_analyzer_opt_analyze_headers);
Opts.AnalyzerDisplayProgress = Args.hasArg(OPT_analyzer_display_progress);
Expand Down
20 changes: 0 additions & 20 deletions lib/StaticAnalyzer/Core/ExplodedGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,6 @@
using namespace clang;
using namespace ento;

//===----------------------------------------------------------------------===//
// Node auditing.
//===----------------------------------------------------------------------===//

// An out of line virtual method to provide a home for the class vtable.
ExplodedNode::Auditor::~Auditor() = default;

#ifndef NDEBUG
static ExplodedNode::Auditor* NodeAuditor = nullptr;
#endif

void ExplodedNode::SetAuditor(ExplodedNode::Auditor* A) {
#ifndef NDEBUG
NodeAuditor = A;
#endif
}

//===----------------------------------------------------------------------===//
// Cleanup.
//===----------------------------------------------------------------------===//
Expand Down Expand Up @@ -224,9 +207,6 @@ void ExplodedNode::addPredecessor(ExplodedNode *V, ExplodedGraph &G) {
assert(!V->isSink());
Preds.addNode(V, G);
V->Succs.addNode(this, G);
#ifndef NDEBUG
if (NodeAuditor) NodeAuditor->AddEdge(V, this);
#endif
}

void ExplodedNode::NodeGroup::replaceNode(ExplodedNode *node) {
Expand Down
108 changes: 0 additions & 108 deletions lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ using namespace ento;

#define DEBUG_TYPE "AnalysisConsumer"

static std::unique_ptr<ExplodedNode::Auditor> CreateUbiViz();

STATISTIC(NumFunctionTopLevel, "The # of functions at top level.");
STATISTIC(NumFunctionsAnalyzed,
"The # of functions and blocks analyzed (as top level "
Expand Down Expand Up @@ -743,21 +741,10 @@ void AnalysisConsumer::ActionExprEngine(Decl *D, bool ObjCGCEnabled,
ExprEngine Eng(CTU, *Mgr, ObjCGCEnabled, VisitedCallees, &FunctionSummaries,
IMode);

// Set the graph auditor.
std::unique_ptr<ExplodedNode::Auditor> Auditor;
if (Mgr->options.visualizeExplodedGraphWithUbiGraph) {
Auditor = CreateUbiViz();
ExplodedNode::SetAuditor(Auditor.get());
}

// Execute the worklist algorithm.
Eng.ExecuteWorkList(Mgr->getAnalysisDeclContextManager().getStackFrame(D),
Mgr->options.getMaxNodesPerTopLevelFunction());

// Release the auditor (if any) so that it doesn't monitor the graph
// created BugReporter.
ExplodedNode::SetAuditor(nullptr);

// Visualize the exploded graph.
if (Mgr->options.visualizeExplodedGraphWithGraphViz)
Eng.ViewGraph(Mgr->options.TrimGraph);
Expand Down Expand Up @@ -803,98 +790,3 @@ ento::CreateAnalysisConsumer(CompilerInstance &CI) {
CI.getFrontendOpts().Plugins,
hasModelPath ? new ModelInjector(CI) : nullptr);
}

//===----------------------------------------------------------------------===//
// Ubigraph Visualization. FIXME: Move to separate file.
//===----------------------------------------------------------------------===//

namespace {

class UbigraphViz : public ExplodedNode::Auditor {
std::unique_ptr<raw_ostream> Out;
std::string Filename;
unsigned Cntr;

typedef llvm::DenseMap<void*,unsigned> VMap;
VMap M;

public:
UbigraphViz(std::unique_ptr<raw_ostream> Out, StringRef Filename);

~UbigraphViz() override;

void AddEdge(ExplodedNode *Src, ExplodedNode *Dst) override;
};

} // end anonymous namespace

static std::unique_ptr<ExplodedNode::Auditor> CreateUbiViz() {
SmallString<128> P;
int FD;
llvm::sys::fs::createTemporaryFile("llvm_ubi", "", FD, P);
llvm::errs() << "Writing '" << P << "'.\n";

auto Stream = llvm::make_unique<llvm::raw_fd_ostream>(FD, true);

return llvm::make_unique<UbigraphViz>(std::move(Stream), P);
}

void UbigraphViz::AddEdge(ExplodedNode *Src, ExplodedNode *Dst) {

assert (Src != Dst && "Self-edges are not allowed.");

// Lookup the Src. If it is a new node, it's a root.
VMap::iterator SrcI= M.find(Src);
unsigned SrcID;

if (SrcI == M.end()) {
M[Src] = SrcID = Cntr++;
*Out << "('vertex', " << SrcID << ", ('color','#00ff00'))\n";
}
else
SrcID = SrcI->second;

// Lookup the Dst.
VMap::iterator DstI= M.find(Dst);
unsigned DstID;

if (DstI == M.end()) {
M[Dst] = DstID = Cntr++;
*Out << "('vertex', " << DstID << ")\n";
}
else {
// We have hit DstID before. Change its style to reflect a cache hit.
DstID = DstI->second;
*Out << "('change_vertex_style', " << DstID << ", 1)\n";
}

// Add the edge.
*Out << "('edge', " << SrcID << ", " << DstID
<< ", ('arrow','true'), ('oriented', 'true'))\n";
}

UbigraphViz::UbigraphViz(std::unique_ptr<raw_ostream> OutStream,
StringRef Filename)
: Out(std::move(OutStream)), Filename(Filename), Cntr(0) {

*Out << "('vertex_style_attribute', 0, ('shape', 'icosahedron'))\n";
*Out << "('vertex_style', 1, 0, ('shape', 'sphere'), ('color', '#ffcc66'),"
" ('size', '1.5'))\n";
}

UbigraphViz::~UbigraphViz() {
Out.reset();
llvm::errs() << "Running 'ubiviz' program... ";
std::string ErrMsg;
std::string Ubiviz;
if (auto Path = llvm::sys::findProgramByName("ubiviz"))
Ubiviz = *Path;
std::array<StringRef, 2> Args{{Ubiviz, Filename}};

if (llvm::sys::ExecuteAndWait(Ubiviz, Args, llvm::None, {}, 0, 0, &ErrMsg)) {
llvm::errs() << "Error viewing graph: " << ErrMsg << "\n";
}

// Delete the file.
llvm::sys::fs::remove(Filename);
}
7 changes: 0 additions & 7 deletions test/Analysis/ubigraph-viz.cpp

This file was deleted.

2 changes: 0 additions & 2 deletions tools/scan-build-py/libscanbuild/analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,6 @@ def analyzer_params(args):
if args.disable_checker:
checkers = ','.join(args.disable_checker)
result.extend(['-analyzer-disable-checker', checkers])
if os.getenv('UBIVIZ'):
result.append('-analyzer-viz-egraph-ubigraph')

return prefix_with('-Xclang', result)

Expand Down
5 changes: 0 additions & 5 deletions tools/scan-build/libexec/ccc-analyzer
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,6 @@ sub Analyze {
push @Args, "-Xclang", $arg;
}

# Display Ubiviz graph?
if (defined $ENV{'CCC_UBI'}) {
push @Args, "-Xclang", "-analyzer-viz-egraph-ubigraph";
}

if (defined $AnalyzerTarget) {
push @Args, "-target", $AnalyzerTarget;
}
Expand Down
76 changes: 0 additions & 76 deletions utils/analyzer/ubiviz

This file was deleted.

0 comments on commit 4d1df0a

Please sign in to comment.