]> andersk Git - splint.git/commitdiff
Cleaned up code problems reported by make splintme.
authorevans1629 <evans1629>
Thu, 12 Dec 2002 17:21:08 +0000 (17:21 +0000)
committerevans1629 <evans1629>
Thu, 12 Dec 2002 17:21:08 +0000 (17:21 +0000)
14 files changed:
src/Headers/context.h
src/Headers/cscanner.h
src/Headers/functionClauseList.h
src/Headers/functionConstraint.h
src/cgrammar.c.der
src/cgrammar.y
src/context.c
src/cppexp.c
src/cppmain.c
src/flags.c
src/functionClauseList.c
src/functionConstraint.c
src/stateInfo.c
src/uentry.c

index 1e03aff24582bc0efc981c72e6671cc9f24a2ffa..a69186db5cf6a26048d9ed063ac59eff7614b01a 100644 (file)
@@ -336,10 +336,6 @@ extern int context_getBugsLimit (void) /*@*/ ;
 # define context_getBugsLimit()  ((int)context_getValue(FLG_BUGSLIMIT))
 
 /*drl 12/30/2001 these are some ugly functions that were added to facilitate struct annotations */
-
-
-extern bool hasInvariants (ctype p_ct);
-
 /*drl 1/6/2001: I didn't think these functions were solid enough to include in the
   stable  release of splint.  I commented them out so that they won't break anything
   but didn't delete them because they will be fixed and included later
@@ -353,12 +349,14 @@ extern bool hasInvariants (ctype p_ct);
 
 /* sRef fixSref (ctype p_ct, sRef p_base, sRef p_fix); */
 
-ctype context_setLastStruct (/*@returned@*/ ctype p_s) /*@modifies internalState@*/;
-ctype context_getLastStruct (/*@returned@*/ /*ctype p_s*/) /*@modifies internalState@*/;
+extern ctype context_setLastStruct (/*@returned@*/ ctype p_s) /*@modifies internalState@*/;
+extern ctype context_getLastStruct (/*@returned@*/ /*ctype p_s*/) /*@modifies internalState@*/;
 
 /*drl added 2/4/2002*/
 
-  bool context_inOldSytleScope(void);
+extern bool context_inOldStyleScope (void) /*@*/ ;
+extern void context_setGlobalStructInfo (ctype p_ct, constraintList p_list) /*@modifies internalState@*/ ;
+
 # else
 # error "Multiple include"
 # endif
index efc30c0a024842346dd1168c08615e64af72f7d5..ef0106eb9da0de500882de8861e5f84fb647d639 100644 (file)
@@ -7,6 +7,7 @@
 ** cscanner.h
 */
 
+/*@-declundef@*/ /* Don't always check cscanner.c */
 extern /*@observer@*/ cstring cscanner_observeLastIdentifier (void) ;
 extern void cscanner_expectingMetaStateName (void) /*@modifies internalState@*/ ;
 extern void cscanner_clearExpectingMetaStateName (void) /*@modifies internalState@*/ ;
@@ -18,6 +19,7 @@ extern void cscanner_swallowMacro (void) /*@modifies internalState, fileSystem@*
 
 # ifdef S_SPLINT_S
 
+/*@-namechecks@*/
 typedef struct yy_buffer_state *YY_BUFFER_STATE;
 
 extern /*@unused@*/ void yy_switch_to_buffer (YY_BUFFER_STATE);
@@ -35,5 +37,7 @@ extern /*@unused@*/ char *yytext;
 extern /*@unused@*/ void yyerror (char *);
 extern /*@unused@*/ int        yychar; 
 extern /*@unused@*/ int yynerrs;
+/*@=namechecks@*/
+/*@=declundef@*/
 
 # endif
index 471949bc3b05b033ee971a924cab8f41e561ad90..21717fe9de2f2b6ac47acb44072f02ce029d4fea 100644 (file)
@@ -48,6 +48,8 @@ extern functionClauseList
 extern /*@unused@*/ /*@only@*/ cstring functionClauseList_unparse (functionClauseList p_s) ;
 extern void functionClauseList_free (/*@only@*/ functionClauseList p_s) ;
 
