[cfe-commits] r53575 - in /cfe/trunk/Driver: Analyses.def AnalysisConsumer.cpp AnalysisConsumer.h clang.cpp

Ted Kremenek kremenek at apple.com
Mon Jul 14 16:41:14 PDT 2008


Author: kremenek
Date: Mon Jul 14 18:41:13 2008
New Revision: 53575

URL: http://llvm.org/viewvc/llvm-project?rev=53575&view=rev
Log:
Break off declaration of Analysis enum into Analyses.def. The driver options in
clang.cpp now #include these definitions to create the command line options, and
AnalysisConsumer #includes this file to generate the switch statement to create
actions.

Renamed -check-objc-methodsigs to -warn-objc-methodsigs.

The "missing -dealloc" check is now optional: -warn-objc-missing-dealloc

Added:
    cfe/trunk/Driver/Analyses.def
Modified:
    cfe/trunk/Driver/AnalysisConsumer.cpp
    cfe/trunk/Driver/AnalysisConsumer.h
    cfe/trunk/Driver/clang.cpp

Added: cfe/trunk/Driver/Analyses.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/Analyses.def?rev=53575&view=auto

==============================================================================
--- cfe/trunk/Driver/Analyses.def (added)
+++ cfe/trunk/Driver/Analyses.def Mon Jul 14 18:41:13 2008
@@ -0,0 +1,41 @@
+//===-- Analyses.def - Metadata about Static Analyses -----------*- 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 the set of static analyses used by AnalysisConsumer.
+//
+//===----------------------------------------------------------------------===//
+
+ANALYSIS(CFGDump, "cfg-dump",
+         "Display Control-Flow Graphs")
+
+ANALYSIS(CFGView, "cfg-view",
+         "View Control-Flow Graphs using GraphViz")
+
+ANALYSIS(DisplayLiveVariables, "dump-live-variables",
+         "Print results of live variable analysis")
+
+ANALYSIS(WarnDeadStores, "warn-dead-stores",
+         "Warn about stores to dead variables")
+
+ANALYSIS(WarnUninitVals, "warn-uninit-values",
+         "Warn about uses of uninitialized variables")
+
+ANALYSIS(WarnObjCMethSigs, "warn-objc-methodsigs",
+"Warn about Objective-C method signatures with type incompatibilities")
+
+ANALYSIS(WarnObjCDealloc, "warn-objc-missing-dealloc",
+"Warn about Objective-C classes that lack a correct implementation of -dealloc")
+
+ANALYSIS(CheckerSimple, "checker-simple",
+         "Perform simple path-sensitive checks.")
+
+ANALYSIS(CheckerCFRef, "checker-cfref",
+         "Run the [Core] Foundation reference count checker")   
+
+#undef ANALYSIS

Modified: cfe/trunk/Driver/AnalysisConsumer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/AnalysisConsumer.cpp?rev=53575&r1=53574&r2=53575&view=diff

==============================================================================
--- cfe/trunk/Driver/AnalysisConsumer.cpp (original)
+++ cfe/trunk/Driver/AnalysisConsumer.cpp Mon Jul 14 18:41:13 2008
@@ -41,11 +41,9 @@
 // Basic type definitions.
 //===----------------------------------------------------------------------===//
 
