]> andersk Git - splint.git/blobdiff - src/usymtab_interface.c
Making fixes for Microsoft Visual C++ compiler.
[splint.git] / src / usymtab_interface.c
index 9d486d22607598080c6e88bd8fe01b8049020292..a8ac1257a64d3f0ddbe6d8ffe0e8683ce1f6dd3e 100644 (file)
@@ -1,6 +1,6 @@
 /*
-** LCLint - annotation-assisted static program checker
-** Copyright (C) 1994-2000 University of Virginia,
+** Splint - annotation-assisted static program checker
+** Copyright (C) 1994-2003 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
 */
 /*
 ** usymtab_interface.c
 **
 ** Grammar interface to symtab.
 **
-** The LCLint parser will build symbol tables for abstract types and
+** The Splint parser will build symbol tables for abstract types and
 ** function declarations.
 **
 */
 
-# include "lclintMacros.nf"
-# include "llbasic.h"
+# include "splintMacros.nf"
+# include "basic.h"
 # include "gram.h"
 # include "lclscan.h"
 # include "lclsyntable.h"
@@ -271,7 +271,8 @@ static ctype
                
                usymtab_supEntry 
                  (uentry_makeDatatype 
-                  (tn, ctype_unknown, MAYBE, NO, fileloc_getBuiltin ()));
+                  (tn, ctype_unknown, MAYBE, qual_createConcrete (), 
+                   fileloc_getBuiltin ()));
                
              }
            /*@switchbreak@*/ break;
@@ -553,7 +554,7 @@ static /*@only@*/ qtype
       
       result = qtype_addQualList (result, n->quals);
 
-      if (n->pointers > 0)
+      if (pointers_isDefined (n->pointers))
        {
          qtype_adjustPointers (n->pointers, result);
        }
@@ -586,11 +587,11 @@ static /*@only@*/ multiVal
   
   if /*@-usedef@*/ (first == '\"') /*@=usedef@*/
     {
-      int len = cstring_length (text) - 2;
+      size_t len = cstring_length (text) - 2;
       char *val = mstring_create (len);
       
       llassert (cstring_lastChar (text) == '\"');
-      strncpy (val, cstring_toCharsSafe (text) + 1, size_fromInt (len));
+      strncpy (val, cstring_toCharsSafe (text) + 1, len);
       return (multiVal_makeString (cstring_fromCharsO (val)));
     }
 
@@ -655,16 +656,14 @@ doDeclareConstant (constDeclarationNode c, bool priv)
          if (i->value != (termNode)0 &&
              i->value->kind == TRM_LITERAL)
            {
-             ue = uentry_makeConstantAux (s, ct, loc, priv, 
-                                          literalValue (ct, i->value->literal));
+             ue = uentry_makeConstantValue (s, ct, loc, priv, literalValue (ct, i->value->literal));
            }
          else
            {
-             ue = uentry_makeConstantAux (s, ct, loc, priv, multiVal_unknown ());
+             ue = uentry_makeConstantValue (s, ct, loc, priv, multiVal_unknown ());
            }
-
-                 uentry_reflectQualifiers (ue, qtype_getQuals (qt));
-
+         
+         uentry_reflectQualifiers (ue, qtype_getQuals (qt));
          
          if (context_inLCLLib () && !priv)
            {
@@ -864,7 +863,7 @@ declareAbstractType (abstractNode n, bool priv)
   cstring tn;
   fileloc loc;
   uentry ue;
-  usymId uid;
+  typeId uid;
   abstBodyNode ab;
 
   if (n == (abstractNode) 0)
@@ -878,7 +877,9 @@ declareAbstractType (abstractNode n, bool priv)
   loc = fileloc_fromTok (n->tok);
   
   ue = uentry_makeDatatypeAux (tn, ctype_unknown, 
-                              ynm_fromBool (n->isMutable), YES, loc, priv);
+                              ynm_fromBool (n->isMutable), 
+                              qual_createAbstract (), 
+                              loc, priv);
 
   if (n->isRefCounted)
     {
@@ -948,10 +949,8 @@ declareAbstractType (abstractNode n, bool priv)
     }
 }
 
-static void
-  declareExposedType (exposedNode n, bool priv)
+static void declareExposedType (exposedNode n, bool priv)
 {
-  usymId uid;
   qtype c;
   cstring s;
 
@@ -971,7 +970,8 @@ static void
 
     s = getVarName (i->declarator->type);
 
-    ue = uentry_makeDatatypeAux (s, realType, MAYBE, NO, loc, priv);
+    ue = uentry_makeDatatypeAux (s, realType, MAYBE, qual_createConcrete (), 
+                                loc, priv);
 
     uentry_reflectQualifiers (ue, qtype_getQuals (c));
     
@@ -980,7 +980,7 @@ static void
        uentry_setDefined (ue, loc);
       }
 
-    uid = usymtab_supExposedTypeEntry (ue, context_inLCLLib () && !priv);
+    (void) usymtab_supExposedTypeEntry (ue, context_inLCLLib () && !priv);
   } end_declaratorInvNodeList_elements;
 
   qtype_free (c);
