Main Page   Alphabetical List   Compound List   File List   Compound Members   File Members  

flagMarker.c

Go to the documentation of this file.
00001 /*
00002 ** LCLint - annotation-assisted static program checker
00003 ** Copyright (C) 1994-2000 University of Virginia,
00004 **         Massachusetts Institute of Technology
00005 **
00006 ** This program is free software; you can redistribute it and/or modify it
00007 ** under the terms of the GNU General Public License as published by the
00008 ** Free Software Foundation; either version 2 of the License, or (at your
00009 ** option) any later version.
00010 ** 
00011 ** This program is distributed in the hope that it will be useful, but
00012 ** WITHOUT ANY WARRANTY; without even the implied warranty of
00013 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 ** General Public License for more details.
00015 ** 
00016 ** The GNU General Public License is available from http://www.gnu.org/ or
00017 ** the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00018 ** MA 02111-1307, USA.
00019 **
00020 ** For information on lclint: lclint-request@cs.virginia.edu
00021 ** To report a bug: lclint-bug@cs.virginia.edu
00022 ** For more information: http://lclint.cs.virginia.edu
00023 */
00024 /*
00025 ** flagMarker.c
00026 */
00027 
00028 # include "lclintMacros.nf"
00029 # include "basic.h"
00030 
00031 flagMarker flagMarker_createLocalSet (flagcode code, ynm set, fileloc loc)
00032 {
00033   flagMarker c = (flagMarker) dmalloc (sizeof (*c));
00034   
00035   c->kind = FMK_LOCALSET;
00036   c->code = code;
00037   c->info.set = set;
00038   c->loc = fileloc_copy (loc); 
00039 
00040   return c;
00041 }
00042 
00043 flagMarker flagMarker_createSuppress (flagcode code, fileloc loc)
00044 {
00045   flagMarker c = (flagMarker) dmalloc (sizeof (*c));
00046   
00047   c->kind = FMK_SUPPRESS;
00048   c->code = code;
00049   c->loc = fileloc_copy (loc); 
00050 
00051   return c;
00052 }
00053 
00054 flagMarker flagMarker_createIgnoreOn (fileloc loc)
00055 {
00056   flagMarker c = (flagMarker) dmalloc (sizeof (*c));
00057   
00058   c->kind = FMK_IGNOREON;
00059   c->code = INVALID_FLAG;
00060   c->loc = fileloc_copy (loc); 
00061 
00062   return c;
00063 }
00064 
00065 flagMarker flagMarker_createIgnoreCount (int count, fileloc loc)
00066 {
00067   flagMarker c = (flagMarker) dmalloc (sizeof (*c));
00068   
00069   c->kind = FMK_IGNORECOUNT;
00070   c->code = INVALID_FLAG;
00071   c->info.nerrors = count;
00072   c->loc = fileloc_copy (loc); 
00073 
00074   return c;
00075 }
00076 
00077 flagMarker flagMarker_createIgnoreOff (fileloc loc)
00078 {
00079   flagMarker c = (flagMarker) dmalloc (sizeof (*c));
00080   
00081   c->kind = FMK_IGNOREOFF;
00082   c->code = INVALID_FLAG;
00083   c->loc = fileloc_copy (loc); 
00084 
00085   return c;
00086 }
00087 
00088 ynm flagMarker_getSet (flagMarker f)
00089 {
00090   llassert (f->kind == FMK_LOCALSET);
00091 
00092   return f->info.set;
00093 }
00094 
00095 flagcode flagMarker_getCode (flagMarker f)
00096 {
00097   llassert (f->kind == FMK_LOCALSET|| f->kind == FMK_SUPPRESS);
00098 
00099   return f->code;
00100 }
00101 
00102 int flagMarker_getCount (flagMarker f)
00103 {
00104   llassert (f->kind == FMK_IGNORECOUNT);
00105 
00106   return f->info.nerrors;
00107 }
00108 
00109 cstring flagMarker_unparse (flagMarker c)
00110 {
00111   switch (c->kind)
00112     {
00113     case FMK_LOCALSET:
00114       return (message ("%q: %s%s", 
00115                        fileloc_unparse (c->loc), ynm_unparseCode (c->info.set), 
00116                        flagcode_name (c->code)));
00117     case FMK_IGNORECOUNT:
00118       return (message ("%q: ignore count %d", 
00119                        fileloc_unparse (c->loc), c->info.nerrors));
00120     case FMK_IGNOREON:
00121       return (message ("%q: ignore on", 
00122                        fileloc_unparse (c->loc)));
00123     case FMK_IGNOREOFF:
00124       return (message ("%q: ignore off", 
00125                        fileloc_unparse (c->loc)));
00126     case FMK_SUPPRESS:
00127       return (message ("%q: suppress %s", 
00128                        fileloc_unparse (c->loc),
00129                        flagcode_name (c->code)));
00130     }
00131 
00132   BADBRANCH;
00133 }
00134   
00135 void flagMarker_free (/*@only@*/ flagMarker c)
00136 {
00137   sfree (c);
00138 }
00139 
00140 bool flagMarker_sameFile (flagMarker c, fileloc loc)
00141 {
00142   return (fileloc_almostSameFile (c->loc, loc));
00143 }
00144 
00145 /*
00146 ** return true if loc is before c->loc
00147 */
00148 
00149 bool flagMarker_beforeMarker (flagMarker c, fileloc loc)
00150 {
00151   return  (!fileloc_notAfter (c->loc, loc));
00152 }
00153 
00154 
00155 

Generated at Fri Nov 3 18:57:41 2000 for LCLint by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000