]> andersk Git - splint.git/blobdiff - src/ctype.c
Trying to add dummyfile to be bin to stay in the repository.\18
[splint.git] / src / ctype.c
index 387f470b06389abacfa143aab6ead53f0b8e1582..d09d4fe8d15913c0a9b33076f4dfd81c9d8a3029 100644 (file)
@@ -1,6 +1,6 @@
 /*
-** 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
@@ -17,9 +17,9 @@
 ** 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
@@ -28,7 +28,7 @@
 ** They should probably be separated soon.
 */
 
-# include "lclintMacros.nf"
+# include "splintMacros.nf"
 # include "basic.h"
 # include "structNames.h"
 
@@ -52,12 +52,12 @@ static ctype ctype_getConjB (ctype p_c) /*@*/ ;
 
 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)
@@ -170,6 +170,11 @@ ctype_realType (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)));
@@ -189,7 +194,7 @@ ctype_realType (ctype c)
 bool
 ctype_isSimple (ctype c)
 {
-  return (!(ctype_isPointer (c) 
+  return (! (ctype_isPointer (c) 
            || ctype_isArray (c)
            || ctype_isFunction (c)));
 }
@@ -219,7 +224,7 @@ ctype_realishType (ctype c)
       else
        {
          ctype r = uentry_getRealType (usymtab_getTypeEntry 
-                                       (ctype_typeId (c)));
+                                        (ctype_typeId (c)));
          return (r);
        }
     }
@@ -312,7 +317,29 @@ ctype_makePointer (ctype c)
 
 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
@@ -376,6 +403,56 @@ ctype_baseArrayPtr (ctype c)
     }
 }
 
+/*
+** 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)
 {
@@ -793,7 +870,9 @@ ctype_isSigned (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));
 }
 
 
@@ -931,11 +1010,11 @@ ctype_isDirectInt (ctype 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)))
            {
@@ -1253,7 +1332,7 @@ ctype_makeConj (ctype c1, ctype c2)
                  if (iv == ctype_unknown)
                    {
                      iv = cttable_addComplex
-                       (ctbase_makeConj (ctype_int, 
+                        (ctbase_makeConj (ctype_int, 
                                          ctype_voidPointer,
                                          FALSE));
                    }
@@ -1668,7 +1747,7 @@ ctype_typeId (ctype c)
 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))
     {
@@ -1769,7 +1848,7 @@ ctype_dump (ctype 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 ()))
        {
@@ -1848,7 +1927,7 @@ ctype_adjustPointers (int np, ctype c)
   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
@@ -2603,13 +2682,16 @@ long int ctype_getArraySize (ctype c)
   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;
 }
 
This page took 0.228699 seconds and 4 git commands to generate.