/*
** Splint - annotation-assisted static program checker
-** Copyright (C) 1994-2002 University of Virginia,
+** Copyright (C) 1994-2003 University of Virginia,
** Massachusetts Institute of Technology
**
** This program is free software; you can redistribute it and/or modify it
# endif
# include "splintMacros.nf"
-# include "llbasic.h"
+# include "basic.h"
# include "osd.h"
# include "help.h"
-
-# ifndef NOLCL
# include "gram.h"
# include "lclscan.h"
# include "scanline.h"
# include "lclinit.h"
# include "lh.h"
# include "imports.h"
-# endif
# include "Headers/version.h" /* Visual C++ finds the wrong version.h */
# include "lcllib.h"
# include "cgrammar.h"
+# include "rcfiles.h"
# include "llmain.h"
-# include "portab.h"
-
extern /*@external@*/ int yydebug;
static void cleanupFiles (void);
-static void interrupt (int p_i);
+/*
+** evans 2002-07-03: renamed from interrupt to avoid conflict with WATCOM compiler keyword
+** (Suggested by Adam Clarke)
+*/
+
+static void llinterrupt (int p_i);
static void describeVars (void);
static bool specialFlagsHelp (char *p_next);
static void warnSysFiles(fileIdList p_files) /*@modifies fileSystem@*/;
-# ifndef NOLCL
-
static
void lslCleanup (void)
/*@globals killed g_symtab@*/
g_currentSpec = cstring_undefined;
g_currentSpecName = NULL;
}
-# endif
static void handlePassThroughFlag (char *arg)
{
# endif
int main (int argc, char *argv[])
-# ifdef NOLCL
- /*@globals killed undef g_currentloc,
- killed undef yyin,
- undef g_warningstream, g_messagestream, g_errorstream;
- @*/
- /*@modifies g_currentloc, fileSystem,
- yyin;
- @*/
-# else
/*@globals killed undef g_currentloc,
killed g_localSpecPath,
killed undef g_currentSpec,
/*@modifies g_currentloc, g_localSpecPath, g_currentSpec, g_currentSpecName,
fileSystem, yyin;
@*/
-# endif
{
bool first_time = TRUE;
bool expsuccess;
inputStream sourceFile = inputStream_undefined;
fileIdList dercfiles;
- cstringSList passThroughArgs = cstringSList_undefined;
+ cstringList passThroughArgs = cstringList_undefined;
fileIdList cfiles, xfiles, lclfiles, mtfiles;
clock_t before, lcltime, libtime, pptime, cptime, rstime;
int i = 0;
g_messagestream = stderr;
g_errorstream = stderr;
- (void) signal (SIGINT, interrupt);
- (void) signal (SIGSEGV, interrupt);
+ (void) signal (SIGINT, llinterrupt);
+ (void) signal (SIGSEGV, llinterrupt);
flags_initMod ();
+ qual_initMod ();
clabstract_initMod ();
typeIdSet_initMod ();
- cppReader_initMod ();
osd_initMod ();
+ cppReader_initMod ();
setCodePoint ();
if (++i < argc)
{
fname = cstring_fromChars (argv[i]);
- setStringFlag (opt, fname);
+ flags_setStringFlag (opt, fname);
}
else
{
argc - 1, argv + 1);
showHerald ();
-
+
+ if (context_getFlag (FLG_CSV)) {
+ cstring fname = context_getString (FLG_CSV);
+
+ if (cstring_isDefined (fname)) {
+ if (osd_fileExists (fname) && !context_getFlag (FLG_CSVOVERWRITE)) {
+ lldiagmsg (message ("Specified CSV output file already exists (use +csvoverwrite to automatically overwrite): %s",
+ fname));
+ } else {
+ g_csvstream = fopen (cstring_toCharsSafe (fname), "w");
+
+ DPRINTF (("Creating: %s", fname));
+ if (g_csvstream == NULL) {
+ lldiagmsg (message ("Cannot open file for CSV output: %s", fname));
+ } else {
+ displayScan (message ("Starting CSV output file: %s", context_getString (FLG_CSV)));
+ fprintf (g_csvstream,
+ "Warning, Flag Code, Flag Name, Priority, File, Line, Column, Warning Text, Additional Text\n");
+ }
+ }
+ }
+ }
+
# ifdef DOANNOTS
initAnnots ();
# endif
if (anylcl)
{
-# ifdef NOLCL
- llfatalerror (cstring_makeLiteral ("This version of Splint does not handle LCL files."));
-# else
lslProcess (lclfiles);
-# endif
}
usymtab_initGlobalMarker ();
DPRINTF (("Pass through: %s", cstringSList_unparse (passThroughArgs)));
- cstringSList_elements (passThroughArgs, thisarg)
+ cstringList_elements (passThroughArgs, thisarg)
{
handlePassThroughFlag (cstring_toCharsSafe (thisarg));
}
- end_cstringSList_elements;
+ end_cstringList_elements;
- cstringSList_free (passThroughArgs);
+ cstringList_free (passThroughArgs);
cleanupMessages ();
(void) inputStream_close (sourceFile);
}
+
+ inputStream_free (sourceFile); /* evans 2002-07-12: why no warning without this?!! */
} end_fileIdList_elements;
+ fileIdList_free (dercfiles); /* evans 2002-07-12: why no warning without this?!! */
cptime = clock ();
/* process any leftover macros */
# endif
cleanupFiles ();
-
+
+ if (g_csvstream != NULL) {
+ displayScan (message ("Closing CSV file: %s", context_getString (FLG_CSV)));
+ check (fclose (g_csvstream) == 0);
+ }
+
if (context_getFlag (FLG_SHOWSUMMARY))
{
summarizeErrors ();
}
-
{
bool isQuiet = context_getFlag (FLG_QUIET);
cstring specErrors = cstring_undefined;
-# ifndef NOLCL
int nspecErrors = lclNumberErrors ();
-# endif
expsuccess = TRUE;
if (context_neednl ())
fprintf (g_warningstream, "\n");
-# ifndef NOLCL
if (nspecErrors > 0)
{
if (nspecErrors == context_getLCLExpect ())
expsuccess = FALSE;
}
}
-# endif
if (context_anyErrors ())
{
}
cstring_free (specErrors);
+
+ if (context_numBugs () > 0) {
+ expsuccess = FALSE;
+ if (!isQuiet) {
+ llmsg (message (" %d internal bugs reported", context_numBugs ()));
+ }
+ }
}
if (context_getFlag (FLG_STATS))
clock_t ttime = clock () - before;
int specLines = context_getSpecLinesProcessed ();
cstring specmsg = cstring_undefined;
-
+
rstime = clock ();
if (specLines > 0)
specmsg = message ("%d spec, ", specLines);
}
+ /* The clock might wrap around, not platform-independent easy way to deal with this... */
+ if (ttime > 0)
+ {
# ifndef CLOCKS_PER_SEC
- lldiagmsg (message ("%s%d source lines in %d time steps (steps/sec unknown)\n",
- specmsg,
- context_getLinesProcessed (),
- (int) ttime));
+ lldiagmsg (message ("%s%d source lines in %d time steps (steps/sec unknown)\n",
+ specmsg,
+ context_getLinesProcessed (),
+ (int) ttime));
# else
- lldiagmsg (message ("%s%d source lines in %f s.\n",
- specmsg,
- context_getLinesProcessed (),
- (double) ttime / CLOCKS_PER_SEC));
+ lldiagmsg (message ("%s%d source lines in %f s.\n",
+ specmsg,
+ context_getLinesProcessed (),
+ (double) ttime / CLOCKS_PER_SEC));
+ DPRINTF (("Time: %ld [%ld - %ld]", ttime, rstime, before));
# endif
+ }
+ else
+ {
+ lldiagmsg (message ("%s%d source lines\n",
+ specmsg,
+ context_getLinesProcessed ()));
+ }
+
}
else
{
if (anylcl)
{
- sprintf (msg,
- "Time distribution (percent): initialize %.2f / lcl %.2f / "
- "pre-process %.2f / c check %.2f / finalize %.2f \n",
- (100.0 * (double) (libtime - before) / ttime),
- (100.0 * (double) (lcltime - libtime) / ttime),
- (100.0 * (double) (pptime - lcltime) / ttime),
- (100.0 * (double) (cptime - pptime) / ttime),
- (100.0 * (double) (rstime - cptime) / ttime));
+ /* Gack: really should figure out how to make configure find snprintf... */
+# ifdef WIN32
+ (void) _snprintf (msg, 256,
+# else
+ (void) snprintf (msg, 256,
+# endif
+ "Time distribution (percent): initialize %.2f / lcl %.2f / "
+ "pre-process %.2f / c check %.2f / finalize %.2f \n",
+ (100.0 * (double) (libtime - before) / ttime),
+ (100.0 * (double) (lcltime - libtime) / ttime),
+ (100.0 * (double) (pptime - lcltime) / ttime),
+ (100.0 * (double) (cptime - pptime) / ttime),
+ (100.0 * (double) (rstime - cptime) / ttime));
}
else
{
- sprintf (msg,
- "Time distribution (percent): initialize %.2f / "
- "pre-process %.2f / c check %.2f / finalize %.2f \n",
- (100.0 * (double) (libtime - before) / ttime),
- (100.0 * (double) (pptime - libtime) / ttime),
- (100.0 * (double) (cptime - pptime) / ttime),
- (100.0 * (double) (rstime - cptime) / ttime));
+# ifdef WIN32
+ (void) _snprintf (msg, 256,
+# else
+ (void) snprintf (msg, 256,
+# endif
+ "Time distribution (percent): initialize %.2f / "
+ "pre-process %.2f / c check %.2f / finalize %.2f \n",
+ (100.0 * (double) (libtime - before) / ttime),
+ (100.0 * (double) (pptime - libtime) / ttime),
+ (100.0 * (double) (cptime - pptime) / ttime),
+ (100.0 * (double) (rstime - cptime) / ttime));
}
llgenindentmsgnoloc (cstring_fromCharsO (msg));
# endif
void
-interrupt (int i)
+llinterrupt (int i)
{
switch (i)
{
if (status != LLFAILURE)
{
- context_destroyMod ();
+ usymtab_destroyMod ();
+
+ /*drl I'm commenting this line out
+ because it is causing Splint to crash when built with
+ 2.95 I'm not sure if this is a compiler bug or if if has to do with bool
+ Any way if we're going to exist the program why do we bother freeing stuff...
+ */
+ /* context_destroyMod (); */
exprNode_destroyMod ();
-
+ cppReader_destroyMod ();
sRef_destroyMod ();
uentry_destroyMod ();
typeIdSet_destroyMod ();
-
+ qual_destroyMod ();
+ osd_destroyMod ();
+ fileloc_destroyMod ();
# ifdef USEDMALLOC
dmalloc_shutdown ();
# endif
if ((filesprocessed % skip) == 0)
{
if (filesprocessed == 0) {
- displayScan (cstring_makeLiteral (" "));
+ displayScanContinue (cstring_makeLiteral (" "));
}
else {
- displayScan (cstring_makeLiteral ("."));
+ displayScanContinue (cstring_makeLiteral ("."));
}
}
filesprocessed++;
fileIdList_add (dfiles, dfile);
}
} end_fileIdList_elements;
-
- return dfiles;
+
+ return dfiles;
}
/* This should be in an lclUtils.c file... */
-# ifndef NOLCL
char *specFullName (char *specfile, /*@out@*/ char **inpath)
{
/* extract the path and the specname associated with the given file */
return specname;
}
-# endif
void warnSysFiles(fileIdList files)
{