X-Git-Url: http://andersk.mit.edu/gitweb/splint.git/blobdiff_plain/885824d34f6f6626fde2fb041801408cbaf1f6f1..7bf960677344d11a101697c76672a0be4b3759f2:/src/flags.c diff --git a/src/flags.c b/src/flags.c index 265f771..9b5d4cd 100644 --- a/src/flags.c +++ b/src/flags.c @@ -1,6 +1,6 @@ /* ** LCLint - annotation-assisted static program checker -** Copyright (C) 1994-2000 University of Virginia, +** Copyright (C) 1994-2001 University of Virginia, ** Massachusetts Institute of Technology ** ** This program is free software; you can redistribute it and/or modify it @@ -54,9 +54,10 @@ static flagcatinfo categories[] = { FK_ANSI, "ansi", "violations of constraints imposed by ANSI/ISO standard" } , { FK_ARRAY, "arrays", "special checking involving arrays" } , { FK_BOOL, "booleans", "checking and naming of boolean types" } , - { FK_COMMENTS, "comments", "interpretation of stylized comments" } , + { FK_COMMENTS, "comments", "interpretation of semantic comments" } , { FK_COMPLETE, "complete", "completely defined, used, or specified system" } , { FK_CONTROL, "controlflow", "suspicious control structures" } , + { FK_DEBUG, "debug", "flags for debugging lclint" } , { FK_DECL, "declarations", "consistency of declarations" } , { FK_DEF, "definition", "undefined storage errors" } , { FK_DIRECT, "directories", "set directores" } , @@ -92,13 +93,14 @@ static flagcatinfo categories[] = { FK_PROTOS, "prototypes", "function prototypes" } , { FK_DEAD, "released", "using storage that has been deallocated" } , { FK_IGNORERET, "returnvals", "ignored return values" }, + { FK_SECURITY, "security", "possible security vulnerability" }, { FK_SPEC, "specifications", "checks involving .lcl specifications" } , { FK_SUPPRESS, "suppress", "local and global suppression of messages" } , { FK_TYPEEQ, "typeequivalence", "control what types are equivalent" } , { FK_BEHAVIOR, "undefined", "code with undefined or implementation-defined behavior" } , { FK_UNRECOG, "unrecognized", "unrecognized identifiers" } , { FK_UNSPEC, "unconstrained", "checking in the presence of unconstrained functions" } , - { FK_DEBUG, NULL, NULL } , + { FK_WARNUSE, "warnuse", "use of possibly problematic function" } , { FK_SYNTAX, NULL, NULL } , { FK_TYPE, NULL, NULL } , { FK_SECRET, NULL, NULL } , @@ -193,6 +195,11 @@ void flags_initMod () /*@+enumint@*/ if (flags[code].code != code) { + fprintf (stderr, + "*** ERROR: inconsistent flag %s / %d / %d", + flags[code].flag, + flags[code].code, code); + llbug (message ("*** ERROR: inconsistent flag %s / %d / %d", cstring_fromChars (flags[code].flag), flags[code].code, code)); @@ -626,9 +633,15 @@ void printAlphaFlags () cstringSList_printSpaced (fl, 3, 1, context_getLineLen () - 25); cstringSList_free (fl); } + /*@observer@*/ cstring -flagcode_name (flagcode code) +flagcode_unparse (flagcode code) { + if (code == INVALID_FLAG) + { + return cstring_makeLiteralTemp (""); + } + return cstring_fromChars (flags[code].flag); } @@ -706,6 +719,11 @@ canonicalizeFlag (cstring s) flagcode identifyFlag (cstring s) { + if (cstring_length (s) == 0) { + /* evs 2000-06-25: A malformed flag. */ + return INVALID_FLAG; + } + if (cstring_firstChar (s) == 'I') { return FLG_INCLUDEPATH; /* no space after -I */ @@ -873,8 +891,8 @@ identifyFlag (cstring s) if (cstring_equalLit (s, "accessunspec")) { - flagWarning - (cstring_makeLiteralTemp + llerror_flagWarning + (cstring_makeLiteral ("accessunspec flag is not supported by LCLint version 2.0 or " "later. It has been replaced by accessmodule, accessfile and " "accessfunction to provide more precise control of accessibility " @@ -886,28 +904,37 @@ identifyFlag (cstring s) if (cstring_equalLit (s, "staticmods")) { - flagWarning - (cstring_makeLiteralTemp + llerror_flagWarning + (cstring_makeLiteral ("staticmods flag is obsolete. You probably " "want impcheckmodstatics. For more information, " "see lclint -help impcheckmodstatics")); return SKIP_FLAG; } + + if (cstring_equalLit (s, "bool")) + { + llerror_flagWarning + (cstring_makeLiteral ("bool flag is obsolete. It never really " + "made sense in the first place.")); + + return SKIP_FLAG; + } if (cstring_equalLit (s, "ansi")) { - flagWarning - (cstring_makeLiteralTemp ("ansi flag is obsolete. You probably " - "want noparams and/or oldstyle.")); + llerror_flagWarning + (cstring_makeLiteral ("ansi flag is obsolete. You probably " + "want noparams and/or oldstyle.")); return SKIP_FLAG; } if (cstring_equalLit (s, "stdio")) { - flagWarning - (cstring_makeLiteralTemp + llerror_flagWarning + (cstring_makeLiteral ("stdio flag is obsolete. You may " "want strictlib or one of the gloabls " "checking flags. For more information, " @@ -927,6 +954,8 @@ void setValueFlag (flagcode opt, cstring arg) case FLG_LCLEXPECT: case FLG_LIMIT: case FLG_LINELEN: + case FLG_INDENTSPACES: + case FLG_BUGSLIMIT: case FLG_EXTERNALNAMELEN: case FLG_INTERNALNAMELEN: case FLG_CONTROLNESTDEPTH: @@ -948,7 +977,7 @@ void setValueFlag (flagcode opt, cstring arg) } else { - context_setValueAndFlag (opt, val); + context_setValueAndFlag (opt, val); } } break; @@ -1102,7 +1131,6 @@ extern int flagcode_valueIndex (flagcode f) /*@unchecked@*/ static bool initialized = FALSE; int i; /*@unchecked@*/ static flagcode valueFlags[NUMVALUEFLAGS]; - if (!initialized) { @@ -1113,14 +1141,15 @@ extern int flagcode_valueIndex (flagcode f) if (flagcode_hasValue (code)) { llassert (nv < NUMVALUEFLAGS); + DPRINTF (("Value flag: %s [%d]", flagcode_unparse (code), (int) code)); valueFlags[nv] = code; - nv++; + nv++; } } end_allFlagCodes; llassertprint (nv == NUMVALUEFLAGS, - ("number of value flags: %d (expected %d)", - nv, NUMVALUEFLAGS)); + ("Number of value flags: %d (expected %d)", + nv, (int) NUMVALUEFLAGS)); initialized = TRUE; } @@ -1131,9 +1160,14 @@ extern int flagcode_valueIndex (flagcode f) { return i; } - } + } + fprintf (stderr, "Cannot find value flag: %d", (int) f); + exit (EXIT_FAILURE); + /* Cannot do this...might call recursively... + llfatalbug (message ("Cannot fine value flag: %d", (int) f)); BADEXIT; + */ } extern int flagcode_stringIndex (flagcode f)