[cfe-commits] r49552 - /cfe/trunk/lib/Analysis/CFRefCount.cpp
Ted Kremenek
kremenek at apple.com
Fri Apr 11 11:40:51 PDT 2008
Author: kremenek
Date: Fri Apr 11 13:40:51 2008
New Revision: 49552
URL: http://llvm.org/viewvc/llvm-project?rev=49552&view=rev
Log:
Use RangedBugReport to report better ranges for reference count errors.
Modified:
cfe/trunk/lib/Analysis/CFRefCount.cpp
Modified: cfe/trunk/lib/Analysis/CFRefCount.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFRefCount.cpp?rev=49552&r1=49551&r2=49552&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/CFRefCount.cpp (original)
+++ cfe/trunk/lib/Analysis/CFRefCount.cpp Fri Apr 11 13:40:51 2008
@@ -538,8 +538,8 @@
typedef llvm::ImmutableMap<SymbolID, RefVal> RefBindings;
typedef RefBindings::Factory RefBFactoryTy;
- typedef llvm::SmallPtrSet<GRExprEngine::NodeTy*,2> UseAfterReleasesTy;
- typedef llvm::SmallPtrSet<GRExprEngine::NodeTy*,2> ReleasesNotOwnedTy;
+ typedef llvm::DenseMap<GRExprEngine::NodeTy*,Expr*> UseAfterReleasesTy;
+ typedef llvm::DenseMap<GRExprEngine::NodeTy*,Expr*> ReleasesNotOwnedTy;
class BindingsPrinter : public ValueState::CheckerStatePrinter {
public:
@@ -704,8 +704,10 @@
unsigned idx = 0;
- for (CallExpr::arg_iterator I=CE->arg_begin(), E=CE->arg_end();
- I!=E; ++I, ++idx) {
+ Expr* ErrorExpr = NULL;
+
+ for (CallExpr::arg_iterator I = CE->arg_begin(), E = CE->arg_end();
+ I != E; ++I, ++idx) {
RVal V = StateMgr.GetRVal(St, *I);
@@ -716,7 +718,11 @@
if (RefBindings::TreeTy* T = B.SlimFind(Sym)) {
B = Update(B, Sym, T->getValue().second, Summ->getArg(idx), hasError);
SetRefBindings(StVals, B);
- if (hasError) break;
+
+ if (hasError) {
+ ErrorExpr = *I;
+ break;
+ }
}
}
}
@@ -731,11 +737,11 @@
switch (hasError) {
default: assert(false);
case RefVal::ErrorUseAfterRelease:
- UseAfterReleases.insert(N);
+ UseAfterReleases[N] = ErrorExpr;
break;
case RefVal::ErrorReleaseNotOwned:
- ReleasesNotOwned.insert(N);
+ ReleasesNotOwned[N] = ErrorExpr;
break;
}
}
@@ -886,8 +892,9 @@
for (CFRefCount::use_after_iterator I = TF.use_after_begin(),
E = TF.use_after_end(); I != E; ++I) {
- BugReport report(*this);
- BR.EmitPathWarning(report, *I);
+ RangedBugReport report(*this);
+ report.addRange(I->second->getSourceRange());
+ BR.EmitPathWarning(report, I->first);
}
}
@@ -896,8 +903,10 @@
for (CFRefCount::bad_release_iterator I = TF.bad_release_begin(),
E = TF.bad_release_end(); I != E; ++I) {
- BugReport report(*this);
- BR.EmitPathWarning(report, *I);
+ RangedBugReport report(*this);
+ report.addRange(I->second->getSourceRange());
+ BR.EmitPathWarning(report, I->first);
+
}
}
More information about the cfe-commits
mailing list