/*
-** LCLint - annotation-assisted static program checker
-** Copyright (C) 1994-2001 University of Virginia,
+** Splint - annotation-assisted static program checker
+** Copyright (C) 1994-2002 University of Virginia,
** Massachusetts Institute of Technology
**
** This program is free software; you can redistribute it and/or modify it
** the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
** MA 02111-1307, USA.
**
-** For information on lclint: lclint-request@cs.virginia.edu
-** To report a bug: lclint-bug@cs.virginia.edu
-** For more information: http://lclint.cs.virginia.edu
+** For information on splint: info@splint.org
+** To report a bug: splint-bug@splint.org
+** For more information: http://www.splint.org
*/
/*
** ctype.c
** They should probably be separated soon.
*/
-# include "lclintMacros.nf"
+# include "splintMacros.nf"
# include "basic.h"
# include "structNames.h"
static bool ctype_isComplex (ctype c)
{
- return (ctentry_isComplex (ctype_getCtentry(c)));
+ return (ctentry_isComplex (ctype_getCtentry (c)));
}
static bool ctype_isPlain (ctype c)
{
- return (ctentry_isPlain (ctype_getCtentry(c)));
+ return (ctentry_isPlain (ctype_getCtentry (c)));
}
static bool ctype_isBroken (ctype c)
{
ctype r = c;
+ if (ctype_isElips (c) || ctype_isMissingParamsMarker (c))
+ {
+ return c;
+ }
+
if (ctype_isUA (c))
{
r = uentry_getRealType (usymtab_getTypeEntry (ctype_typeId (c)));
bool
ctype_isSimple (ctype c)
{
- return (!(ctype_isPointer (c)
+ return (! (ctype_isPointer (c)
|| ctype_isArray (c)
|| ctype_isFunction (c)));
}
else
{
ctype r = uentry_getRealType (usymtab_getTypeEntry
- (ctype_typeId (c)));
+ (ctype_typeId (c)));
return (r);
}
}
ctype ctype_makeFixedArray (ctype c, long size)
{
- return (cttable_addDerived (CTK_ARRAY, ctbase_makeFixedArray (c, size), c));
+ ctype res;
+ res = cttable_addDerived (CTK_ARRAY, ctbase_makeFixedArray (c, size), c);
+ return res;
+}
+
+ctype ctype_makeInnerFixedArray (ctype c, long size)
+{
+ ctype res;
+
+ if (ctype_isFixedArray (c))
+ {
+ ctype cb = ctype_baseArrayPtr (c);
+ long osize = ctype_getArraySize (c);
+
+ res = ctype_makeFixedArray (ctype_makeInnerFixedArray (cb, size),
+ osize);
+ }
+ else
+ {
+ res = ctype_makeFixedArray (c, size);
+ }
+
+ return res;
}
ctype
}
}
+/*
+** wchar_t *
+*/
+
+ctype
+ctype_makeWideString ()
+{
+ static ctype res = ctype_unknown;
+
+ if (ctype_isUnknown (res))
+ {
+ ctype wchart;
+
+ if (usymtab_existsType (cstring_makeLiteralTemp ("wchar_t")))
+ {
+ wchart = uentry_getAbstractType (usymtab_lookup (cstring_makeLiteralTemp ("wchar_t")));
+ }
+ else
+ {
+ wchart = ctype_char;
+ }
+
+ res = ctype_makePointer (wchart);
+ }
+
+ return res;
+}
+
+bool
+ctype_isWideString (ctype c)
+{
+ if (ctype_isPointer (c))
+ {
+ ctype ct = ctype_baseArrayPtr (c);
+
+ if (usymtab_existsType (cstring_makeLiteralTemp ("wchar_t")))
+ {
+ return (ct == uentry_getAbstractType (usymtab_lookup (cstring_makeLiteralTemp ("wchar_t"))));
+ }
+ else
+ {
+ return FALSE;
+ }
+ }
+ else
+ {
+ return FALSE;
+ }
+}
+
ctype
ctype_getReturnType (ctype c)
{
bool
ctype_isNumeric (ctype c)
{
- return (ctype_isInt (c) || ctype_isReal (c) || ctype_isEnum (c));
+ return (ctype_isInt (c) || ctype_isReal (c) || ctype_isEnum (c)
+ /* evans 2001-10-05: added this: */
+ || ctype_isArbitraryIntegral (c));
}
static bool
ctype_isForcePred (ctype * c, bool (pred) (ctype))
{
- if (ctype_isConj (*c))
+ /*drl bee: pbr */ if (ctype_isConj (*c))
{
ctype cbr = ctype_getConjA (*c);
- if ((*pred) (cbr))
+ /*drl bee: si*/ if ((*pred) (cbr))
{
if ((*pred) (ctype_getConjB (*c)))
{
if (iv == ctype_unknown)
{
iv = cttable_addComplex
- (ctbase_makeConj (ctype_int,
+ (ctbase_makeConj (ctype_int,
ctype_voidPointer,
FALSE));
}
cstring
ctype_unparseDeclaration (ctype c, /*@only@*/ cstring name)
{
- llassert (!(ctype_isElips (c) || ctype_isMissingParamsMarker (c)));
+ llassert (! (ctype_isElips (c) || ctype_isMissingParamsMarker (c)));
if (ctype_isUnknown (c))
{
if (ctype_isUA (c))
{
cstring tname = usymtab_getTypeEntryName
- (usymtab_convertId (ctype_typeId (c)));
+ (usymtab_convertId (ctype_typeId (c)));
if (cstring_equal (tname, context_getBoolName ()))
{
if (ctype_isFunction (c))
{
c = ctype_makeParamsFunction
- (ctype_adjustPointers (np, ctype_getReturnType (c)),
+ (ctype_adjustPointers (np, ctype_getReturnType (c)),
uentryList_copy (ctype_argsFunction (c)));
}
else
long int size;
ctentry cte = ctype_getCtentry (c);
ctbase ctb;
- llassert ( (ctentry_getKind (cte) == CTK_COMPLEX) || (ctentry_getKind(cte) == CTK_ARRAY) );
- ctb = cte->ctbase;
+ llassert (ctype_isFixedArray (c));
+ llassert ((ctentry_getKind (cte) == CTK_COMPLEX) || (ctentry_getKind (cte) == CTK_ARRAY));
+ ctb = cte->ctbase;
size = ctbase_getArraySize (ctb);
- DPRINTF(( message("ctype_getArraySize: got fixed array size of %d ", (int)size) ));
+ DPRINTF ((message ("ctype_getArraySize: got fixed array size of %s / %d ",
+ ctype_unparse (c),
+ (int) size)));
return size;
}