More fun with retain checker diagnostics:

- Fix some grammar.
- Fix a bug where a "reference count incremented" diagnostic would not be shown
  if the previous typestate was "Released" (only happens in GC mode).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64971 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Ted Kremenek 2009-02-18 22:57:22 +00:00
Родитель b7d2553edd
Коммит bb8c5aaa10
1 изменённых файлов: 17 добавлений и 7 удалений

Просмотреть файл

@ -1981,7 +1981,7 @@ RefBindings CFRefCount::Update(RefBindings B, SymbolRef sym,
break;
case RefVal::Released:
if (isGCEnabled())
V = V ^ RefVal::Owned;
V = (V ^ RefVal::Owned) + 1;
else {
V = V ^ RefVal::ErrorUseAfterRelease;
hasErr = V.getKind();
@ -1999,7 +1999,9 @@ RefBindings CFRefCount::Update(RefBindings B, SymbolRef sym,
assert (false);
case RefVal::Owned:
V = V.getCount() > 1 ? V - 1 : V ^ RefVal::Released;
assert(V.getCount() > 0);
if (V.getCount() == 1) V = V ^ RefVal::Released;
V = V - 1;
break;
case RefVal::NotOwned:
@ -2370,9 +2372,11 @@ PathDiagnosticPiece* CFRefReport::VisitNode(const ExplodedNode<GRState>* N,
<< "' decrements an object's retain count and registers the "
"object with the garbage collector. ";
if (CurrV.getKind() == RefVal::Released)
os << "The object's visible retain count is now 0 and can be "
if (CurrV.getKind() == RefVal::Released) {
assert(CurrV.getCount() == 0);
os << "Since it now has a 0 retain count the object can be "
"automatically collected by the garbage collector.";
}
else
os << "An object must have a 0 retain count to be garbage collected. "
"After this call its retain count is +" << CurrV.getCount()
@ -2401,7 +2405,7 @@ PathDiagnosticPiece* CFRefReport::VisitNode(const ExplodedNode<GRState>* N,
os << "Reference count incremented.";
if (unsigned Count = CurrV.getCount()) {
os << " Object has +" << Count;
os << " The object now has +" << Count;
if (Count > 1)
os << " retain counts.";
@ -2409,6 +2413,12 @@ PathDiagnosticPiece* CFRefReport::VisitNode(const ExplodedNode<GRState>* N,
os << " retain count.";
}
if (PrevV.getKind() == RefVal::Released) {
assert(TF.isGCEnabled() && CurrV.getCount() > 0);
os << " The object is not eligible for garbage collection until the "
"retain count reaches 0 again.";
}
break;
case RefVal::Released: