]> granicus.if.org Git - clang/commitdiff
[analyzer] Use the new registration mechanism for the debugging info "checks".
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Thu, 17 Feb 2011 21:39:39 +0000 (21:39 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Thu, 17 Feb 2011 21:39:39 +0000 (21:39 +0000)
The relative checker package is 'debug':

'-dump-live-variables' is replaced by '-analyzer-checker=debug.DumpLiveVars'
'-cfg-view' is replaced by '-analyzer-checker=debug.ViewCFG'
'-cfg-dump' is replaced by '-analyzer-checker=debug.DumpCFG'

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125780 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Driver/CC1Options.td
include/clang/Frontend/Analyses.def
lib/StaticAnalyzer/Checkers/Checkers.td
lib/StaticAnalyzer/Checkers/DebugCheckers.cpp [new file with mode: 0644]
lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
test/Analysis/auto-obj-dtors-cfg-output.cpp
test/Analysis/dtors-in-dtor-cfg-output.cpp
test/Analysis/initializers-cfg-output.cpp
test/Analysis/temp-obj-dtors-cfg-output.cpp

index 2abbf40161615156f34abff181f3d98e26b7d355..eaeabedc00bdb49ee48916da1c5165e8d8cb16dc 100644 (file)
@@ -36,18 +36,12 @@ def triple_EQ : Joined<"-triple=">, Alias<triple>;
 // Analyzer Options
 //===----------------------------------------------------------------------===//
 
-def analysis_CFGDump : Flag<"-cfg-dump">,
-  HelpText<"Display Control-Flow Graphs">;
-def analysis_CFGView : Flag<"-cfg-view">,
-  HelpText<"View Control-Flow Graphs using GraphViz">;
 def analysis_UnoptimizedCFG : Flag<"-unoptimized-cfg">,
   HelpText<"Generate unoptimized CFGs for all analyses">;
 def analysis_CFGAddImplicitDtors : Flag<"-cfg-add-implicit-dtors">,
   HelpText<"Add C++ implicit destructors to CFGs for all analyses">;
 def analysis_CFGAddInitializers : Flag<"-cfg-add-initializers">,
   HelpText<"Add C++ initializers to CFGs for all analyses">;
-def analysis_DisplayLiveVariables : Flag<"-dump-live-variables">,
-  HelpText<"Print results of live variable analysis">;
 def analysis_WarnUninitVals : Flag<"-warn-uninit-values">,
   HelpText<"Warn about uses of uninitialized variables">;
 def analysis_ObjCMemChecker : Flag<"-analyzer-check-objc-mem">,
index 289ac83cc3544736b7bdaa4442cf6da5e85315ca..75b52a824c63083694a664865f8964fce95af505 100644 (file)
 #define ANALYSIS(NAME, CMDFLAG, DESC, SCOPE)
 #endif
 
-ANALYSIS(CFGDump, "cfg-dump", 
-         "Display Control-Flow Graphs", Code)
-
-ANALYSIS(CFGView, "cfg-view", 
-         "View Control-Flow Graphs using GraphViz", Code)
-
-ANALYSIS(DisplayLiveVariables, "dump-live-variables",
-         "Print results of live variable analysis", Code)
-
 ANALYSIS(WarnUninitVals, "warn-uninit-values",
          "Warn about uses of uninitialized variables", Code)
  
index aabf07a1fc2c59debc8578b541048997c3ce0b89..1dc748666441db6ef400d5226e4a4447b044ff7d 100644 (file)
@@ -28,6 +28,7 @@ def UnixExperimental : Package<"experimental">,
   InPackage<Unix>, Hidden;
 
 def LLVM : Package<"llvm">;
+def Debug : Package<"debug">;
 
 //===----------------------------------------------------------------------===//
 // Groups.
@@ -107,6 +108,21 @@ def LLVMConventionsChecker : Checker<"Conventions">,
   HelpText<"Check code for LLVM codebase conventions">,
   DescFile<"LLVMConventionsChecker.cpp">;
 
+def LiveVariablesDumper : Checker<"DumpLiveVars">,
+  InPackage<Debug>,
+  HelpText<"Print results of live variable analysis">,
+  DescFile<"DebugCheckers.cpp">;
+
+def CFGViewer : Checker<"ViewCFG">,
+  InPackage<Debug>,
+  HelpText<"View Control-Flow Graphs using GraphViz">,
+  DescFile<"DebugCheckers.cpp">;
+
+def CFGDumper : Checker<"DumpCFG">,
+  InPackage<Debug>,
+  HelpText<"Display Control-Flow Graphs">,
+  DescFile<"DebugCheckers.cpp">;
+
 //===----------------------------------------------------------------------===//
 // Hidden experimental checkers.
 //===----------------------------------------------------------------------===//
diff --git a/lib/StaticAnalyzer/Checkers/DebugCheckers.cpp b/lib/StaticAnalyzer/Checkers/DebugCheckers.cpp
new file mode 100644 (file)
index 0000000..091d99b
--- /dev/null
@@ -0,0 +1,80 @@
+//==- 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>();
+}
index a2003c313755d1b757b1c99e06723783ae7c208b..dbfebccee745f5c7c8ec2328f9c9e24abc8a378e 100644 (file)
@@ -407,25 +407,6 @@ static void ActionObjCMemChecker(AnalysisConsumer &C, AnalysisManager& mgr,
  }
 }
 
