aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/CheckObjCDealloc.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-07-14 17:40:50 +0000
committerTed Kremenek <kremenek@apple.com>2008-07-14 17:40:50 +0000
commit57202071e477530e9348bc76671ee369b2399b92 (patch)
tree2dfdcffb6b502a7ddc7f991f48a5433a851965a8 /lib/Analysis/CheckObjCDealloc.cpp
parentca33f79346547cf1865c47b53ee99a6cdef07c72 (diff)
Added method "EmitBasicReport" to BugReporter to simplify the emission of simple bug diagnostics.
Refactored error reporting in CheckObjCDealloc and CheckObjCInstMethSignature to use this new bug reporting interface (major code simplification). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53560 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/CheckObjCDealloc.cpp')
-rw-r--r--lib/Analysis/CheckObjCDealloc.cpp43
1 files changed, 11 insertions, 32 deletions
diff --git a/lib/Analysis/CheckObjCDealloc.cpp b/lib/Analysis/CheckObjCDealloc.cpp
index 3e21f016df..0c9100951c 100644
--- a/lib/Analysis/CheckObjCDealloc.cpp
+++ b/lib/Analysis/CheckObjCDealloc.cpp
@@ -83,8 +83,7 @@ void clang::CheckObjCDealloc(ObjCImplementationDecl* D,
// Get the "dealloc" selector.
IdentifierInfo* II = &Ctx.Idents.get("dealloc");
- Selector S = Ctx.Selectors.getSelector(0, &II);
-
+ Selector S = Ctx.Selectors.getSelector(0, &II);
ObjCMethodDecl* MD = 0;
// Scan the instance methods for "dealloc".
@@ -99,52 +98,32 @@ void clang::CheckObjCDealloc(ObjCImplementationDecl* D,
if (!MD) { // No dealloc found.
- // FIXME: This code should be reduced to three lines if possible (Refactor).
- SimpleBugType BT(LOpts.getGCMode() == LangOptions::NonGC
- ? "missing -dealloc"
- : "missing -dealloc (Hybrid MM, non-GC)");
-
- DiagCollector C(BT);
+ const char* name = LOpts.getGCMode() == LangOptions::NonGC
+ ? "missing -dealloc"
+ : "missing -dealloc (Hybrid MM, non-GC)";
std::ostringstream os;
os << "Objective-C class '" << D->getName()
<< "' lacks a 'dealloc' instance method";
- Diagnostic& Diag = BR.getDiagnostic();
- Diag.Report(&C,
- Ctx.getFullLoc(D->getLocStart()),
- Diag.getCustomDiagID(Diagnostic::Warning, os.str().c_str()),
- NULL, 0, NULL, 0);
-
- for (DiagCollector::iterator I = C.begin(), E = C.end(); I != E; ++I)
- BR.EmitWarning(*I);
-
+ BR.EmitBasicReport(name, os.str().c_str(), D->getLocStart());
return;
}
// dealloc found. Scan for missing [super dealloc].
if (MD->getBody() && !scan_dealloc(MD->getBody(), S)) {
- // FIXME: This code should be reduced to three lines if possible (Refactor).
- SimpleBugType BT(LOpts.getGCMode() == LangOptions::NonGC
- ? "missing [super dealloc]"
- : "missing [super dealloc] (Hybrid MM, non-GC)");
-
- DiagCollector C(BT);
+ const char* name = LOpts.getGCMode() == LangOptions::NonGC
+ ? "missing [super dealloc]"
+ : "missing [super dealloc] (Hybrid MM, non-GC)";
std::ostringstream os;
os << "The 'dealloc' instance method in Objective-C class '" << D->getName()
<< "' does not send a 'dealloc' message to its super class"
" (missing [super dealloc])";
- Diagnostic& Diag = BR.getDiagnostic();
- Diag.Report(&C,
- Ctx.getFullLoc(MD->getLocStart()),
- Diag.getCustomDiagID(Diagnostic::Warning, os.str().c_str()),
- NULL, 0, NULL, 0);
-
- for (DiagCollector::iterator I = C.begin(), E = C.end(); I != E; ++I)
- BR.EmitWarning(*I);
- }
+ BR.EmitBasicReport(name, os.str().c_str(), D->getLocStart());
+ return;
+ }
}