/*@only@*/ mtContextNode p_context,
int p_value, /*@only@*/ fileloc p_loc) /*@*/ ;
-extern /*@observer@*/ cstring annotationInfo_unparse (annotationInfo p_ainfo);
-extern /*@observer@*/ fileloc annotationInfo_getLoc (annotationInfo p_ainfo) /*@*/ ;
+extern /*@observer@*/ cstring annotationInfo_unparse (annotationInfo p_a);
+extern /*@observer@*/ fileloc annotationInfo_getLoc (annotationInfo p_a) /*@*/ ;
extern void annotationInfo_free (/*@only@*/ annotationInfo) ;
# ifdef HAVE_CONFIG_H
# ifdef WIN32
+
/* Win32 uses its own hand-generated config file */
# include "../../winconfig.h"
# else
extern void cpplib_reserve (/*@sef@*/ cppReader *, /*@sef@*/ size_t);
#define cpplib_reserve(PFILE, N) \
- (cpplib_getWritten (PFILE) + (N) > (PFILE)->token_buffer_size \
- && (cppReader_growBuffer (PFILE, (N)), 0))
+ (((cpplib_getWritten (PFILE) + (N) > (PFILE)->token_buffer_size)) ? cppReader_growBuffer (PFILE, (N)) : (void) 0)
/* Append string STR (of length N) to PFILE's output buffer.
Assume there is enough space. */
# define NUMVALUEFLAGS 14
/*@constant int NUMSTRINGFLAGS; @*/
-# define NUMSTRINGFLAGS 27
+# define NUMSTRINGFLAGS 28
/*@iter allFlagCodes (yield flagcode f); @*/
# define allFlagCodes(m_code) \
extern int flagcode_valueIndex (flagcode p_f) /*@*/ ;
extern int flagcode_stringIndex (flagcode p_f) /*@*/ ;
+extern int flagcode_priority (flagcode p_code) /*@*/ ;
+
extern bool flagcode_equal (flagcode p_code1, flagcode p_code2) /*@*/ ;
# define flagcode_equal(c1, c2) ((c1) == (c2))
/* stream for error messages */
/*@unchecked@*/ extern /*@relnull@*/ /*@dependent@*/ /*:open:*/ FILE *g_errorstream;
+/* stream for error messages */
+/*@unchecked@*/ extern /*@null@*/ /*@dependent@*/ /*:open:*/ FILE *g_csvstream;
+
/*@-ansireserved@*/
/* This macro is defined by flex. */
/*@constant external int ECHO@*/
extern /*@only@*/ lslOpSet
symtable_opsWithLegalDomain (symtable p_tab, /*@temp@*/ /*@null@*/ nameNode p_n,
- sortSetList p_argSorts, sort p_qual);
+ sortSetList p_argSorts, sort p_q);
extern /*@observer@*/ sigNodeSet
symtable_possibleOps (symtable p_tab, nameNode p_n);
extern bool symtable_opExistsWithArity(symtable p_tab, nameNode p_n, int p_arity);
return res;
}
-void annotationInfo_free (annotationInfo ainfo)
+void annotationInfo_free (annotationInfo a)
{
- if (annotationInfo_isDefined (ainfo))
+ if (annotationInfo_isDefined (a))
{
- cstring_free (ainfo->name);
- fileloc_free (ainfo->loc);
- mtContextNode_free (ainfo->context); /* evans 2002-01-03 */
- sfree (ainfo);
+ cstring_free (a->name);
+ fileloc_free (a->loc);
+ mtContextNode_free (a->context); /* evans 2002-01-03 */
+ sfree (a);
}
}
-cstring annotationInfo_getName (annotationInfo ainfo)
+cstring annotationInfo_getName (annotationInfo a)
{
- llassert (annotationInfo_isDefined (ainfo));
- return ainfo->name;
+ llassert (annotationInfo_isDefined (a));
+ return a->name;
}
-/*@observer@*/ cstring annotationInfo_unparse (annotationInfo ainfo)
+/*@observer@*/ cstring annotationInfo_unparse (annotationInfo a)
{
- return annotationInfo_getName (ainfo);
+ return annotationInfo_getName (a);
}
/*@observer@*/ metaStateInfo annotationInfo_getState (annotationInfo a) /*@*/
return a->state;
}
-/*@observer@*/ fileloc annotationInfo_getLoc (annotationInfo ainfo) /*@*/
+/*@observer@*/ fileloc annotationInfo_getLoc (annotationInfo a) /*@*/
{
- llassert (annotationInfo_isDefined (ainfo));
- return ainfo->loc;
+ llassert (annotationInfo_isDefined (a));
+ return a->loc;
}
int annotationInfo_getValue (annotationInfo a) /*@*/
}
}
-cstring annotationInfo_dump (annotationInfo ainfo)
+cstring annotationInfo_dump (annotationInfo a)
{
- llassert (annotationInfo_isDefined (ainfo));
- return ainfo->name;
+ llassert (annotationInfo_isDefined (a));
+ return a->name;
}
/*@observer@*/ annotationInfo annotationInfo_undump (char **s)
{
cstring mname = reader_readUntil (s, '.');
- annotationInfo ainfo;
+ annotationInfo a;
llassert (cstring_isDefined (mname));
- ainfo = context_lookupAnnotation (mname);
+ a = context_lookupAnnotation (mname);
- if (annotationInfo_isUndefined (ainfo))
+ if (annotationInfo_isUndefined (a))
{
llfatalerrorLoc
(message ("Library uses undefined annotation %s. Must use same -mts flags as when library was created.",
else
{
cstring_free (mname);
- return ainfo;
+ return a;
}
BADBRANCHRET (annotationInfo_undefined);
static /*@only@*/ cstring printBadArgs (sortSetList p_args);
static /*@only@*/ sortSet
- standardOperators (/*@null@*/ nameNode p_n, sortSetList p_argSorts, sort p_qual);
+ standardOperators (/*@null@*/ nameNode p_n, sortSetList p_argSorts, sort p_q);
static bool isStandardOperator (/*@null@*/ nameNode p_n);
static void assignSorts (termNode p_t, sort p_s);
}
static /*@only@*/ sortSet
-standardOperators (/*@null@*/ nameNode n, sortSetList argSorts, /*@unused@*/ sort qual)
+standardOperators (/*@null@*/ nameNode n, sortSetList argSorts, /*@unused@*/ sort q)
{
sortSet argSet;
sortSet ret = sortSet_new ();
preconditions = constraintList_makeNew();
}
- // drl remember to remove this code before you make a pslint release.
+ /*@i523@ drl remember to remove this code before you make a splint release. */
/*
if (context_getFlag (FLG_IMPLICTCONSTRAINT) )
{
{
struct operation *new_stack;
size_t old_size = size_fromInt ((char *) limit - (char *) stack);
- size_t new_size = 2 * old_size;
+ size_t new_size = (size_t) (2 * old_size);
if (stack != init_stack)
{
nlist->got_name_map = 0;
nlist->next = NULL;
- if (opts->first_system_include == NULL)
+ /*@i2523@*/ if (opts->first_system_include == NULL)
{
opts->first_system_include = nlist;
}
cppReader_appendIncludeChain (pfile, opts->after_include,
opts->last_after_include);
- if (opts->first_system_include == NULL)
+ /*@i523@*/ if (opts->first_system_include == NULL)
{
opts->first_system_include = opts->after_include;
}
|| (cprim_isAnyChar (c2) && context_msgCharInt ())) {
return TRUE;
}
+ /*@fallthrough@*/
default:
;
}
FILE *fileTable_createFile (fileTable ft, cstring fname)
{
- int fdesc = open (cstring_toCharsSafe (fname), O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, S_IRUSR | S_IWUSR);
+# ifdef WIN32
+ int fdesc = open (cstring_toCharsSafe (fname), O_WRONLY | O_CREAT | O_TRUNC | O_EXCL); /* not supported by VS.net: , S_IRUSR | S_IWUSR); */
+# else
+ int fdesc = open (cstring_toCharsSafe (fname), O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, S_IRUSR | S_IWUSR);
+# endif
if (fdesc == -1)
{
cstring flagname = cstring_fromChars (thisarg + 1); /* skip '-' or '+' */
flagcode opt = flags_identifyFlag (flagname);
- DPRINTF (("Flag: %s", flagcode_unparse (opt)));
+ DPRINTF (("Flag [%s]: %s", flagname, flagcode_unparse (opt)));
if (flagcode_isInvalid (opt))
{
cstringSList_free (fl); /* evans 2002-07-12: why wasn't this reported!?? */
}
+
+int flagcode_priority (/*@unused@*/ flagcode code)
+{
+ /*
+ ** For now, we do a really simple prioritization: all are 1
+ */
+
+ return 1;
+}
/*@notfunction@*/
# define globalExtraArgFlag FALSE, FALSE, TRUE, FALSE, ARG_SPECIAL
/*@notfunction@*/
-# define globalFileFlag FALSE, FALSE, TRUE, FALSE, ARG_FILE
+# define globalFileFlag FALSE, TRUE, TRUE, FALSE, ARG_FILE
/*@=namechecks@*/
/*
"show location information for load files",
NULL, 0, 0
},
+ {
+ FK_FORMAT, FK_DISPLAY, globalFileFlag,
+ "csv",
+ FLG_CSV,
+ "produce comma-separated values (CSV) warnings output file",
+ NULL, 0, 0
+ },
+ {
+ FK_FORMAT, FK_DISPLAY, plainFlag,
+ "csvoverwrite",
+ FLG_CSVOVERWRITE,
+ "overwrite exisiting CVS output file",
+ NULL, 0, 0
+ },
{
FK_FORMAT, FK_DISPLAY, plainFlag,
"parenfileformat",
else
{
llassert (FALSE);
- // fix this
+ /*@i2523 fix this */
}
}
}
FILE *g_warningstream = NULL;
FILE *g_messagestream = NULL;
FILE *g_errorstream = NULL;
+FILE *g_csvstream = NULL;
/*
** These were in llmain.c. Most should not be globals...
oname = s->name;
s->name = fileLib_cleanName (s->name);
- cstring_free (oname); /* evans 2002-07-12: why no error without this?! */
+ /*@i523@*/ cstring_free (oname); /* evans 2002-07-12: why no error without this?! */
s->lineNo = 0;
s->charNo = 0;
s->stringSourceTail = NULL;
s->buffer[0] = '\0';
- return s;
+ /*@i523@*/ return s;
}
extern /*@only@*/ inputStream
static /*@only@*/ cstring saveOneMessage = cstring_undefined;
static /*@only@*/ fileloc lastparseerror = fileloc_undefined;
static /*@only@*/ fileloc lastbug = fileloc_undefined;
-static bool llgenerrorreal (char *p_srcFile, int p_srcLine,
- /*@only@*/ cstring p_s, fileloc p_fl, bool p_iserror, bool p_indent)
+static bool llgenerrorreal (flagcode p_code,
+ char *p_srcFile, int p_srcLine,
+ /*@only@*/ cstring p_s,
+ /*@temp@*/ cstring p_addtext,
+ fileloc p_fl, bool p_iserror, bool p_indent)
/*@modifies g_warningstream@*/ ;
-static bool llgenerroraux (char *p_srcFile, int p_srcLine,
- /*@only@*/ cstring p_s, fileloc p_fl, bool p_iserror, bool p_indent)
+static bool llgenerroraux (flagcode p_code, char *p_srcFile, int p_srcLine,
+ /*@only@*/ cstring p_s,
+ /*@temp@*/ cstring p_addtext,
+ fileloc p_fl, bool p_iserror, bool p_indent)
/*@modifies g_warningstream@*/ ;
+static void generateCSV (flagcode p_code, cstring p_s, cstring p_addtext, fileloc p_fl)
+ /*@modifies g_csvstream@*/ ;
+
static void printError (FILE *p_stream, /*@only@*/ cstring p_sc)
/*@globals lastfileloclen @*/
/*@modifies *p_stream@*/ ;
}
else
{
- if (llgenerroraux (srcFile, srcLine, s, fl, TRUE, FALSE))
+ if (hcode != INVALID_FLAG && hcode != ocode)
+ {
+ code = hcode;
+ }
+
+ if (llgenerroraux (ocode, srcFile, srcLine, s, flagcodeHint (code), fl, TRUE, FALSE))
{
- if (hcode != INVALID_FLAG && hcode != ocode)
+ if (code != ocode)
{
- code = hcode;
-
if (context_flagOn (code, fl))
{
/* The flag is alreay set, something buggy in the flag code */
{
llshowhint (code);
}
- }
+ }
else
{
llsuppresshint ('-', code);
bool
xllgenerror (char *srcFile, int srcLine, flagcode o, /*@only@*/ cstring s, fileloc fl)
{
- if (llgenerroraux (srcFile, srcLine, s, fl, TRUE, FALSE))
+ if (llgenerroraux (o, srcFile, srcLine, s, flagcodeHint (o), fl, TRUE, FALSE))
{
llnosuppresshint (o);
flagcode_recordError (o);
{
if (!context_suppressFlagMsg (o, fl))
{
- if (llgenerroraux (srcFile, srcLine, s, fl, TRUE, FALSE))
+ if (llgenerroraux (o, srcFile, srcLine, s, hint, fl, TRUE, FALSE))
{
flagcode_recordError (o);
}
static bool
-llrealerror (char *srcFile, int srcLine, /*@only@*/ cstring s, fileloc fl)
+llrealerror (flagcode code, char *srcFile, int srcLine, /*@only@*/ cstring s, /*@temp@*/ cstring addtext, fileloc fl)
{
- return (llgenerrorreal (srcFile, srcLine, s, fl, TRUE, FALSE));
+ return (llgenerrorreal (code, srcFile, srcLine, s, addtext, fl, TRUE, FALSE));
}
static bool
-llgenerroraux (char *srcFile, int srcLine,
- /*@only@*/ cstring s, fileloc fl, bool iserror, bool indent)
+llgenerroraux (flagcode code,
+ char *srcFile, int srcLine,
+ /*@only@*/ cstring s,
+ cstring addtext,
+ fileloc fl, bool iserror, bool indent)
{
if (context_inSuppressZone (fl))
{
return FALSE;
}
- if (llgenerrorreal (srcFile, srcLine, s, fl, iserror, indent)) {
+ if (llgenerrorreal (code, srcFile, srcLine, s, addtext, fl, iserror, indent)) {
return TRUE;
} else {
return FALSE;
{
flagcode_recordError (code);
- if (llgenerrorreal (srcFile, srcLine, s, fl, TRUE, FALSE)) {
+ if (llgenerrorreal (code, srcFile, srcLine, s, cstring_undefined, fl, TRUE, FALSE)) {
closeMessage ();
return TRUE;
} else {
}
}
+static void generateCSV (flagcode code, cstring s, cstring addtext, fileloc fl)
+{
+
+ if (g_csvstream != NULL) {
+ /* Warning, Flag Code, Flag Name, Priority, File, Line, Column, Warning Text, Additional Text */
+ fprintf (g_csvstream, "%d,%d,%s,%d,%s,%d,%d,\"%s\"",
+ context_numErrors (),
+ (int) code, /* flag code */
+ cstring_toCharsSafe (flagcode_unparse (code)), /* flag name */
+ flagcode_priority (code), /* priority */
+ cstring_toCharsSafe (fileloc_outputFilename (fl)),
+ fileloc_lineno (fl),
+ fileloc_column (fl),
+ cstring_toCharsSafe (s));
+
+ if (cstring_isDefined (addtext)) {
+ fprintf (g_csvstream, ",\"%s\"\n", cstring_toCharsSafe (addtext));
+ } else {
+ fprintf (g_csvstream, "\n");
+ }
+ }
+}
+
static bool
-llgenerrorreal (char *srcFile, int srcLine,
- /*@only@*/ cstring s, fileloc fl, bool iserror, bool indent)
+llgenerrorreal (flagcode code, char *srcFile, int srcLine,
+ /*@only@*/ cstring s,
+ cstring addtext,
+ fileloc fl, bool iserror, bool indent)
{
cstring flstring;
flstring = fileloc_unparse (fl);
lastfileloclen = cstring_length (flstring);
+ generateCSV (code, s, addtext, fl);
+
if (indent)
{
printError (g_warningstream, message (" %q: %q", flstring, s));
}
showSourceLoc (srcFile, srcLine);
+
return TRUE;
}
{
if (context_getFlag (code))
{
+ generateCSV (code, s, hint, g_currentloc);
prepareMessage ();
context_clearPreprocessing ();
llerror (code, s);
{
DPRINTF (("xllopt: %s", s));
- if (llrealerror (srcFile, srcLine, s, loc))
+ if (llrealerror (o, srcFile, srcLine, s, flagcodeHint (o), loc))
{
DPRINTF (("Here we are!"));
llsuppresshint ('-', o);
}
else
{
- if (llrealerror (srcFile, srcLine, s, loc))
+ if (llrealerror (f1, srcFile, srcLine, s, flagcodeHint (f1), loc))
{
llsuppresshint2 ('-', f1, f2);
flagcode_recordError (f2);
}
else
{
- if (llrealerror (srcFile, srcLine, s, loc))
+ if (llrealerror (f1, srcFile, srcLine, s, flagcodeHint (f2), loc))
{
llsuppresshint ('+', f2);
flagcode_recordError (f2);
bool xllnoptgenerror (char *srcFile, int srcLine,
flagcode o, /*@only@*/ cstring s, fileloc loc)
{
- if (llrealerror (srcFile, srcLine, s, loc))
+ if (llrealerror (o, srcFile, srcLine, s, flagcodeHint (o), loc))
{
llsuppresshint ('+', o);
flagcode_recordError (o);
}
bool xfsgenerror (char *srcFile, int srcLine,
- flagSpec fs, /*@only@*/ cstring s, fileloc fl)
+ flagSpec fs, /*@only@*/ cstring s, fileloc fl)
{
if (flagSpec_isOn (fs, fl))
{
- if (llgenerroraux (srcFile, srcLine, s, fl, TRUE, FALSE))
+ flagcode firston = flagSpec_getFirstOn (fs, fl);
+
+ if (llgenerroraux (firston, srcFile, srcLine, s,
+ flagcodeHint (firston),
+ fl, TRUE, FALSE))
{
- llsuppresshint ('-', flagSpec_getFirstOn (fs, fl));
- flagcode_recordError (flagSpec_getFirstOn (fs, fl));
+ llsuppresshint ('-', firston);
+ flagcode_recordError (firston);
return TRUE;
}
else
{
- flagcode_recordSuppressed (flagSpec_getFirstOn (fs, fl));
+ flagcode_recordSuppressed (firston);
return FALSE;
}
}
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
# 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);
# include "syntable.h"
# include "lslinit.h"
# include "lclinit.h"
+# include "lclscan.h"
+# include "lclscanline.h"
/* needed to parse init files */
# include "shift.h"
XPERCENT, XCTYPE, XPLURAL, XREPREFIX, XFILELOC, XPOINTER
} ccode;
-/* char *s, anytype v */
+/*@function void GETPRINTF (char *p_s, anytype p_v) modifies strbuf@*/
+
/*@notfunction@*/
+# ifndef WIN32
+ /* ISO requires this, but not all implementations (e.g., Microsoft's) provide it */
# define GETPRINTF(s,v) (snprintf (strbuf, 64, s, v), mstring_copy (strbuf))
+# else
+ /* MS provides _snprintf instead */
+# define GETPRINTF(s,v) (_snprintf (strbuf, 64, s, v), mstring_copy (strbuf))
+# endif
/*
** returns control code indicated by *c, and
{
/* Give up if the result gets to be longer
than the absolute path name. */
- if (rel_buffer + filename_len <= rel_buf_p + 3)
+ /*@i423@*/ if (rel_buffer + filename_len <= rel_buf_p + 3)
{
sfree (rel_buffer);
return cstring_copy (filename);
llassert (lineptr != NULL);
lineptr = strchr (lineptr + 1, ' '); /* go past namestr */
llassert (lineptr != NULL);
- col = 5 + lineptr - line; /* 5 for initial "%LCL "*/
+ col = 5 + ((int) (lineptr - line)); /* 5 for initial "%LCL "*/
lclbug (message ("%q: Imported files contains unknown base sort",
fileloc_unparseRawCol (importfile, inputStream_thisLineNumber (srce), col)));
llassert (lineptr != NULL);
lineptr = strchr (lineptr + 1, ' '); /* go past namestr */
llassert (lineptr != NULL);
- col = 5 + lineptr - line; /* 5 for initial "%LCL "*/
+ col = 5 + ((int) (lineptr - line)); /* 5 for initial "%LCL "*/
if (sort_isNoSort (bsort))
{
lineptr = strchr (lineptr + 1, ' '); /* go past namestr */
llassert (lineptr != NULL);
- col = 5 + lineptr - line; /* 5 for initial "%LCL "*/
+ col = 5 + ((int) (lineptr - line)); /* 5 for initial "%LCL "*/
if (sort_isNoSort (bsort))
{
lineptr = strchr (lineptr + 1, ' '); /* go past namestr */
llassert (lineptr != NULL);
- col = 5 + lineptr - line; /* 5 for initial "%LCL "*/
+ col = 5 + ((int) (lineptr - line)); /* 5 for initial "%LCL "*/
if (sort_isNoSort (bsort))
{
lclplainerror (message ("%q: unknown base sort\n",
/*@only@*/ lslOpSet
symtable_opsWithLegalDomain (symtable tab, /*@temp@*/ /*@null@*/ nameNode n,
- sortSetList argSorts, sort qual)
+ sortSetList argSorts, sort q)
{
/* handles nil qual */
lslOpSet ops = lslOpSet_new ();
{
rangeSort = sigNode_rangeSort (sig);
- if ((qual == 0) || (sort_equal (rangeSort, qual)))
+ if ((q == NULL) || (sort_equal (rangeSort, q)))
{
if (domainMatches (sig->domain, argSorts))
{
DPRINTF (("Destroy usymtab [%p]: %d", utab, utab->nentries));
usymtab_freeAux (utab);
utab = usymtab_undefined;
-}
+ /*@-globstate@*/
+} /*@=globstate@*/
void
usymtab_initGlobalMarker () /*@globals globtab@*/
dbgfree = TRUE;
usymtab_freeAux (utab);
utab = usymtab_undefined;
-}
+/*@i523@*/ }
static int usymtab_lexicalLevel (void) /*@globals utab@*/
{