-static void ActionDisplayLiveVariables(AnalysisConsumer &C,
-                                       AnalysisManager& mgr, Decl *D) {
-  if (LiveVariables* L = mgr.getLiveVariables(D)) {
-    L->dumpBlockLiveness(mgr.getSourceManager());
-  }
-}
-
-static void ActionCFGDump(AnalysisConsumer &C, AnalysisManager& mgr, Decl *D) {
-  if (CFG *cfg = mgr.getCFG(D)) {
-    cfg->dump(mgr.getLangOptions());
-  }
-}
-
-static void ActionCFGView(AnalysisConsumer &C, AnalysisManager& mgr, Decl *D) {
-  if (CFG *cfg = mgr.getCFG(D)) {
-    cfg->viewCFG(mgr.getLangOptions());
-  }
-}
-
 //===----------------------------------------------------------------------===//
 // AnalysisConsumer creation.
 //===----------------------------------------------------------------------===//
index 8185d25563b295bae4208d23b3dcf9c5cddbefdc..315eb121e6880a8ae31b7228c2f12d678ef960c3 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -cfg-dump -cfg-add-implicit-dtors %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=debug.DumpCFG -cfg-add-implicit-dtors %s 2>&1 | FileCheck %s
 // XPASS: *
 
 class A {
index cbf6481a6ba7e0a18d08244a61aad0bc337bfbc8..77654831800300a6bcf2635b6c5ae1087bf65364 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -cfg-dump -cfg-add-implicit-dtors %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=debug.DumpCFG -cfg-add-implicit-dtors %s 2>&1 | FileCheck %s
 // XPASS: *
 
 class A {
index 4576dc7a5c4c2ff787f8965f8d3556b1d944816f..5c5d51494749dce62605ebbe1a61f15207bbb745 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -cfg-dump -cfg-add-initializers %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=debug.DumpCFG -cfg-add-initializers %s 2>&1 | FileCheck %s
 // XPASS: *
 
 class A {
index f30d09fb39f0c331bfd27b701ab9b5842caba0a2..5ed782c690a1d82b91711df8b79d2f46966062bf 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -cfg-dump -cfg-add-implicit-dtors -cfg-add-initializers %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=debug.DumpCFG -cfg-add-implicit-dtors -cfg-add-initializers %s 2>&1 | FileCheck %s
 // XPASS: *
 
 class A {