From: George Karpenkov Date: Thu, 6 Sep 2018 23:07:47 +0000 (+0000) Subject: [analyzer] Remove traces of ubigraph visualization X-Git-Tag: llvmorg-8.0.0-rc1~9300 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=95363e378aab20a8093bd22cf8c1a884a8ead039;p=platform%2Fupstream%2Fllvm.git [analyzer] Remove traces of ubigraph visualization 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 llvm-svn: 341601 --- diff --git a/clang/include/clang/Driver/CC1Options.td b/clang/include/clang/Driver/CC1Options.td index cb10b30..d43d69b 100644 --- a/clang/include/clang/Driver/CC1Options.td +++ b/clang/include/clang/Driver/CC1Options.td @@ -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)">; diff --git a/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h b/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h index cb5fc9a..67de75b 100644 --- a/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h +++ b/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h @@ -164,7 +164,6 @@ public: unsigned TrimGraph : 1; unsigned visualizeExplodedGraphWithGraphViz : 1; - unsigned visualizeExplodedGraphWithUbiGraph : 1; unsigned UnoptimizedCFG : 1; unsigned PrintStats : 1; @@ -361,7 +360,7 @@ public: 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 diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h index eb91f4b..50b9b56 100644 --- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h +++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h @@ -100,8 +100,7 @@ public: void FlushDiagnostics(); bool shouldVisualize() const { - return options.visualizeExplodedGraphWithGraphViz || - options.visualizeExplodedGraphWithUbiGraph; + return options.visualizeExplodedGraphWithGraphViz; } bool shouldInlineCall() const { diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h index 4e0c02e..f974ef8 100644 --- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h +++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h @@ -240,18 +240,6 @@ public: return const_cast(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); } diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 7a0e78f..664dff7 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -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); diff --git a/clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp b/clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp index ece103d..68e47af 100644 --- a/clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp +++ b/clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp @@ -36,23 +36,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. //===----------------------------------------------------------------------===// @@ -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) { diff --git a/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp b/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp index 9a6b665..d42e3a9 100644 --- a/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp +++ b/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp @@ -50,8 +50,6 @@ using namespace ento; #define DEBUG_TYPE "AnalysisConsumer" -static std::unique_ptr CreateUbiViz(); - STATISTIC(NumFunctionTopLevel, "The # of functions at top level."); STATISTIC(NumFunctionsAnalyzed, "The # of functions and blocks analyzed (as top level " @@ -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 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); @@ -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 Out; - std::string Filename; - unsigned Cntr; - - typedef llvm::DenseMap VMap; - VMap M; - -public: - UbigraphViz(std::unique_ptr Out, StringRef Filename); - - ~UbigraphViz() override; - - void AddEdge(ExplodedNode *Src, ExplodedNode *Dst) override; -}; - -} // end anonymous namespace - -static std::unique_ptr CreateUbiViz() { - SmallString<128> P; - int FD; - llvm::sys::fs::createTemporaryFile("llvm_ubi", "", FD, P); - llvm::errs() << "Writing '" << P << "'.\n"; - - auto Stream = llvm::make_unique(FD, true); - - return llvm::make_unique(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 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 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); -} diff --git a/clang/test/Analysis/ubigraph-viz.cpp b/clang/test/Analysis/ubigraph-viz.cpp deleted file mode 100644 index 228dd66..0000000 --- a/clang/test/Analysis/ubigraph-viz.cpp +++ /dev/null @@ -1,7 +0,0 @@ -// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.API -analyzer-viz-egraph-ubigraph -verify %s -// expected-no-diagnostics - -int f(int x) { - return x < 0 ? 0 : 42; -} - diff --git a/clang/tools/scan-build-py/libscanbuild/analyze.py b/clang/tools/scan-build-py/libscanbuild/analyze.py index 5a7cc20..ec2ffbb 100644 --- a/clang/tools/scan-build-py/libscanbuild/analyze.py +++ b/clang/tools/scan-build-py/libscanbuild/analyze.py @@ -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) diff --git a/clang/tools/scan-build/libexec/ccc-analyzer b/clang/tools/scan-build/libexec/ccc-analyzer index 73cd2ff..49bffc6 100755 --- a/clang/tools/scan-build/libexec/ccc-analyzer +++ b/clang/tools/scan-build/libexec/ccc-analyzer @@ -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; } diff --git a/clang/utils/analyzer/ubiviz b/clang/utils/analyzer/ubiviz deleted file mode 100755 index 137e130f..0000000 --- a/clang/utils/analyzer/ubiviz +++ /dev/null @@ -1,76 +0,0 @@ -#!/usr/bin/env python -# -# The LLVM Compiler Infrastructure -# -# This file is distributed under the University of Illinois Open Source -# License. See LICENSE.TXT for details. -# -##===--------------------------------------------------------------------===## -# -# This script reads visualization data emitted by the static analyzer for -# display in Ubigraph. -# -##===--------------------------------------------------------------------===## - -import xmlrpclib -import sys - - -def Error(message): - print >> sys.stderr, 'ubiviz: ' + message - sys.exit(1) - - -def StreamData(filename): - file = open(filename) - for ln in file: - yield eval(ln) - file.close() - - -def Display(G, data): - action = data[0] - if action == 'vertex': - vertex = data[1] - G.new_vertex_w_id(vertex) - for attribute in data[2:]: - G.set_vertex_attribute(vertex, attribute[0], attribute[1]) - elif action == 'edge': - src = data[1] - dst = data[2] - edge = G.new_edge(src, dst) - for attribute in data[3:]: - G.set_edge_attribute(edge, attribute[0], attribute[1]) - elif action == "vertex_style": - style_id = data[1] - parent_id = data[2] - G.new_vertex_style_w_id(style_id, parent_id) - for attribute in data[3:]: - G.set_vertex_style_attribute(style_id, attribute[0], attribute[1]) - elif action == "vertex_style_attribute": - style_id = data[1] - for attribute in data[2:]: - G.set_vertex_style_attribute(style_id, attribute[0], attribute[1]) - elif action == "change_vertex_style": - vertex_id = data[1] - style_id = data[2] - G.change_vertex_style(vertex_id, style_id) - - -def main(args): - if len(args) == 0: - Error('no input files') - - server = xmlrpclib.Server('http://127.0.0.1:20738/RPC2') - G = server.ubigraph - - for arg in args: - G.clear() - for x in StreamData(arg): - Display(G, x) - - sys.exit(0) - - -if __name__ == '__main__': - main(sys.argv[1:])