[cfe-commits] r53098 - in /cfe/trunk: Driver/AnalysisConsumer.cpp include/clang/Analysis/LocalCheckers.h lib/Analysis/CheckObjCDealloc.cpp
Ted Kremenek
kremenek at apple.com
Thu Jul 3 07:35:12 PDT 2008
Author: kremenek
Date: Thu Jul 3 09:35:01 2008
New Revision: 53098
URL: http://llvm.org/viewvc/llvm-project?rev=53098&view=rev
Log:
For the -dealloc checker, check the LangOptions to determine whether or not the code is compiled with GC.
Modified:
cfe/trunk/Driver/AnalysisConsumer.cpp
cfe/trunk/include/clang/Analysis/LocalCheckers.h
cfe/trunk/lib/Analysis/CheckObjCDealloc.cpp
Modified: cfe/trunk/Driver/AnalysisConsumer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/AnalysisConsumer.cpp?rev=53098&r1=53097&r2=53098&view=diff
==============================================================================
--- cfe/trunk/Driver/AnalysisConsumer.cpp (original)
+++ cfe/trunk/Driver/AnalysisConsumer.cpp Thu Jul 3 09:35:01 2008
@@ -385,7 +385,9 @@
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 @@
}
// Checks we always perform:
- C->addObjCImplementationAction(&ActionCheckObjCDealloc);
+ if (lopts.getGCMode() != LangOptions::GCOnly)
+ C->addObjCImplementationAction(&ActionCheckObjCDealloc);
return C.take();
}
Modified: cfe/trunk/include/clang/Analysis/LocalCheckers.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/LocalCheckers.h?rev=53098&r1=53097&r2=53098&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/LocalCheckers.h (original)
+++ cfe/trunk/include/clang/Analysis/LocalCheckers.h Thu Jul 3 09:35:01 2008
@@ -29,6 +29,7 @@
class LiveVariables;
class BugReporter;
class ObjCImplementationDecl;
+class LangOptions;
void CheckDeadStores(LiveVariables& L, BugReporter& BR);
@@ -40,7 +41,8 @@
bool StandardWarnings,
const LangOptions& lopts);
-void CheckObjCDealloc(ObjCImplementationDecl* D, BugReporter& BR);
+void CheckObjCDealloc(ObjCImplementationDecl* D, const LangOptions& L,
+ BugReporter& BR);
} // end namespace clang
Modified: cfe/trunk/lib/Analysis/CheckObjCDealloc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CheckObjCDealloc.cpp?rev=53098&r1=53097&r2=53098&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/CheckObjCDealloc.cpp (original)
+++ cfe/trunk/lib/Analysis/CheckObjCDealloc.cpp Thu Jul 3 09:35:01 2008
@@ -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 @@
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 @@
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 @@
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();
More information about the cfe-commits
mailing list