@@ -1012,8 +1012,8 @@ doDeclareType (typeNode t, bool priv)
        case TK_UNION:
        default:
          {
-           llfatalbug (message ("declareType ERROR: unknown kind: %q",
-                                cstring_fromCharsO (FormatInt ((int)t->kind))));
+           llfatalbug (message ("declareType: unknown kind: %d",
+                                (int) t->kind));
          }
        }
     }
@@ -1073,7 +1073,7 @@ declareFcnAux (fcnNode f, /*@only@*/ qtype qt, ctype ct,
     {
       globals = f->globals;
       
-            sl = fixModifies (f, args);
+      sl = fixModifies (f, args);
 
       /*
       ** Bind let declarations in modifies list 
@@ -1113,13 +1113,12 @@ declareFcnAux (fcnNode f, /*@only@*/ qtype qt, ctype ct,
          
          ue = usymtab_lookupGlob (cstring_makeLiteralTemp ("stderr"));
          
-                 globlist = globSet_insert (globlist, sRef_copy (uentry_getSref (ue)));
+         globlist = globSet_insert (globlist, sRef_copy (uentry_getSref (ue)));
          sl = sRefSet_insert (sl, sRef_buildPointer (uentry_getSref (ue)));
-
        }
     }
 
-  if (usymId_isInvalid (tn))
+  if (typeId_isInvalid (tn))
     {
       acct = context_fileAccessTypes ();
     }
@@ -1127,7 +1126,7 @@ declareFcnAux (fcnNode f, /*@only@*/ qtype qt, ctype ct,
     {
       acct = typeIdSet_single (tn);
     }
-  
+
   if (usymtab_exists (s))
     {
       uentry l = usymtab_lookup (s);
@@ -1160,7 +1159,6 @@ declareFcnAux (fcnNode f, /*@only@*/ qtype qt, ctype ct,
            }
 
          uentry_reflectQualifiers (ue, qtype_getQuals (qt));
-
          usymtab_supEntry (ue);
        }
       else
@@ -1173,7 +1171,6 @@ declareFcnAux (fcnNode f, /*@only@*/ qtype qt, ctype ct,
          **          loc);
           */
 
-         
          fileloc_free (loc);
          sRefSet_free (sl);
          globSet_free (globlist);
@@ -1209,14 +1206,17 @@ declareFcnAux (fcnNode f, /*@only@*/ qtype qt, ctype ct,
 
       uentry_reflectQualifiers (le, qtype_getQuals (qt));
 
-      switch (f->special)
-       {
-       case QU_UNKNOWN:     break;
-       case QU_PRINTFLIKE:  uentry_setPrintfLike (le); break;
-       case QU_SCANFLIKE:   uentry_setScanfLike (le); break;
-       case QU_MESSAGELIKE: uentry_setMessageLike (le); break;
-       BADDEFAULT;
-       }
+      if (qual_isUnknown (f->special)) {
+       ;
+      } else if (qual_isPrintfLike (f->special)) {
+       uentry_setPrintfLike (le); 
+      } else if (qual_isScanfLike (f->special)) {
+       uentry_setScanfLike (le); 
+      } else if (qual_isMessageLike (f->special)) {
+       uentry_setMessageLike (le); 
+      } else {
+       BADBRANCH;
+      }
 
       usymtab_supEntry (le);
     }
@@ -1230,7 +1230,7 @@ doDeclareFcn (fcnNode f, typeId tn, bool priv, bool spec)
   qtype qt = convertLclTypeSpecNode (f->typespec);
   ctype ct = convertTypeExpr (qtype_getType (qt), f->declarator->type);
 
-    declareFcnAux (f, qt, ct, tn, priv, spec);
+  declareFcnAux (f, qt, ct, tn, priv, spec);
 }
 
 /*
@@ -1577,14 +1577,13 @@ static /*@exposed@*/ sRef fixTermNode (termNode n, fcnNode f, uentryList cl)
                          }
                      }
                    else
-                     return (sRef_makeGlobal (usym, ctype_unknown));
+                     return (sRef_makeGlobal (usym, ctype_unknown, stateInfo_currentLoc ()));
                  }
                
                else
                  {
-                   sRef p = sRef_makeParam (i, ctype_unknown);
-
-                                   return (p);
+                   sRef p = sRef_makeParam (i, ctype_unknown, stateInfo_currentLoc ());
+                   return (p);
                  }
              }
          }
@@ -1648,7 +1647,7 @@ static
                  
                      llmsg (message
                             ("%q: Warning: object and type modifications "
-                             "not understood by LCLint",
+                             "not understood by Splint",
                              fileloc_unparse (loc)));
                      fileloc_free (loc);
                      shownWarning = TRUE;
@@ -1700,7 +1699,7 @@ paramNode_toUentry (paramNode p)
          ctype cr = convertTypeExpr (qtype_getType (ct), p->paramdecl);
          cstring pname = (p->paramdecl == (typeExpr)0) ? cstring_undefined 
                                                        : paramNode_name (p);
-         uentry ue = uentry_makeVariableParam (pname, cr);
+         uentry ue = uentry_makeVariableParam (pname, cr, g_currentloc);
 
          uentry_reflectQualifiers (ue, qtype_getQuals (ct));
          qtype_free (ct);
This page took 1.480614 seconds and 4 git commands to generate.