-namespace {
-  
+namespace {  
   class AnalysisManager;
-  typedef void (*CodeAction)(AnalysisManager& Mgr);    
-
+  typedef void (*CodeAction)(AnalysisManager& Mgr);
 } // end anonymous namespace
 
 //===----------------------------------------------------------------------===//
@@ -287,14 +285,14 @@
 // Analyses
 //===----------------------------------------------------------------------===//
 
-static void ActionDeadStores(AnalysisManager& mgr) {
+static void ActionWarnDeadStores(AnalysisManager& mgr) {
   if (LiveVariables* L = mgr.getLiveVariables()) {
     BugReporter BR(mgr);
     CheckDeadStores(*L, BR);
   }
 }
 
-static void ActionUninitVals(AnalysisManager& mgr) {
+static void ActionWarnUninitVals(AnalysisManager& mgr) {
   if (CFG* c = mgr.getCFG())
     CheckUninitializedValues(*c, mgr.getContext(), mgr.getDiagnostic());
 }
@@ -327,7 +325,7 @@
     Eng.ViewGraph(mgr.shouldTrimGraph());
 }
 
-static void ActionRefLeakCheckerAux(AnalysisManager& mgr, bool GCEnabled,
+static void ActionCheckerCFRefAux(AnalysisManager& mgr, bool GCEnabled,
                                     bool StandardWarnings) {
 
   GRTransferFuncs* TF = MakeCFRefCountTF(mgr.getContext(),
@@ -338,31 +336,31 @@
   ActionGRExprEngine(mgr, TF);
 }
 
-static void ActionRefLeakChecker(AnalysisManager& mgr) {
+static void ActionCheckerCFRef(AnalysisManager& mgr) {
      
  switch (mgr.getLangOptions().getGCMode()) {
    default:
      assert (false && "Invalid GC mode.");
    case LangOptions::NonGC:
-     ActionRefLeakCheckerAux(mgr, false, true);
+     ActionCheckerCFRefAux(mgr, false, true);
      break;
     
    case LangOptions::GCOnly:
-     ActionRefLeakCheckerAux(mgr, true, true);
+     ActionCheckerCFRefAux(mgr, true, true);
      break;
      
    case LangOptions::HybridGC:
-     ActionRefLeakCheckerAux(mgr, false, true);
-     ActionRefLeakCheckerAux(mgr, true, false);
+     ActionCheckerCFRefAux(mgr, false, true);
+     ActionCheckerCFRefAux(mgr, true, false);
      break;
  }
 }
 
-static void ActionSimpleChecks(AnalysisManager& mgr) {
+static void ActionCheckerSimple(AnalysisManager& mgr) {
   ActionGRExprEngine(mgr, MakeGRSimpleValsTF());
 }
 
-static void ActionLiveness(AnalysisManager& mgr) {
+static void ActionDisplayLiveVariables(AnalysisManager& mgr) {
   if (LiveVariables* L = mgr.getLiveVariables()) {
     mgr.DisplayFunction();  
     L->dumpBlockLiveness(mgr.getSourceManager());
@@ -383,14 +381,14 @@
   }
 }
 
-static void ActionCheckObjCDealloc(AnalysisManager& mgr) {
+static void ActionWarnObjCDealloc(AnalysisManager& mgr) {
   BugReporter BR(mgr);
   
   CheckObjCDealloc(cast<ObjCImplementationDecl>(mgr.getCodeDecl()), 
                    mgr.getLangOptions(), BR);  
 }
 
-static void ActionCheckObjCInstMethSignature(AnalysisManager& mgr) {
+static void ActionWarnObjCMethSigs(AnalysisManager& mgr) {
   BugReporter BR(mgr);
   
   CheckObjCInstMethSignature(cast<ObjCImplementationDecl>(mgr.getCodeDecl()),
@@ -416,45 +414,14 @@
   
   for ( ; Beg != End ; ++Beg)
     switch (*Beg) {
-      case WarnDeadStores:
-        C->addCodeAction(&ActionDeadStores);
-        break;
-        
-      case WarnUninitVals:
-        C->addCodeAction(&ActionUninitVals);
+#define ANALYSIS(NAME, CMD, DESC)\
+      case NAME:\
+        C->addCodeAction(&Action ## NAME);\
         break;
-        
-      case CheckObjCMethSigs:
-        C->addObjCImplementationAction(&ActionCheckObjCInstMethSignature);
-        break;
-      
-      case DisplayLiveVariables:
-        C->addCodeAction(&ActionLiveness);
-        break;
-        
-      case CheckerCFRef:
-        C->addCodeAction(&ActionRefLeakChecker);
-        break;
-        
-      case CheckerSimple:
-        C->addCodeAction(&ActionSimpleChecks);
-        break;
-        
-      case CFGDump:
-        C->addCodeAction(&ActionCFGDump);
-        break;
-        
-      case CFGView:
-        C->addCodeAction(&ActionCFGView);
-        break;
-        
+#include "Analyses.def"
       default: break;
     }
   
-  // Checks we always perform:
-  if (lopts.getGCMode() != LangOptions::GCOnly)
-    C->addObjCImplementationAction(&ActionCheckObjCDealloc);
-    
   return C.take();
 }
 

Modified: cfe/trunk/Driver/AnalysisConsumer.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/AnalysisConsumer.h?rev=53575&r1=53574&r2=53575&view=diff

==============================================================================
--- cfe/trunk/Driver/AnalysisConsumer.h (original)
+++ cfe/trunk/Driver/AnalysisConsumer.h Mon Jul 14 18:41:13 2008
@@ -17,16 +17,11 @@
 namespace clang {
 
 enum Analyses {
-  CFGDump,
-  CFGView,
-  WarnDeadStores,
-  WarnUninitVals,
-  DisplayLiveVariables,
-  CheckerCFRef,
-  CheckerSimple,
-  CheckObjCMethSigs
+#define ANALYSIS(NAME, CMDFLAG, DESC) NAME,
+#include "Analyses.def"
+NumAnalyses
 };
-  
+
 ASTConsumer* CreateAnalysisConsumer(Analyses* Beg, Analyses* End,
                                     Diagnostic &diags, Preprocessor* pp,
                                     PreprocessorFactory* ppf,

Modified: cfe/trunk/Driver/clang.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/clang.cpp?rev=53575&r1=53574&r2=53575&view=diff

==============================================================================
--- cfe/trunk/Driver/clang.cpp (original)
+++ cfe/trunk/Driver/clang.cpp Mon Jul 14 18:41:13 2008
@@ -162,21 +162,10 @@
 static llvm::cl::list<Analyses>
 AnalysisList(llvm::cl::desc("Available Source Code Analyses:"),
 llvm::cl::values(
-clEnumValN(CFGDump, "cfg-dump", "Display Control-Flow Graphs"),
-clEnumValN(CFGView, "cfg-view", "View Control-Flow Graphs using GraphViz"),
-clEnumValN(DisplayLiveVariables, "dump-live-variables",
-           "Print results of live variable analysis"),
-clEnumValN(WarnDeadStores, "warn-dead-stores",
-           "Flag warnings of stores to dead variables"),
-clEnumValN(WarnUninitVals, "warn-uninit-values",
-           "Flag warnings of uses of unitialized variables"),
-clEnumValN(CheckObjCMethSigs, "check-objc-methodsigs",
-      "Check the Objective-C method signatures for type incompatibilities."),
-clEnumValN(CheckerSimple, "checker-simple",
-           "Perform simple path-sensitive checks."),
-clEnumValN(CheckerCFRef, "checker-cfref",
-           "Run the [Core] Foundation reference count checker"),   
-clEnumValEnd));          
+#define ANALYSIS(NAME, CMDFLAG, DESC)\
+clEnumValN(NAME, CMDFLAG, DESC),
+#include "Analyses.def"
+clEnumValEnd));
 
 //===----------------------------------------------------------------------===//
 // Language Options





More information about the cfe-commits mailing list