+extern void functionClauseList_getImplictConstraints (functionClauseList p_s) /*@*/ ;
+
 /*@constant int functionClauseListBASESIZE;@*/
 # define functionClauseListBASESIZE MIDBASESIZE
 
index 83035c631e23a0759e7d15211cbc15cc77eb60b3..546e102a06256bc52502ae0fbd93a2380d76fd17 100644 (file)
@@ -29,6 +29,12 @@ struct s_functionConstraint {
 extern /*@falsewhennull@*/ bool functionConstraint_isDefined (functionConstraint) /*@*/ ;
 # define functionConstraint_isDefined(p_info) ((p_info) != NULL)
 
+extern /*@falsewhennull@*/ bool functionConstraint_isBufferConstraint (/*@sef@*/ functionConstraint) /*@*/ ;
+# define functionConstraint_isBufferConstraint(p_con) (((p_con) != NULL) && ((p_con)->kind == FCT_BUFFER))
+
+extern void functionConstraint_addBufferConstraints (functionConstraint p_fc, /*@only@*/ constraintList) 
+  /*@modifies p_fc@*/ ;
+
 extern /*@nullwhentrue@*/ bool functionConstraint_isUndefined (functionConstraint) /*@*/ ;
 # define functionConstraint_isUndefined(p_info) ((p_info) == NULL)
 
index 753c4230cd6186207ce728f69e2c084910533d34..c9e81e67757091eb5003be8f6482be75cce51e9f 100644 (file)
@@ -4704,7 +4704,7 @@ case 397:
 { sRef_clearGlobalScopeSafe (); ;
     break;}
 case 398:
-{ ctype ct; ct = declareStruct (yyvsp[-9].cname, yyvsp[-4].flist); setGlobalStructInfo(ct, yyvsp[0].conL); yyval.ctyp = ct; ;
+{ ctype ct; ct = declareStruct (yyvsp[-9].cname, yyvsp[-4].flist); context_setGlobalStructInfo(ct, yyvsp[0].conL); yyval.ctyp = ct; ;
     break;}
 case 399:
 { sRef_setGlobalScopeSafe (); ;
index 780c349cd81bd1dd66567de43a97fd2c08d48f27..9869c86397326e52e92267d78b15ad09fd5b3f4f 100644 (file)
@@ -1418,7 +1418,7 @@ suSpc
    structDeclList  DeleteStructInnerScope { sRef_clearGlobalScopeSafe (); }
    TRBRACE 
    optStructInvariant 
-   { ctype ct; ct = declareStruct ($3, $8); setGlobalStructInfo(ct, $12); $$ = ct; } 
+   { ctype ct; ct = declareStruct ($3, $8); context_setGlobalStructInfo(ct, $12); $$ = ct; } 
  | NotType CUNION  newId IsType TLBRACE { sRef_setGlobalScopeSafe (); } 
    CreateStructInnerScope 
    structDeclList DeleteStructInnerScope { sRef_clearGlobalScopeSafe (); } 
index 61e67c2453f82b7328172645c5055778e0b0b28f..81d8adaabc64a87571ec4bac7d324fe03343f2ac 100644 (file)
@@ -1875,12 +1875,9 @@ context_enterFunction (/*@exposed@*/ uentry e)
   sRef_enterFunctionScope ();
 }
 
-bool context_inOldSytleScope(void)
+bool context_inOldStyleScope(void)
 {
-  if (gc.kind == CX_OLDSTYLESCOPE)
-    return TRUE;
-  else
-    return FALSE;
+  return (gc.kind == CX_OLDSTYLESCOPE);
 }
 
 void
@@ -4907,9 +4904,7 @@ struct sInfo {
  /*@unused@*/ struct getUe * t ;
 };
 
-
-static struct sInfo globalStructInfo;
-
+/* unused: static struct sInfo globalStructInfo; */
 
 /*drl 1/6/2001: I didn't think these functions were solid enough to include in the
   stable  release of splint.  I coomented them out so that they won't break anything
@@ -4920,7 +4915,7 @@ static struct sInfo globalStructInfo;
 
 /*@-paramuse@*/
 
-void  setGlobalStructInfo(ctype ct, constraintList list)
+void context_setGlobalStructInfo(ctype ct, constraintList list)
 {
 # if 0
   /* int i;
index e79321e68b66f771d02b234855f540444b19b641..588eaf10cb62290629d84293c02dd2dc91bf8a8b 100644 (file)
@@ -153,7 +153,7 @@ Written by Per Bothner 1994.  */
 
 static struct operation cppexp_lex (cppReader *);
 static void integer_overflow (cppReader *);
-static long left_shift (cppReader *, long, bool p_unsignedp, size_t);
+static long left_shift (cppReader *, long, bool p_unsignedp, unsigned long);
 static long right_shift (long, bool p_unsignedp, unsigned long);
 
 /*@constant short CPPREADER_ERRORTOK@*/
@@ -798,7 +798,7 @@ integer_overflow (cppReader *pfile)
 }
 
 static long
-left_shift (cppReader *pfile, long a, bool unsignedp, size_t b)
+left_shift (cppReader *pfile, long a, bool unsignedp, unsigned long b)
 {
   if (b >= HOST_BITS_PER_LONG)
     {
index 991ed85658ad87ca5ed3d35eff3d7984424cad4e..36b1ce07b1b93f94382562982db1168bab68bc0f 100644 (file)
@@ -191,12 +191,8 @@ void cppAddIncludeDir (cstring dir)
     } 
   else 
     {
-      /* -I option (Add directory to include path) */
       struct file_name_list *dirtmp = (struct file_name_list *) dmalloc (sizeof (*dirtmp));
       
-      llassert (cstring_firstChar (dir) == 'I');
-      dir = cstring_suffix (dir, 1);
-
       DPRINTF (("Add include: %s", dir));
 
       dirtmp->next = 0;                /* New one goes on the end */
index d197f6ce21801b9a01b77e2ac7bfe0aabaa1c464..cdc6dc78868a32feb1490f652a139329d4db6ac8 100644 (file)
@@ -1701,26 +1701,50 @@ flags_processFlags (bool inCommandLine,
            }
          else if (opt == FLG_INCLUDEPATH || opt == FLG_SPECPATH)
            {
-             cstring dir = cstring_suffix (cstring_fromChars (thisarg), 1); /* skip over I */
-             
-             DPRINTF (("Directory: %s", dir));
-             
-             switch (opt)
-               {
-               case FLG_INCLUDEPATH:
-                 cppAddIncludeDir (dir);
-                 /*@switchbreak@*/ break;
-               case FLG_SPECPATH:
-                 /*@-mustfree@*/
-                 g_localSpecPath = cstring_toCharsSafe
-                   (message ("%s%h%s", 
-                             cstring_fromChars (g_localSpecPath), 
-                             PATH_SEPARATOR,
-                             dir));
-                 /*@=mustfree@*/
-                 /*@switchbreak@*/ break;
-                 BADDEFAULT;
+             if (mstring_length (thisarg) < 2) {
+               BADBRANCH;
+             } else {
+               if (mstring_equal (thisarg, "-I-")) {
+                 cppAddIncludeDir (cstring_fromChars (thisarg)); /* Need to handle this specially. */
+               } else {
+                 cstring dir = cstring_suffix (cstring_fromChars (thisarg), 2); /* skip over -I */
+                 
+                 DPRINTF (("Length of thisarg [%s] %d", thisarg, cstring_length (thisarg)));
+                 
+                 if (cstring_length (dir) == 0) {
+                   DPRINTF (("space after directory: "));
+                   if (++i < argc) {
+                     dir = cstring_fromChars (argv[i]);
+                   } else {
+                     voptgenerror
+                       (FLG_BADFLAG,
+                        message
+                        ("Flag %s must be followed by a directory name",
+                         flagcode_unparse (opt)),
+                        g_currentloc);
+                   }
+                 } 
+                 
+                 DPRINTF (("Got directory: [%s]", dir));
+                 
+                 switch (opt)
+                   {
+                   case FLG_INCLUDEPATH:
+                     cppAddIncludeDir (dir);
+                     /*@switchbreak@*/ break;
+                   case FLG_SPECPATH:
+                     /*@-mustfree@*/
+                     g_localSpecPath = cstring_toCharsSafe
+                       (message ("%s%h%s", 
+                                 cstring_fromChars (g_localSpecPath), 
+                                 PATH_SEPARATOR,
+                                 dir));
+                     /*@=mustfree@*/
+                     /*@switchbreak@*/ break;
+                     BADDEFAULT;
+                   }
                }
+             }
            }
          else if (flagcode_isModeName (opt))
            {
index 9180f10fe39cb7aa02bb46a7d839251358ca5b74..c05d8b0e5afe2c65c83b874a16316c58dd0d2987 100644 (file)
@@ -173,39 +173,36 @@ functionClauseList_free (functionClauseList s)
 }
 
 void
-functionClauseList_ImplictConstraints (functionClauseList s)
+functionClauseList_getImplictConstraints (functionClauseList s)
 {
   functionClauseList_elements(s, el)
     {
-      if (functionClause_isRequires(el) )
+      if (functionClause_isRequires(el))
        {
-         functionConstraint con;
-
-         con = functionClause_getRequires(el);
-         if (functionConstraint_hasBufferConstraint(con) )
+         functionConstraint con = functionClause_getRequires(el);
+         
+         if (functionConstraint_hasBufferConstraint(con))
            {
-             if (con->kind == FCT_BUFFER)
+             if (functionConstraint_isBufferConstraint (con))
                {
                  constraintList implCons = getImplicitFcnConstraints ();
-
-                 DPRINTF((message("functionClauseList_ImplictConstraints adding the implict constraints: %s to %s",
-                                  constraintList_print(implCons), constraintList_print( con->constraint.buffer) ) ));
                  
-                 con->constraint.buffer  = constraintList_addList ( con->constraint.buffer, constraintList_copy(implCons));
-
-                 DPRINTF((message("functionClauseList_ImplictConstraints the new constraint is %s",
-                                  constraintList_print( con->constraint.buffer) ) ));
-
+                 DPRINTF ((message ("functionClauseList_ImplictConstraints adding the implict constraints: %s to %s",
+                                    constraintList_print(implCons), constraintList_print (con->constraint.buffer))));
                  
+                 functionConstraint_addBufferConstraints (con, constraintList_copy (implCons));
+                 
+                 DPRINTF ((message ("functionClauseList_ImplictConstraints the new constraint is %s",
+                                    functionConstraint_unparse (con))));
                }
              else
                {
-                 llassert(FALSE);
+                 llassert (FALSE);
                  // fix this
                }
            }
        }
     }
-
+  
   end_functionClauseList_elements 
 }
index 859434e9106237abe42c8e57029c6b82fe3a28cb..5a30602f881c0a95c52e6d5731874054b3c1d6d0 100644 (file)
@@ -219,11 +219,9 @@ extern void functionConstraint_free (/*@only@*/ functionConstraint node)
     }
 }
 
-
-
-
-
-
-
-
+void functionConstraint_addBufferConstraints (functionConstraint fc, constraintList clist) 
+{
+  llassert (functionConstraint_isBufferConstraint (fc));
+  fc->constraint.buffer  = constraintList_addList (fc->constraint.buffer, clist);
+}
 
index 57bcdf6d60f8809b7bd52aa67c97d0d1e139ab9f..7da32bb134aab4710bdb993821587ae34b9d2d13 100644 (file)
@@ -53,6 +53,7 @@ void stateInfo_free (/*@only@*/ stateInfo a)
   else
     {
       stateInfo snew = stateInfo_makeRefLoc (newinfo->ref, newinfo->loc);
+      llassert (snew->previous == NULL);
       snew->previous = old;
       return snew;
     }
index 1bf61d04d1d3a868fd30cb50c7ac7b5e3b04eb56..29277a374e015a7df6f76c2cb3dbb0bccf9e6100 100644 (file)
@@ -11341,7 +11341,7 @@ void uentry_checkName (uentry ue)
   fileloc_free (tloc);
   uentry_setHasNameError (ue);
   
-  if (context_getFlag (FLG_REPEATUNRECOG) || (context_inOldSytleScope() ) )
+  if (context_getFlag (FLG_REPEATUNRECOG) || (context_inOldStyleScope()))
     {
       uentry_markOwned (ue);
     }
This page took 0.065789 seconds and 5 git commands to generate.