mirror of
https://github.com/cc65/cc65.git
synced 2025-01-11 11:30:13 +00:00
Using tracked individual string buffers instead of a shared static string buffer for full type names.
This commit is contained in:
parent
4ccf10f3fa
commit
52051f444e
@ -273,15 +273,12 @@ const char* GetBasicTypeName (const Type* T)
|
|||||||
|
|
||||||
|
|
||||||
const char* GetFullTypeName (const Type* T)
|
const char* GetFullTypeName (const Type* T)
|
||||||
/* Return the full name string of the given type.
|
/* Return the full name string of the given type */
|
||||||
** Note: This may use a static buffer that could be overwritten by other calls.
|
|
||||||
*/
|
|
||||||
{
|
{
|
||||||
static struct StrBuf Buf = STATIC_STRBUF_INITIALIZER;
|
struct StrBuf* Buf = NewDiagnosticStrBuf ();
|
||||||
SB_Clear (&Buf);
|
GetFullTypeNameBuf (Buf, T);
|
||||||
GetFullTypeNameBuf (&Buf, T);
|
|
||||||
|
|
||||||
return SB_GetConstBuf (&Buf);
|
return SB_GetConstBuf (Buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -219,9 +219,7 @@ const char* GetBasicTypeName (const Type* T);
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
const char* GetFullTypeName (const Type* T);
|
const char* GetFullTypeName (const Type* T);
|
||||||
/* Return the full name string of the given type.
|
/* Return the full name string of the given type */
|
||||||
** Note: This may use a static buffer that could be overwritten by other calls.
|
|
||||||
*/
|
|
||||||
|
|
||||||
struct StrBuf* GetFullTypeNameBuf (struct StrBuf* S, const Type* T);
|
struct StrBuf* GetFullTypeNameBuf (struct StrBuf* S, const Type* T);
|
||||||
/* Return the full name string of the given type */
|
/* Return the full name string of the given type */
|
||||||
|
@ -38,7 +38,9 @@
|
|||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
/* common */
|
/* common */
|
||||||
|
#include "coll.h"
|
||||||
#include "print.h"
|
#include "print.h"
|
||||||
|
#include "strbuf.h"
|
||||||
|
|
||||||
/* cc65 */
|
/* cc65 */
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
@ -92,6 +94,8 @@ static WarnMapEntry WarnMap[] = {
|
|||||||
{ &WarnUnusedVar, "unused-var" },
|
{ &WarnUnusedVar, "unused-var" },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Collection DiagnosticStrBufs;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@ -323,3 +327,50 @@ void ErrorReport (void)
|
|||||||
{
|
{
|
||||||
Print (stdout, 1, "%u errors, %u warnings\n", ErrorCount, WarningCount);
|
Print (stdout, 1, "%u errors, %u warnings\n", ErrorCount, WarningCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* Tracked StrBufs */
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void InitDiagnosticStrBufs (void)
|
||||||
|
/* Init tracking string buffers used for diagnostics */
|
||||||
|
{
|
||||||
|
InitCollection (&DiagnosticStrBufs);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void DoneDiagnosticStrBufs (void)
|
||||||
|
/* Done with tracked string buffers used for diagnostics */
|
||||||
|
{
|
||||||
|
ClearDiagnosticStrBufs ();
|
||||||
|
DoneCollection (&DiagnosticStrBufs);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void ClearDiagnosticStrBufs (void)
|
||||||
|
/* Free all tracked string buffers */
|
||||||
|
{
|
||||||
|
unsigned I;
|
||||||
|
|
||||||
|
for (I = 0; I < CollCount (&DiagnosticStrBufs); ++I) {
|
||||||
|
SB_Done (CollAtUnchecked (&DiagnosticStrBufs, I));
|
||||||
|
}
|
||||||
|
|
||||||
|
CollDeleteAll (&DiagnosticStrBufs);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
struct StrBuf* NewDiagnosticStrBuf (void)
|
||||||
|
/* Get a new tracked string buffer */
|
||||||
|
{
|
||||||
|
StrBuf *Buf = NewStrBuf ();
|
||||||
|
CollAppend (&DiagnosticStrBufs, Buf);
|
||||||
|
return Buf;
|
||||||
|
}
|
||||||
|
@ -72,6 +72,9 @@ extern IntStack WarnUnusedLabel; /* - unused labels */
|
|||||||
extern IntStack WarnUnusedParam; /* - unused parameters */
|
extern IntStack WarnUnusedParam; /* - unused parameters */
|
||||||
extern IntStack WarnUnusedVar; /* - unused variables */
|
extern IntStack WarnUnusedVar; /* - unused variables */
|
||||||
|
|
||||||
|
/* Forward */
|
||||||
|
struct StrBuf;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@ -115,6 +118,18 @@ void ListWarnings (FILE* F);
|
|||||||
void ErrorReport (void);
|
void ErrorReport (void);
|
||||||
/* Report errors (called at end of compile) */
|
/* Report errors (called at end of compile) */
|
||||||
|
|
||||||
|
void InitDiagnosticStrBufs (void);
|
||||||
|
/* Init tracking string buffers used for diagnostics */
|
||||||
|
|
||||||
|
void DoneDiagnosticStrBufs (void);
|
||||||
|
/* Done with tracked string buffers used for diagnostics */
|
||||||
|
|
||||||
|
void ClearDiagnosticStrBufs (void);
|
||||||
|
/* Free all tracked string buffers */
|
||||||
|
|
||||||
|
struct StrBuf* NewDiagnosticStrBuf (void);
|
||||||
|
/* Get a new tracked string buffer */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* End of error.h */
|
/* End of error.h */
|
||||||
|
@ -1060,6 +1060,9 @@ int main (int argc, char* argv[])
|
|||||||
IS_Set (&Standard, STD_DEFAULT);
|
IS_Set (&Standard, STD_DEFAULT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Track string buffer allocation */
|
||||||
|
InitDiagnosticStrBufs ();
|
||||||
|
|
||||||
/* Go! */
|
/* Go! */
|
||||||
Compile (InputFile);
|
Compile (InputFile);
|
||||||
|
|
||||||
@ -1083,6 +1086,9 @@ int main (int argc, char* argv[])
|
|||||||
CreateDependencies ();
|
CreateDependencies ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Done with tracked string buffer allocation */
|
||||||
|
DoneDiagnosticStrBufs ();
|
||||||
|
|
||||||
/* Return an apropriate exit code */
|
/* Return an apropriate exit code */
|
||||||
return (ErrorCount > 0)? EXIT_FAILURE : EXIT_SUCCESS;
|
return (ErrorCount > 0)? EXIT_FAILURE : EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user