]> granicus.if.org Git - clang/commitdiff
For the -dealloc checker, check the LangOptions to determine whether or not the code...
authorTed Kremenek <kremenek@apple.com>
Thu, 3 Jul 2008 14:35:01 +0000 (14:35 +0000)
committerTed Kremenek <kremenek@apple.com>
Thu, 3 Jul 2008 14:35:01 +0000 (14:35 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53098 91177308-0d34-0410-b5e6-96231b3b80d8

Driver/AnalysisConsumer.cpp
include/clang/Analysis/LocalCheckers.h
lib/Analysis/CheckObjCDealloc.cpp

index 1dc2fac4f848b699d93159466cb1ad789e100402..44d96a00501b7638fa2d24f740514a055f1c609e 100644 (file)
@@ -385,7 +385,9 @@ static void ActionCFGView(AnalysisManager& mgr) {
 
 static void ActionCheckObjCDealloc(AnalysisManager& mgr) {
   BugReporter BR(mgr);
-  CheckObjCDealloc(cast<ObjCImplementationDecl>(mgr.getCodeDecl()), BR);  
+  
+  CheckObjCDealloc(cast<ObjCImplementationDecl>(mgr.getCodeDecl()), 
+                   mgr.getLangOptions(), BR);  
 }
 
 //===----------------------------------------------------------------------===//
@@ -439,7 +441,8 @@ ASTConsumer* clang::CreateAnalysisConsumer(Analyses* Beg, Analyses* End,
     }
   
   // Checks we always perform:
-  C->addObjCImplementationAction(&ActionCheckObjCDealloc);  
+  if (lopts.getGCMode() != LangOptions::GCOnly)
+    C->addObjCImplementationAction(&ActionCheckObjCDealloc);  
   
   return C.take();
 }
index 08959d3cdf7a50f2f325bc786b5cda889a94a990..acf789dd5b7d5c73ec56b7f3fcfdf6c511d3309a 100644 (file)
@@ -29,6 +29,7 @@ class ParentMap;
 class LiveVariables;
 class BugReporter;
 class ObjCImplementationDecl;
+class LangOptions;
   
 void CheckDeadStores(LiveVariables& L, BugReporter& BR); 
   
@@ -40,7 +41,8 @@ GRTransferFuncs* MakeCFRefCountTF(ASTContext& Ctx, bool GCEnabled,
                                   bool StandardWarnings,
                                   const LangOptions& lopts); 
   
-void CheckObjCDealloc(ObjCImplementationDecl* D, BugReporter& BR);
+void CheckObjCDealloc(ObjCImplementationDecl* D, const LangOptions& L,
+                      BugReporter& BR);
 
   
 } // end namespace clang
index 9a40fa97ec2b7f86492b27a5f4a62a1d79d72bb7..38736dff3deb978740d8bccd0615f0e29452b77e 100644 (file)
@@ -18,6 +18,7 @@
 #include "clang/AST/ExprObjC.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/DeclObjC.h"
+#include "clang/Basic/LangOptions.h"
 #include <sstream>
 
 using namespace clang;
@@ -40,8 +41,11 @@ static bool scan_dealloc(Stmt* S, Selector Dealloc) {
   return false;
 }
 
-void clang::CheckObjCDealloc(ObjCImplementationDecl* D, BugReporter& BR) {
+void clang::CheckObjCDealloc(ObjCImplementationDecl* D,
+                             const LangOptions& LOpts, BugReporter& BR) {
 
+  assert (LOpts.getGCMode() != LangOptions::GCOnly);
+  
   ASTContext& Ctx = BR.getContext();
 
   // Determine if the class subclasses NSObject.
@@ -74,7 +78,10 @@ void clang::CheckObjCDealloc(ObjCImplementationDecl* D, BugReporter& BR) {
   if (!MD) { // No dealloc found.
     
     // FIXME: This code should be reduced to three lines if possible (Refactor).
-    SimpleBugType BT("missing -dealloc");
+    SimpleBugType BT(LOpts.getGCMode() == LangOptions::NonGC 
+                     ? "missing -dealloc" 
+                     : "missing -dealloc (Hybrid MM, non-GC)");
+    
     DiagCollector C(BT);
     
     std::ostringstream os;
@@ -97,12 +104,15 @@ void clang::CheckObjCDealloc(ObjCImplementationDecl* D, BugReporter& BR) {
   if (MD->getBody() && !scan_dealloc(MD->getBody(), S)) {
     
     // FIXME: This code should be reduced to three lines if possible (Refactor).
-    SimpleBugType BT("missing [super dealloc]");
+    SimpleBugType BT(LOpts.getGCMode() == LangOptions::NonGC
+                     ? "missing [super dealloc]"
+                     : "missing [super dealloc] (Hybrid MM, non-GC)");
+                     
     DiagCollector C(BT);
     
     std::ostringstream os;
     os << "The 'dealloc' instance method in Objective-C class '" << D->getName()
-       << "' does not send a 'dealloc' message to it super class"
+       << "' does not send a 'dealloc' message to its super class"
            " (missing [super dealloc])";
     
     Diagnostic& Diag = BR.getDiagnostic();