/*
** 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
/* requires: ctype_createAbstract (u) is never called more than once for any u. */
/* [ tested by cttable_addFullSafe, not really required ] */
- return (cttable_addFullSafe (ctentry_makeNew (CTK_PLAIN, ctbase_createAbstract (u))));
+ return (cttable_addFullSafe
+ (ctentry_makeNew (CTK_PLAIN, ctbase_createAbstract (u))));
+}
+
+ctype
+ctype_createNumAbstract (typeId u)
+{
+ /* requires: ctype_createAbstract (u) is never called more than once for any u. */
+ /* [ tested by cttable_addFullSafe, not really required ] */
+
+ return (cttable_addFullSafe
+ (ctentry_makeNew (CTK_PLAIN, ctbase_createNumAbstract (u))));
}
int
bool
ctype_isUA (ctype c)
{
- return (!ctype_isUnknown (c) && ctbase_isUA (ctype_getCtbase (c)));
+ return (!ctype_isUnknown (c)
+ && ctbase_isUA (ctype_getCtbase (c)));
}
bool
|| ctype_isAbstract (ctype_getConjB (c))))));
}
+bool
+ctype_isNumAbstract (ctype c)
+{
+ return (!ctype_isUnknown (c)
+ && ((ctype_isPlain (c) && ctbase_isNumAbstract (ctype_getCtbaseSafe (c))) ||
+ (ctype_isConj (c) &&
+ (ctype_isNumAbstract (ctype_getConjA (c))
+ || ctype_isNumAbstract (ctype_getConjB (c))))));
+}
+
bool
ctype_isImmutableAbstract (ctype t)
{
ctype_isRealAbstract (ctype_getConjB (c)))));
}
+bool
+ctype_isRealNumAbstract (ctype c)
+{
+ return (ctype_isNumAbstract (ctype_realType (c)) ||
+ (ctype_isConj (c) &&
+ (ctype_isRealNumAbstract (ctype_getConjA (c)) ||
+ ctype_isRealNumAbstract (ctype_getConjB (c)))));
+}
+
/*
** primitive creators
*/
return res;
}
+/*
+** In C, array terms appear backwards:
+**
+** int a[5][7]
+**
+** declares an array of 5 elements, each of which is
+** an array of 7 int's.
+**
+** We represent this as,
+**
+** array (array (int, 7), 5)
+**
+** Hence, the rightmost declaration is the innermost type.
+*/
+
ctype ctype_makeInnerFixedArray (ctype c, size_t size)
{
ctype res;
+ DPRINTF (("makeinnerfixed: %s / %d", ctype_unparse (c), size));
+
if (ctype_isFixedArray (c))
{
ctype cb = ctype_baseArrayPtr (c);
size_t osize = ctype_getArraySize (c);
res = ctype_makeFixedArray (ctype_makeInnerFixedArray (cb, size), osize);
+ DPRINTF (("res 1: %s", ctype_unparse (res)));
}
else if (ctype_isArray (c))
{
ctype cb = ctype_baseArrayPtr (c);
res = ctype_makeArray (ctype_makeInnerFixedArray (cb, size));
+ DPRINTF (("res 2: %s", ctype_unparse (res)));
}
else
{
res = ctype_makeFixedArray (c, size);
+ DPRINTF (("res 3: %s", ctype_unparse (res)));
}
- DPRINTF (("Make inner fixed array: %s", ctype_unparse (res)));
+ DPRINTF (("Make inner fixed array: %s / base: %s",
+ ctype_unparse (res), ctype_unparse (ctype_baseArrayPtr (res))));
return res;
}
res = ctype_makeFixedArray (ctype_makeInnerArray (cb), osize);
}
+ else if (ctype_isArray (c))
+ {
+ ctype cb = ctype_baseArrayPtr (c);
+ res = ctype_makeArray (ctype_makeInnerArray (cb));
+ }
else
{
res = ctype_makeArray (c);
if (ctype_isBroken (clp))
{
- llbuglit ("ctype_baseArrayPtr: bogus ctype");
+ llcontbug (message ("ctype_baseArrayPtr: bogus ctype getting base of: %s", ctype_unparse (c)));
+ return ctype_unknown;
}
return clp;
{
ctype cbr = ctype_getConjA (*c);
- /*drl bee: si*/ if ((*pred) (cbr))
+ if ((*pred) (cbr))
{
if ((*pred) (ctype_getConjB (*c)))
{
bool ctype_isIncompleteArray (ctype c)
{
- return (ctype_isArray (c) && !ctype_isFixedArray (c));
+ if (ctype_isArray (c))
+ {
+ if (ctype_isFixedArray (c))
+ {
+ return ctype_isIncompleteArray (ctype_baseArrayPtr (c));
+ }
+ else
+ {
+ return TRUE;
+ }
+ }
+
+ return FALSE;
}
bool
if (ctype_isUA (c))
{
- cstring tname = usymtab_getTypeEntryName
- (usymtab_convertId (ctype_typeId (c)));
+ cstring tname = usymtab_getTypeEntryName (usymtab_convertTypeId (ctype_typeId (c)));
if (cstring_equal (tname, context_getBoolName ()))
{
case CT_ENUMLIST:
case CT_BOOL:
case CT_ABST:
+ case CT_NUMABST:
case CT_FCN:
case CT_STRUCT:
case CT_UNION:
}
ctype
-ctype_adjustPointers (int np, ctype c)
+ctype_adjustPointers (pointers p, ctype c)
{
-
+ int np = pointers_depth (p);
+
if (ctype_isFunction (c))
{
c = ctype_makeParamsFunction
- (ctype_adjustPointers (np, ctype_getReturnType (c)),
+ (ctype_adjustPointers (p, ctype_getReturnType (c)),
uentryList_copy (ctype_argsFunction (c)));
}
else
return (ct);
}
+ctype
+ctype_createForwardEnum (cstring n)
+{
+ uentry ue = uentry_makeEnumTag (n, ctype_unknown, fileloc_undefined);
+ ctype ct = usymtab_supForwardTypeEntry (ue);
+
+ cstring_free (n);
+ return (ct);
+}
+
ctype
ctype_removePointers (ctype c)
{
bool ctype_isVisiblySharable (ctype t)
{
- if (ctype_isUnknown (t)) return TRUE;
+ if (ctype_isUnknown (t))
+ {
+ return TRUE;
+ }
if (ctype_isConj (t))
{
if (rt == t)
{
- return TRUE;
+ if (ctype_isNumAbstract (t))
+ {
+ return FALSE;
+ }
+ else
+ {
+ return TRUE;
+ }
}
else
{
return size;
}
+ctype ctype_biggerType (ctype c1, ctype c2)
+{
+ if (ctbase_isBigger (ctype_getCtbaseSafe (c2), ctype_getCtbaseSafe (c1)))
+ {
+ return c2;
+ }
+ else
+ {
+ return c1;
+ }
+}
+
+int ctype_getSize (ctype c)
+{
+ return ctbase_getSize (ctype_getCtbaseSafe (ctype_realType (c)));
+}