Add reference counting to line infos. This allows better tracking of the ones

that are actually used.


git-svn-id: svn://svn.cc65.org/cc65/trunk@5212 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
uz
2011-08-18 14:36:38 +00:00
parent bd233ac916
commit 2f9e7d2ca0
11 changed files with 126 additions and 72 deletions

View File

@@ -83,7 +83,7 @@ static ULabel* NewULabel (ExprNode* Val)
/* Initialize the fields */
L->LineInfos = EmptyCollection;
GetFullLineInfo (&L->LineInfos, 0);
GetFullLineInfo (&L->LineInfos);
L->Val = Val;
L->Ref = 0;
@@ -160,8 +160,9 @@ void ULabDef (void)
*/
ULabel* L = CollAtUnchecked (&ULabList, ULabDefCount);
CHECK (L->Val == 0);
L->Val = GenCurrentPC ();
GetFullLineInfo (&L->LineInfos, 0);
L->Val = GenCurrentPC ();
ReleaseFullLineInfo (&L->LineInfos);
GetFullLineInfo (&L->LineInfos);
} else {
/* There is no such label, create it */
NewULabel (GenCurrentPC ());
@@ -198,8 +199,10 @@ ExprNode* ULabResolve (unsigned Index)
void ULabCheck (void)
/* Run through all unnamed labels and check for anomalies and errors */
void ULabDone (void)
/* Run through all unnamed labels, check for anomalies and errors and do
* necessary cleanups.
*/
{
/* Check if there are undefined labels */
unsigned I = ULabDefCount;
@@ -210,13 +213,14 @@ void ULabCheck (void)
}
/* Walk over all labels and emit a warning if any unreferenced ones
* are found.
* are found. Remove line infos because they're no longer needed.
*/
for (I = 0; I < CollCount (&ULabList); ++I) {
ULabel* L = CollAtUnchecked (&ULabList, I);
if (L->Ref == 0) {
LIWarning (&L->LineInfos, 1, "No reference to unnamed label");
}
ReleaseFullLineInfo (&L->LineInfos);
}
}