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

clause.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 ** clause.c
00026 */
00027 
00028 # include "lclintMacros.nf"
00029 # include "basic.h"
00030 
00031 cstring
00032 clause_unparse (clause cl)
00033 {
00034   switch (cl)
00035     {
00036     case TRUECLAUSE:   return (cstring_makeLiteralTemp ("true"));
00037     case FALSECLAUSE:  return (cstring_makeLiteralTemp ("false"));
00038     case ANDCLAUSE:    return (cstring_makeLiteralTemp ("and"));
00039     case ORCLAUSE:     return (cstring_makeLiteralTemp ("or"));
00040     case DOWHILECLAUSE:  return (cstring_makeLiteralTemp ("do ... while"));
00041     case WHILECLAUSE:  return (cstring_makeLiteralTemp ("while"));
00042     case ITERCLAUSE:   return (cstring_makeLiteralTemp ("iter"));
00043     case FORCLAUSE:    return (cstring_makeLiteralTemp ("for"));
00044     case CASECLAUSE:   return (cstring_makeLiteralTemp ("case"));
00045     case NOCLAUSE:     return (cstring_makeLiteralTemp ("none"));
00046     case SWITCHCLAUSE: return (cstring_makeLiteralTemp ("switch"));
00047     case CONDCLAUSE:   return (cstring_makeLiteralTemp ("cond"));
00048     case TRUEEXITCLAUSE: return (cstring_makeLiteralTemp ("trueexit"));
00049     case FALSEEXITCLAUSE: return (cstring_makeLiteralTemp ("falseexit"));
00050     }
00051 
00052   BADEXIT;
00053 }
00054 
00055 cstring
00056 clause_nameTaken (clause cl)
00057 {
00058   switch (cl)
00059     {
00060     case TRUECLAUSE:   return (cstring_makeLiteralTemp ("in true branch"));
00061     case FALSECLAUSE:  return (cstring_makeLiteralTemp ("in true branch"));
00062     case ANDCLAUSE:    return (cstring_makeLiteralTemp ("in first and clause"));
00063     case ORCLAUSE:     return (cstring_makeLiteralTemp ("in first or clause"));
00064     case DOWHILECLAUSE:  return (cstring_makeLiteralTemp ("in do ... while body"));
00065     case WHILECLAUSE:  return (cstring_makeLiteralTemp ("in while body"));
00066     case ITERCLAUSE:   return (cstring_makeLiteralTemp ("in iter body"));
00067     case FORCLAUSE:    return (cstring_makeLiteralTemp ("in for body"));
00068     case CASECLAUSE:   return (cstring_makeLiteralTemp ("in one case"));
00069     case NOCLAUSE:     return (cstring_makeLiteralTemp ("in some clause"));
00070     case SWITCHCLAUSE: return (cstring_makeLiteralTemp ("in one possible execution"));
00071     case CONDCLAUSE:   return (cstring_makeLiteralTemp ("in true condition"));
00072     case TRUEEXITCLAUSE: return (cstring_makeLiteralTemp ("in trueexit"));
00073     case FALSEEXITCLAUSE: return (cstring_makeLiteralTemp ("in falseexit"));
00074     }
00075 
00076   BADBRANCH;
00077 }
00078 
00079 cstring
00080 clause_nameAlternate (clause cl)
00081 {
00082   switch (cl)
00083     {
00084     case TRUECLAUSE:   return (cstring_makeLiteralTemp ("in continuation"));  
00085     case FALSECLAUSE:  return (cstring_makeLiteralTemp ("in false branch"));
00086     case ANDCLAUSE:    return (cstring_makeLiteralTemp ("in second and clause"));
00087     case ORCLAUSE:     return (cstring_makeLiteralTemp ("in second or clause"));
00088     case DOWHILECLAUSE:  return (cstring_makeLiteralTemp ("if loop is not taken"));
00089     case WHILECLAUSE:  return (cstring_makeLiteralTemp ("if loop is not taken"));
00090     case ITERCLAUSE:   return (cstring_makeLiteralTemp ("if iter body does not execute"));
00091     case FORCLAUSE:    return (cstring_makeLiteralTemp ("if for loop body does not execute"));
00092     case CASECLAUSE:   return (cstring_makeLiteralTemp ("in other case"));
00093     case NOCLAUSE:
00094     case SWITCHCLAUSE: return (cstring_makeLiteralTemp ("in other possible execution"));
00095     case CONDCLAUSE:   return (cstring_makeLiteralTemp ("in false condition"));
00096     case TRUEEXITCLAUSE: return (cstring_makeLiteralTemp ("in trueexit"));
00097     case FALSEEXITCLAUSE: return (cstring_makeLiteralTemp ("in falseexit"));
00098     }
00099 
00100   BADBRANCH;
00101 }
00102 
00103 cstring clause_nameFlip (clause cl, bool flip)
00104 {
00105   if (flip)
00106     {
00107       return clause_nameAlternate (cl);
00108     }
00109   else
00110     {
00111       return clause_nameTaken (cl);
00112     }
00113 }
00114 
00115 bool clause_isBreakable (clause cl)
00116 {
00117   return (cl == SWITCHCLAUSE
00118           || cl == WHILECLAUSE 
00119           || cl == DOWHILECLAUSE
00120           || cl == FORCLAUSE
00121           || cl == ITERCLAUSE);
00122 }
00123 
00124 bool clause_isLoop (clause cl)
00125 {
00126   return (cl == WHILECLAUSE 
00127           || cl == FORCLAUSE
00128           || cl == ITERCLAUSE
00129           || cl == DOWHILECLAUSE);
00130 }
00131 
00132 bool clause_isConditional (clause cl)
00133 {
00134   return (   cl == TRUECLAUSE
00135           || cl == FALSECLAUSE
00136           || cl == WHILECLAUSE
00137           || cl == FORCLAUSE
00138           || cl == SWITCHCLAUSE
00139           || cl == ITERCLAUSE);
00140 }
00141 
00142 bool clause_isSwitch (clause cl)
00143 {
00144   return (cl == SWITCHCLAUSE);
00145 }
00146 
00147 bool clause_isCase (clause cl)
00148 {
00149   return (cl == CASECLAUSE);
00150 }
00151 
00152 bool clause_isNone (clause cl)
00153 {
00154   return (cl == NOCLAUSE);
00155 } 

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