diff options
| author | Ted Kremenek <kremenek@apple.com> | 2008-07-03 14:35:01 +0000 |
|---|---|---|
| committer | Ted Kremenek <kremenek@apple.com> | 2008-07-03 14:35:01 +0000 |
| commit | e66ca6f35af8ff74f04c54b3ea262efcda8f681c (patch) | |
| tree | 8b477e16a5d6ca67215db982c4f3b3f370829ccf /clang/lib/Analysis/CheckObjCDealloc.cpp | |
| parent | 7d98a48f15c208f6b0ccfd772284a2d2738a9b98 (diff) | |
| download | bcm5719-llvm-e66ca6f35af8ff74f04c54b3ea262efcda8f681c.tar.gz bcm5719-llvm-e66ca6f35af8ff74f04c54b3ea262efcda8f681c.zip | |
For the -dealloc checker, check the LangOptions to determine whether or not the code is compiled with GC.
llvm-svn: 53098
Diffstat (limited to 'clang/lib/Analysis/CheckObjCDealloc.cpp')
| -rw-r--r-- | clang/lib/Analysis/CheckObjCDealloc.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/clang/lib/Analysis/CheckObjCDealloc.cpp b/clang/lib/Analysis/CheckObjCDealloc.cpp index 9a40fa97ec2..38736dff3de 100644 --- a/clang/lib/Analysis/CheckObjCDealloc.cpp +++ b/clang/lib/Analysis/CheckObjCDealloc.cpp @@ -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(); |

