/*
** 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
{ 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" } ,
{ 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 } ,
/*@+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));
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 ("<invalid flag>");
+ }
+
return cstring_fromChars (flags[code].flag);
}
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 */
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 "
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, "
case FLG_LCLEXPECT:
case FLG_LIMIT:
case FLG_LINELEN:
+ case FLG_INDENTSPACES:
+ case FLG_BUGSLIMIT:
case FLG_EXTERNALNAMELEN:
case FLG_INTERNALNAMELEN:
case FLG_CONTROLNESTDEPTH:
}
else
{
- context_setValueAndFlag (opt, val);
+ context_setValueAndFlag (opt, val);
}
}
break;
/*@unchecked@*/ static bool initialized = FALSE;
int i;
/*@unchecked@*/ static flagcode valueFlags[NUMVALUEFLAGS];
-
if (!initialized)
{
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;
}
{
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)