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

sRef.c File Reference

#include "lclintMacros.nf"
#include "basic.h"
#include "exprChecks.h"
#include "aliasChecks.h"
#include "sRefTable.h"
#include "structNames.h"

Go to the source code of this file.

Defines

#define OR(a,b)    (a ? (b, TRUE) : b)
#define AND(a,b)    (a ? b : (b, FALSE))
#define alinfo_undefined   ((alinfo) NULL)
#define MAXBASEDEPTH   25
#define PREDTEST(func,s)

Functions

void sRef_protectDerivs (void)
void sRef_clearProtectDerivs (void)
bool sRef_isRecursiveField (sRef s)
bool sRef_deepPred (bool (predf) (sRef), sRef s)
bool sRef_modInFunction (void)
void sRef_setStateFromType (sRef s, ctype ct)
bool sRef_hasAliasInfoRef (sRef s)
sRef sRef_getAliasInfoRef ( sRef s)
void sRef_setGlobalScope ()
void sRef_clearGlobalScope ()
void sRef_setGlobalScopeSafe ()
void sRef_clearGlobalScopeSafe ()
void sRef_enterFunctionScope ()
void sRef_exitFunctionScope ()
void sRef_destroyMod ()
bool sRef_isExternallyVisible (sRef s)
uentry sRef_getBaseUentry (sRef s)
sRef sRef_updateSref (sRef s)
uentry sRef_getUentry (sRef s)
int sRef_getParam (sRef s)
bool sRef_isModified (sRef s)
void sRef_setModified (sRef s)
bool sRef_canModifyVal (sRef s, sRefSet sl)
bool sRef_canModify (sRef s, sRefSet sl)
cstring sRef_stateVerb (sRef s)
cstring sRef_stateAltVerb (sRef s)
int sRef_compare (sRef s1, sRef s2)
bool sRef_similarRelaxed (sRef s1, sRef s2)
bool sRef_similar (sRef s1, sRef s2)
bool sRef_includedBy (sRef small, sRef big)
bool sRef_realSame (sRef s1, sRef s2)
bool sRef_same (sRef s1, sRef s2)
sRef sRef_fixBaseParam ( sRef s, exprNodeList args)
sRef sRef_undumpGlobal (char **c)
sRef sRef_undump (char **c)
cstring sRef_dump (sRef s)
cstring sRef_dumpGlobal (sRef s)
ctype sRef_deriveType (sRef s, uentryList cl)
ctype sRef_getType (sRef s)
cstring sRef_unparseOpt (sRef s)
cstring sRef_unparsePreOpt (sRef s)
cstring sRef_unparse (sRef s)
cstring sRef_unparseDebug (sRef s)
sRef sRef_makeUnconstrained (cstring fname)
cstring sRef_unconstrainedName (sRef s)
bool sRef_isUnconstrained (sRef s)
sRef sRef_makeCvar (int level, usymId index, ctype ct)
int sRef_lexLevel (sRef s)
sRef sRef_makeGlobal (usymId l, ctype ct)
void sRef_setParamNo (sRef s, int l)
sRef sRef_makeParam (int l, ctype ct)
bool sRef_isIndexKnown (sRef arr)
int sRef_getIndex (sRef arr)
sRef sRef_makeAddress ( sRef t)
cstring sRef_getField (sRef s)
sRef sRef_getBase (sRef s)
sRef sRef_getBaseSafe (sRef s)
sRef sRef_getRootBase (sRef s)
sRef sRef_makeObject (ctype o)
sRef sRef_makeExternal ( sRef t)
sRef sRef_makeDerived ( sRef t)
void sRef_mergeStateQuiet (sRef res, sRef other)
void sRef_mergeStateQuietReverse (sRef res, sRef other)
void sRef_mergeState (sRef res, sRef other, clause cl, fileloc loc)
void sRef_mergeOptState (sRef res, sRef other, clause cl, fileloc loc)
sRef sRef_makeConj ( sRef a, sRef b)
sRef sRef_makeUnknown ()
sRef sRef_makeNothing (void)
sRef sRef_makeInternalState (void)
sRef sRef_makeSpecState (void)
sRef sRef_makeSystemState (void)
sRef sRef_makeResult ()
bool sRef_isNothing (sRef s)
bool sRef_isInternalState (sRef s)
bool sRef_isSpecInternalState (sRef s)
bool sRef_isSpecState (sRef s)
bool sRef_isResult (sRef s)
bool sRef_isSystemState (sRef s)
usymId sRef_getScopeIndex (sRef s)
void sRef_makeSafe (sRef s)
void sRef_makeUnsafe (sRef s)
cstring sRef_unparseFull (sRef s)
cstring sRef_unparseDeep (sRef s)
cstring sRef_unparseState (sRef s)
bool sRef_isNotUndefined (sRef s)
ynm sRef_isWriteable (sRef s)
bool sRef_hasNoStorage (sRef s)
bool sRef_isStrictReadable (sRef s)
ynm sRef_isReadable (sRef s)
bool sRef_isReallyDefined (sRef s)
void sRef_showNotReallyDefined (sRef s)
sstate sRef_getDefState (sRef s)
void sRef_setDefState (sRef s, sstate defstate, fileloc loc)
void sRef_clearAliasState (sRef s, fileloc loc)
void sRef_setAliasKindComplete (sRef s, alkind kind, fileloc loc)
void sRef_setAliasKind (sRef s, alkind kind, fileloc loc)
void sRef_setOrigAliasKind (sRef s, alkind kind)
exkind sRef_getExKind (sRef s)
exkind sRef_getOrigExKind (sRef s)
void sRef_setObserver (sRef s, fileloc loc)
void sRef_setExposed (sRef s, fileloc loc)
void sRef_clearExKindComplete (sRef s, fileloc loc)
void sRef_setExKind (sRef s, exkind exp, fileloc loc)
void sRef_copyRealDerivedComplete (sRef s1, sRef s2)
void sRef_setUndefined (sRef s, fileloc loc)
void sRef_setPartialDefinedComplete (sRef s, fileloc loc)
void sRef_setDefinedComplete (sRef s, fileloc loc)
void sRef_setDefined (sRef s, fileloc loc)
void sRef_setDefinedNCComplete (sRef s, fileloc loc)
bool sRef_isUnionField (sRef s)
void sRef_setPdefined (sRef s, fileloc loc)
void sRef_setAllocatedComplete (sRef s, fileloc loc)
void sRef_setAllocatedShallowComplete (sRef s, fileloc loc)
void sRef_setAllocated (sRef s, fileloc loc)
void sRef_setPartial (sRef s, fileloc loc)
void sRef_setShared (sRef s, fileloc loc)
void sRef_setLastReference (sRef s, sRef ref, fileloc loc)
void sRef_setNotNull (sRef s, fileloc loc)
void sRef_setNullState (sRef s, nstate n, fileloc loc)
void sRef_setNullStateInnerComplete (sRef s, nstate n, fileloc loc)
void sRef_setPosNull (sRef s, fileloc loc)
void sRef_setDefNull (sRef s, fileloc loc)
void sRef_setNullUnknown (sRef s, fileloc loc)
void sRef_setNullError (sRef s)
void sRef_setOnly (sRef s, fileloc loc)
void sRef_setDependent (sRef s, fileloc loc)
void sRef_setOwned (sRef s, fileloc loc)
void sRef_setKept (sRef s, fileloc loc)
void sRef_setKeptComplete (sRef s, fileloc loc)
void sRef_setDependentComplete (sRef s, fileloc loc)
void sRef_setFresh (sRef s, fileloc loc)
void sRef_kill (sRef s, fileloc loc)
void sRef_maybeKill (sRef s, fileloc loc)
void sRef_killComplete (sRef s, fileloc loc)
sRef sRef_saveCopy (sRef s)
sRef sRef_copy (sRef s)
bool sRef_isAddress (sRef s)
bool sRef_isThroughArrayFetch (sRef s)
bool sRef_isArrayFetch (sRef s)
bool sRef_isMacroParamRef (sRef s)
bool sRef_isCvar (sRef s)
bool sRef_isConst (sRef s)
bool sRef_isObject (sRef s)
bool sRef_isExternal (sRef s)
bool sRef_isField (sRef s)
bool sRef_isAnyParam (sRef s)
bool sRef_isParam (sRef s)
bool sRef_isDirectParam (sRef s)
bool sRef_isPointer (sRef s)
bool sRef_isReference (sRef s)
bool sRef_isIReference (sRef s)
bool sRef_isGlobal (sRef s)
bool sRef_isRealGlobal (sRef s)
bool sRef_isFileStatic (sRef s)
bool sRef_isAliasCheckedGlobal (sRef s)
void sRef_free ( sRef s)
void sRef_setType (sRef s, ctype t)
void sRef_setTypeFull (sRef s, ctype t)
sRef sRef_buildField (sRef rec, cstring f)
sRefSet sRef_derivedFields (sRef rec)
bool sRef_isUnknownArrayFetch (sRef s)
bool sRef_isStackAllocated (sRef s)
sRef sRef_buildArrayFetch ( sRef arr)
sRef sRef_buildArrayFetchKnown ( sRef arr, int i)
void sRef_setStateFromUentry (sRef s, uentry ue)
sRef sRef_buildPointer ( sRef t)
sRef sRef_constructPointer (sRef t)
sRef sRef_constructDeref (sRef t)
sRef sRef_constructDeadDeref (sRef t)
bool sRef_hasDerived (sRef s)
void sRef_clearDerived (sRef s)
void sRef_clearDerivedComplete (sRef s)
sRef sRef_makePointer (sRef s)
sRef sRef_makeAnyArrayFetch ( sRef arr)
sRef sRef_makeArrayFetch (sRef arr)
sRef sRef_makeArrayFetchKnown (sRef arr, int i)
sRef sRef_makeField (sRef rec, cstring f)
sRef sRef_makeNCField (sRef rec, cstring f)
cstring sRef_unparseKindName (sRef s)
cstring sRef_unparseKindNamePlain (sRef s)
void sRef_copyState (sRef s1, sRef s2)
sRef sRef_makeNew (ctype ct, sRef t, cstring name)
sRef sRef_makeType (ctype ct)
sRef sRef_makeConst (ctype ct)
bool sRef_hasName (sRef s)
bool sRef_sameName (sRef s1, sRef s2)
sRef sRef_fixOuterRef ( sRef s)
void sRef_storeState (sRef s)
void sRef_resetState (sRef s)
void sRef_resetStateComplete (sRef s)
sRef sRef_fixBase ( sRef s, sRef base)
bool sRef_isAllocIndexRef (sRef s)
void sRef_showRefLost (sRef s)
void sRef_showRefKilled (sRef s)
void sRef_showStateInconsistent (sRef s)
void sRef_showStateInfo (sRef s)
void sRef_showExpInfo (sRef s)
void sRef_showNullInfo (sRef s)
void sRef_showAliasInfo (sRef s)
void sRef_mergeNullState (sRef s, nstate n)
bool sRef_possiblyNull (sRef s)
cstring sRef_getScopeName (sRef s)
cstring sRef_unparseScope (sRef s)
int sRef_getScope (sRef s)
bool sRef_isDead (sRef s)
bool sRef_isDeadStorage (sRef s)
bool sRef_isPossiblyDead (sRef s)
bool sRef_isStateLive (sRef s)
bool sRef_isStateUndefined (sRef s)
bool sRef_isJustAllocated (sRef s)
bool sRef_isUnuseable (sRef s)
bool sRef_perhapsNull (sRef s)
bool sRef_definitelyNull (sRef s)
void sRef_setDerivNullState (sRef set, sRef guide, nstate ns)
void sRef_aliasCheckPred (bool (predf) (sRef, exprNode, sRef, exprNode), bool (checkAliases) (sRef), sRef s, exprNode e, exprNode err)
bool sRef_aliasCheckSimplePred (sRefTest predf, sRef s)
bool sRef_aliasCompleteSimplePred (bool (predf) (sRef), sRef s)
sRef sRef_getConjA (sRef s)
sRef sRef_getConjB (sRef s)
sRef sRef_makeArrow (sRef s, cstring f)
sRef sRef_buildArrow (sRef s, cstring f)
bool sRef_isNSLocalVar (sRef s)
bool sRef_isLocalVar (sRef s)
bool sRef_isRealLocalVar (sRef s)
bool sRef_isLocalParamVar (sRef s)
cstring sRef_nullMessage (sRef s)
sRef sRef_fixResultType ( sRef s, ctype typ, uentry ue)
bool sRef_isOnly (sRef s)
bool sRef_isDependent (sRef s)
bool sRef_isOwned (sRef s)
bool sRef_isKeep (sRef s)
bool sRef_isTemp (sRef s)
bool sRef_isLocalState (sRef s)
bool sRef_isUnique (sRef s)
bool sRef_isShared (sRef s)
bool sRef_isExposed (sRef s)
bool sRef_isObserver (sRef s)
bool sRef_isFresh (sRef s)
bool sRef_isDefinitelyNull (sRef s)
bool sRef_isAllocated (sRef s)
bool sRef_isStack (sRef s)
bool sRef_isNotNull (sRef s)


Define Documentation

#define AND( a, b )   (a ? b : (b, FALSE))
 

Definition at line 52 of file sRef.c.

#define MAXBASEDEPTH   25
 

Definition at line 3104 of file sRef.c.

#define OR( a, b )   (a ? (b, TRUE) : b)
 

Definition at line 49 of file sRef.c.

#define PREDTEST( func, s )
 

Initializer:

\
   do { if (sRef_isInvalid (s)) { return FALSE; } \
        else { if (sRef_isConj (s)) \
                  { return (func (sRef_getConjA (s)) \
                            || func (sRef_getConjB (s))); }}} while (FALSE);

Definition at line 5317 of file sRef.c.

Referenced by sRef_isAddress(), sRef_isAnyParam(), sRef_isArrayFetch(), sRef_isConst(), sRef_isCvar(), sRef_isDirectParam(), sRef_isExternal(), sRef_isField(), sRef_isObject(), sRef_isParam(), sRef_isPointer(), and sRef_isReference().

#define alinfo_undefined   ((alinfo) NULL)
 

Definition at line 191 of file sRef.c.


Function Documentation

void sRef_aliasCheckPred ( bool(predf)(sRef,exprNode,sRef,exprNode),
bool(checkAliases)(sRef),
sRef s,
exprNode e,
exprNode err )
 

Definition at line 7561 of file sRef.c.

Referenced by exprNode_checkCallModifyVal(), exprNode_checkModify(), and exprNode_checkModifyVal().

07564 {
07565   bool error = (*predf)(s, e, sRef_undefined, err);
07566   
07567   
07568   if (checkAliases != NULL && !(checkAliases (s)))
07569     {
07570       /* don't check aliases */
07571     }
07572   else
07573     {
07574       sRefSet aliases = usymtab_allAliases (s);
07575 
07576       
07577       sRefSet_realElements (aliases, current)
07578         {
07579           if (sRef_isValid (current))
07580             {
07581               if (!sRef_similar (current, s)
07582                   || (error && sRef_sameName (current, s)))
07583                 {
07584                   (void) (*predf)(current, e, s, err);
07585                 }
07586               }
07587         } end_sRefSet_realElements;
07588 
07589       sRefSet_free (aliases);
07590     }
07591 }

bool sRef_aliasCheckSimplePred ( sRefTest predf,
sRef s )
 

Definition at line 7598 of file sRef.c.

Referenced by checkPassTransfer(), sRef_isExternallyVisible(), and usymtab_isProbableNull().

07599 {
07600     
07601   if ((*predf)(s))
07602     {
07603       return TRUE;
07604     }
07605   else
07606     {
07607       sRefSet aliases;
07608 
07609       aliases = usymtab_allAliases (s);
07610       
07611       sRefSet_realElements (aliases, current)
07612         {
07613           if (sRef_isValid (current))
07614             {
07615               sRef cref = sRef_updateSref (current);
07616               
07617               /* Whoa! a very kludgey way to make sure the right sref is used
07618               ** where there is a conditional symbol table.  I am beginning
07619               ** to think that having a conditional symbol table wasn't such
07620               ** a great idea.  ;(
07621               */
07622               
07623                       
07624               if ((*predf)(cref))
07625                 {
07626                   sRefSet_free (aliases);
07627                   return TRUE;
07628                 }
07629             }
07630         } end_sRefSet_realElements;
07631 
07632       sRefSet_free (aliases);
07633     }
07634   return FALSE;
07635 }

bool sRef_aliasCompleteSimplePred ( bool(predf)(sRef),
sRef s )
 

Definition at line 7638 of file sRef.c.

Referenced by usymtab_isGuarded().

07639 {
07640   sRefSet aliases;
07641   bool result = FALSE;
07642   
07643   
07644   aliases = usymtab_allAliases (s);
07645   
07646   if ((*predf)(s)) result = TRUE;
07647 
07648   
07649   sRefSet_realElements (aliases, current)
07650     {
07651       if (sRef_isValid (current))
07652         {
07653                   current = sRef_updateSref (current);
07654                   if ((*predf)(current)) result = TRUE;
07655         }
07656     } end_sRefSet_realElements;
07657   
07658   sRefSet_free (aliases);
07659   return result;
07660 }

sRef sRef_buildArrayFetch ( sRef arr )
 

Definition at line 5969 of file sRef.c.

Referenced by sRef_makeAnyArrayFetch(), sRef_makeArrayFetch(), and sRef_undump().

05970 {
05971   sRef s;
05972 
05973   if (!sRef_isValid (arr)) {
05974     /*@-nullret@*/ return arr /*@=nullret@*/;
05975   }
05976 
05977   if (ctype_isRealPointer (arr->type))
05978     {
05979       (void) sRef_buildPointer (arr); /* do this to define arr! */
05980     }
05981   
05982   s = sRef_findDerivedArrayFetch (arr, FALSE, 0, FALSE);
05983   
05984   if (sRef_isValid (s))
05985     {
05986       sRef_setExKind (s, sRef_getExKind (arr), g_currentloc);
05987       return s;
05988     }
05989   else
05990     {
05991       s = sRef_new ();
05992 
05993       s->kind = SK_ARRAYFETCH;
05994       s->info = (sinfo) dmalloc (sizeof (*s->info));
05995       s->info->arrayfetch = (ainfo) dmalloc (sizeof (*s->info->arrayfetch));
05996       s->info->arrayfetch->indknown = FALSE;
05997       s->info->arrayfetch->ind = 0;
05998       s->info->arrayfetch->arr = arr;
05999       sRef_setArrayFetchState (s, arr);
06000       s->oaliaskind = s->aliaskind;
06001       s->oexpkind = s->expkind;
06002 
06003       if (!context_inProtectVars ())
06004         {
06005           sRef_addDeriv (arr, s);
06006         }
06007       
06008       return (s);
06009     }
06010 }

sRef sRef_buildArrayFetchKnown ( sRef arr,
int i )
 

Definition at line 6013 of file sRef.c.

Referenced by sRef_makeArrayFetchKnown(), and sRef_undump().

06014 {
06015   sRef s;
06016 
06017   if (!sRef_isValid (arr)) {
06018     /*@-nullret@*/ return arr /*@=nullret@*/;
06019   }
06020 
06021   if (ctype_isRealPointer (arr->type))
06022     {
06023        (void) sRef_buildPointer (arr); /* do this to define arr! */
06024     }
06025 
06026   s = sRef_findDerivedArrayFetch (arr, TRUE, i, FALSE);
06027       
06028   if (sRef_isValid (s))
06029     {
06030       sRef_setExKind (s, sRef_getExKind (arr), g_currentloc);      
06031       return s;
06032     }
06033   else
06034     {
06035       s = sRef_new ();
06036       
06037       s->kind = SK_ARRAYFETCH;
06038       s->info = (sinfo) dmalloc (sizeof (*s->info));
06039       s->info->arrayfetch = (ainfo) dmalloc (sizeof (*s->info->arrayfetch));
06040       s->info->arrayfetch->arr = arr;
06041       s->info->arrayfetch->indknown = TRUE;
06042       s->info->arrayfetch->ind = i;
06043       
06044       sRef_setArrayFetchState (s, arr);
06045       
06046       s->oaliaskind = s->aliaskind;
06047       s->oexpkind = s->expkind;
06048       sRef_addDeriv (arr, s);
06049 
06050       return (s);
06051     }
06052 }

sRef sRef_buildArrow ( sRef s,
cstring f )
 

Definition at line 8340 of file sRef.c.

08341 {
08342   sRef p;
08343   sRef ret;
08344 
08345   p = sRef_buildPointer (s);
08346   ret = sRef_buildField (p, f);
08347   
08348   return ret;
08349 }

sRef sRef_buildField ( sRef rec,
cstring f )
 

Definition at line 5533 of file sRef.c.

Referenced by sRef_buildArrow(), sRef_makeField(), and sRef_undump().

05534 {
05535   return (sRef_buildNCField (rec, f)); 
05536 }

sRef sRef_buildPointer ( sRef t )
 

Definition at line 6127 of file sRef.c.

Referenced by sRef_buildArrayFetch(), sRef_buildArrayFetchKnown(), sRef_buildArrow(), sRef_constructPointer(), and sRef_makePointer().

06128 {
06129   DPRINTF (("build pointer: %s", sRef_unparse (t)));
06130 
06131   if (sRef_isInvalid (t)) return sRef_undefined;
06132 
06133   if (sRef_isAddress (t))
06134     {
06135       DPRINTF (("Return ref: %s", sRef_unparse (t->info->ref)));
06136       return (t->info->ref);
06137     }
06138   else
06139     {
06140       sRef s = sRef_findDerivedPointer (t);
06141 
06142       DPRINTF (("find derived: %s", sRef_unparse (s)));
06143 
06144       if (sRef_isValid (s))
06145         {
06146           
06147           sRef_setExKind (s, sRef_getExKind (t), g_currentloc);
06148           s->oaliaskind = s->aliaskind;
06149           s->oexpkind = s->expkind;
06150 
06151           return s;
06152         }
06153       else
06154         {
06155           s = sRef_constructPointerAux (t);
06156           
06157           DPRINTF (("construct: %s", sRef_unparse (s)));
06158 
06159           if (sRef_isValid (s))
06160             {
06161               sRef_addDeriv (t, s);
06162 
06163               s->oaliaskind = s->aliaskind;
06164               s->oexpkind = s->expkind;
06165             }
06166           
06167           return s;
06168         }
06169     }
06170 }

bool sRef_canModify ( sRef s,
sRefSet sl )
 

Definition at line 954 of file sRef.c.

00955 {
00956   
00957   if (context_getFlag (FLG_MUSTMOD))
00958     {
00959       return (sRef_doModify (s, sl));
00960     }
00961   else
00962     {
00963       return (sRef_checkModify (s, sl));
00964     }
00965 }

bool sRef_canModifyVal ( sRef s,
sRefSet sl )
 

Definition at line 941 of file sRef.c.

00942 {
00943   if (context_getFlag (FLG_MUSTMOD))
00944     {
00945       return (sRef_doModifyVal (s, sl));
00946     }
00947   else
00948     {
00949       return (sRef_checkModifyVal (s, sl));
00950     }
00951 }

void sRef_clearAliasState ( sRef s,
fileloc loc )
 

Definition at line 4527 of file sRef.c.

04528 {
04529   sRef_aliasSetComplete (sRef_clearAliasStateAux, s, loc);
04530 }

void sRef_clearDerived ( sRef s )
 

Definition at line 6289 of file sRef.c.

Referenced by checkPassTransfer(), context_usedGlobal(), sRef_kill(), sRef_maybeKill(), sRef_mergeStateQuietReverse(), sRef_resetState(), sRef_setAliasKind(), sRef_setUndefined(), uentry_fixupSref(), uentry_getOrigSref(), usymtab_exitScope(), and usymtab_supEntrySref().

06290 {
06291   if (sRef_isValid (s))
06292     {
06293             sRefSet_clear (s->deriv); 
06294     }
06295 }

void sRef_clearDerivedComplete ( sRef s )
 

Definition at line 6298 of file sRef.c.

06299 {
06300   
06301   if (sRef_isValid (s))
06302     {
06303       sRef base = sRef_getBaseSafe (s);
06304 
06305       while (sRef_isValid (base))
06306         {
06307           sRefSet_clear (base->deriv); 
06308           base = sRef_getBaseSafe (base);
06309         }
06310 
06311       sRefSet_clear (s->deriv); 
06312     }
06313 }

void sRef_clearExKindComplete ( sRef s,
fileloc loc )
 

Definition at line 4600 of file sRef.c.

Referenced by exprNode_cast().

04601 {
04602   (void) sRef_aliasSetComplete (sRef_clearExKindAux, s, loc);
04603 }

void sRef_clearGlobalScope ( )
 

Definition at line 555 of file sRef.c.

Referenced by declareFunction(), declareStaticFunction(), and exprNode_iterNewId().

00556 {
00557   llassert (!inFunction);
00558   inFunction = TRUE;
00559 }

void sRef_clearGlobalScopeSafe ( )
 

Definition at line 569 of file sRef.c.

Referenced by uentry_makeUnrecognized().

00570 {
00571     inFunction = oldInFunction;
00572 }

void sRef_clearProtectDerivs ( void )
 

Definition at line 204 of file sRef.c.

Referenced by checkGlobReturn().

00205 {
00206   llassert (protectDerivs);
00207   protectDerivs = FALSE;
00208 }

int sRef_compare ( sRef s1,
sRef s2 )
 

Definition at line 1377 of file sRef.c.

01378 {
01379   if (s1 == s2) return 0;
01380 
01381   if (sRef_isInvalid (s1)) return -1;
01382   if (sRef_isInvalid (s2)) return 1;
01383       
01384   INTCOMPARERETURN (s1->kind, s2->kind);
01385   INTCOMPARERETURN (s1->defstate, s2->defstate);
01386   INTCOMPARERETURN (s1->aliaskind, s2->aliaskind);
01387 
01388   COMPARERETURN (nstate_compare (s1->nullstate, s2->nullstate));
01389 
01390   switch (s1->kind)
01391     {
01392     case SK_PARAM:
01393       return (int_compare (s1->info->paramno, s2->info->paramno));
01394     case SK_ARRAYFETCH:
01395       {
01396         COMPARERETURN (sRef_compare (s1->info->arrayfetch->arr, 
01397                                      s2->info->arrayfetch->arr));
01398         
01399         if (s1->info->arrayfetch->indknown && s2->info->arrayfetch->indknown)
01400           {
01401             return (int_compare (s1->info->arrayfetch->ind, 
01402                                  s2->info->arrayfetch->ind));
01403           }
01404         if (!s1->info->arrayfetch->indknown && !s2->info->arrayfetch->indknown)
01405           return 0;
01406         
01407         return 1;
01408       }
01409     case SK_FIELD:
01410       {
01411         COMPARERETURN (sRef_compare (s1->info->field->rec, s2->info->field->rec));
01412         
01413         if (cstring_equal (s1->info->field->field, s2->info->field->field))
01414           return 0;
01415 
01416         return 1;
01417       }
01418     case SK_PTR:
01419     case SK_ADR:
01420       return (sRef_compare (s1->info->ref, s2->info->ref));
01421     case SK_CONJ:
01422       COMPARERETURN (sRef_compare (s1->info->conj->a, s2->info->conj->a));
01423       return (sRef_compare (s1->info->conj->b, s2->info->conj->b));
01424     case SK_UNCONSTRAINED:
01425       return (cstring_compare (s1->info->fname, s2->info->fname));
01426     case SK_NEW:
01427     case SK_CVAR:
01428     case SK_UNKNOWN:
01429     case SK_OBJECT:
01430     case SK_TYPE:
01431     case SK_DERIVED:
01432     case SK_EXTERNAL:
01433     case SK_CONST:
01434     case SK_RESULT:
01435       return 0;
01436     case SK_SPECIAL:
01437       return (generic_compare (s1->info->spec, s2->info->spec));
01438     }
01439   BADEXIT;
01440 }

sRef sRef_constructDeadDeref ( sRef t )
 

Definition at line 6228 of file sRef.c.

06229 {
06230   return sRef_constructDerefAux (t, TRUE);
06231 }

sRef sRef_constructDeref ( sRef t )
 

Definition at line 6223 of file sRef.c.

06224 {
06225   return sRef_constructDerefAux (t, FALSE);
06226 }

sRef sRef_constructPointer ( sRef t )
 

Definition at line 6173 of file sRef.c.

Referenced by modListPointer(), and sRefSet_addIndirection().

06175 {
06176   return sRef_buildPointer (t);
06177 }

sRef sRef_copy ( sRef s )
 

Definition at line 5271 of file sRef.c.

Referenced by checkPassTransfer(), exprNode_cast(), globListAdd(), processNamedDecl(), sRefSet_newDeepCopy(), sRef_saveCopy(), storeRefNode_copy(), uentry_getOrigSref(), uentry_nameCopy(), and uentry_returnedRef().

05272 {
05273   if (sRef_isKindSpecial (s))
05274     {
05275       /*@-retalias@*/
05276       return s; /* don't copy specials */
05277       /*@=retalias@*/
05278     }
05279   
05280   if (sRef_isValid (s))
05281     {
05282       sRef t = sRef_alloc ();
05283 
05284       t->kind = s->kind;
05285       t->safe = s->safe;
05286       t->modified = s->modified;
05287       t->type = s->type;
05288 
05289             t->info = sinfo_copy (s);
05290       
05291       t->defstate = s->defstate;
05292 
05293       t->nullstate = s->nullstate;
05294 
05295       t->aliaskind = s->aliaskind;
05296       t->oaliaskind = s->oaliaskind;
05297 
05298       t->expkind = s->expkind;
05299       t->oexpkind = s->oexpkind;
05300 
05301       t->aliasinfo = alinfo_copy (s->aliasinfo);
05302       t->definfo = alinfo_copy (s->definfo);
05303       t->nullinfo = alinfo_copy (s->nullinfo);
05304       t->expinfo = alinfo_copy (s->expinfo);
05305 
05306       t->deriv = sRefSet_newDeepCopy (s->deriv);
05307       
05308       return t;
05309     }
05310   else
05311     {
05312       return sRef_undefined;
05313     }
05314 }

void sRef_copyRealDerivedComplete ( sRef s1,
sRef s2 )
 

Definition at line 4656 of file sRef.c.

04657 {
04658   sRef_innerAliasSetCompleteParam (sRef_copyRealDerived, s1, s2);
04659 }

void sRef_copyState ( sRef s1,
sRef s2 )
 

Definition at line 6534 of file sRef.c.

Referenced by uentry_copyState().

06535 {
06536   if (sRef_isValid (s1) && sRef_isValid (s2))
06537     {
06538       s1->defstate = s2->defstate;
06539       
06540       s1->nullstate = s2->nullstate;
06541       s1->nullinfo = alinfo_update (s1->nullinfo, s2->nullinfo);
06542 
06543       s1->aliaskind = s2->aliaskind;
06544       s1->aliasinfo = alinfo_update (s1->aliasinfo, s2->aliasinfo);
06545 
06546       s1->expkind = s2->expkind;
06547       s1->expinfo = alinfo_update (s1->expinfo, s2->expinfo);
06548 
06549       s1->safe = s2->safe;
06550           }
06551 }

bool sRef_deepPred ( bool(predf)(sRef),
sRef s )
 

Definition at line 299 of file sRef.c.

Referenced by usymtab_isAltProbablyDeepNull(), and usymtab_isProbableDeepNull().

00300 {
00301   if (sRef_isValid (s))
00302     {
00303       if ((*predf)(s)) return TRUE;
00304 
00305       switch  (s->kind)
00306         {
00307         case SK_PTR:
00308           return (sRef_deepPred (predf, s->info->ref));
00309         case SK_ARRAYFETCH:
00310           return (sRef_deepPred (predf, s->info->arrayfetch->arr));
00311         case SK_FIELD:
00312           return (sRef_deepPred (predf, s->info->field->rec));
00313         case SK_CONJ:
00314           return (sRef_deepPred (predf, s->info->conj->a)
00315                   || sRef_deepPred (predf, s->info->conj->b));
00316         default:
00317           return FALSE;
00318         }
00319     }
00320 
00321   return FALSE;
00322 }

bool sRef_definitelyNull ( sRef s )
 

Definition at line 7436 of file sRef.c.

Referenced by usymtab_checkFinalScope().

07437 {
07438   return (sRef_isValid (s)
07439           && (s->nullstate == NS_DEFNULL || s->nullstate == NS_CONSTNULL));
07440 }

ctype sRef_deriveType ( sRef s,
uentryList cl )
 

Definition at line 2369 of file sRef.c.

02370 {
02371   if (sRef_isInvalid (s)) return ctype_unknown;
02372 
02373   switch (s->kind)
02374     {
02375     case SK_CVAR:
02376       return (uentry_getType (usymtab_getRefQuiet (s->info->cvar->lexlevel, 
02377                                               s->info->cvar->index)));
02378     case SK_UNCONSTRAINED:
02379       return (ctype_unknown);
02380     case SK_PARAM:
02381       return uentry_getType (uentryList_getN (cl, s->info->paramno));
02382     case SK_ARRAYFETCH:
02383       {
02384         ctype ca = sRef_deriveType (s->info->arrayfetch->arr, cl);
02385         
02386         if (ctype_isArray (ca))
02387           {
02388             return (ctype_baseArrayPtr (ca));
02389           }
02390         else if (ctype_isUnknown (ca))
02391           {
02392             return (ca);
02393           }
02394         else
02395           {
02396             llcontbuglit ("sRef_deriveType: inconsistent array type");
02397             return ca;
02398           }
02399       }
02400     case SK_FIELD:
02401       {
02402         ctype ct = sRef_deriveType (s->info->field->rec, cl);
02403         
02404         if (ctype_isStructorUnion (ct))
02405           {
02406             uentry ue = uentryList_lookupField (ctype_getFields (ct), 
02407                                                s->info->field->field);
02408             
02409             if (uentry_isValid (ue))
02410               {
02411                 return (uentry_getType (ue));
02412               }
02413             else
02414               {
02415                 llcontbuglit ("sRef_deriveType: bad field");
02416                 return ctype_unknown;
02417               }
02418           }
02419         else if (ctype_isUnknown (ct))
02420           {
02421             return (ct);
02422           }
02423         else
02424           {
02425             llcontbuglit ("sRef_deriveType: inconsistent field type");
02426             return (ct);
02427           }
02428       }
02429     case SK_PTR:
02430       {
02431         ctype ct = sRef_deriveType (s->info->ref, cl);
02432         
02433         if (ctype_isUnknown (ct)) return ct;
02434         if (ctype_isPointer (ct)) return (ctype_baseArrayPtr (ct));
02435         else
02436           {
02437             llcontbuglit ("sRef_deriveType: inconsistent pointer type");
02438             return (ct);
02439           }
02440       }
02441     case SK_ADR:
02442       {
02443         ctype ct = sRef_deriveType (s->info->ref, cl);
02444         
02445         if (ctype_isUnknown (ct)) return ct;
02446         return ctype_makePointer (ct);
02447       }
02448     case SK_DERIVED:
02449       {
02450         return sRef_deriveType (s->info->ref, cl);
02451       }
02452     case SK_OBJECT:
02453       {
02454         return (s->info->object);
02455       }
02456     case SK_CONJ:
02457       {
02458         return (ctype_makeConj (sRef_deriveType (s->info->conj->a, cl),
02459                                sRef_deriveType (s->info->conj->b, cl)));
02460       }
02461     case SK_RESULT:
02462     case SK_CONST:
02463     case SK_TYPE:
02464       {
02465         return (s->type);
02466       }
02467     case SK_SPECIAL:
02468     case SK_UNKNOWN:
02469     case SK_EXTERNAL:
02470     case SK_NEW:
02471       return ctype_unknown;
02472     }
02473   BADEXIT;
02474 }

sRefSet sRef_derivedFields ( sRef rec )
 

Definition at line 5556 of file sRef.c.

05557 {
05558   if (sRef_isValid (rec))
05559     {
05560       sRefSet ret;
05561       ret = rec->deriv;
05562       return (ret);
05563     }
05564   else
05565     {
05566       return (sRefSet_undefined);
05567     }
05568 }

void sRef_destroyMod ( )
 

Definition at line 595 of file sRef.c.

Referenced by llexit().

00596 {
00597 # ifdef DEBUGREFS  
00598   llmsg (message ("Live: %d / %d ", nsrefs, totnsrefs));  
00599 # endif
00600 
00601   sRefTable_free (allRefs);
00602 }

cstring sRef_dump ( sRef s )
 

Definition at line 2262 of file sRef.c.

02263 {
02264   if (sRef_isInvalid (s))
02265     {
02266       return (cstring_makeLiteral ("-"));
02267     }
02268   else
02269     {
02270       switch (s->kind)
02271         {
02272         case SK_PARAM:
02273           return (message ("p%d", s->info->paramno));
02274         case SK_ARRAYFETCH:
02275           if (s->info->arrayfetch->indknown)
02276             {
02277               return (message ("a%d%q", s->info->arrayfetch->ind,
02278                                sRef_dump (s->info->arrayfetch->arr)));
02279             }
02280           else
02281             {
02282               return (message ("a%q", sRef_dump (s->info->arrayfetch->arr)));
02283             }
02284         case SK_FIELD:
02285           return (message ("f%s.%q", s->info->field->field, 
02286                            sRef_dump (s->info->field->rec)));
02287         case SK_PTR:
02288           return (message ("t%q", sRef_dump (s->info->ref)));
02289         case SK_ADR:
02290           return (message ("d%q", sRef_dump (s->info->ref)));
02291         case SK_OBJECT:
02292           return (message ("o%q", ctype_dump (s->info->object)));
02293         case SK_SPECIAL:
02294           return (message ("s%d", (int) s->info->spec));
02295         case SK_CONJ:
02296           return (message ("c%q.%q",
02297                            sRef_dump (s->info->conj->a),
02298                            sRef_dump (s->info->conj->b)));
02299         case SK_CVAR:
02300           if (sRef_isGlobal (s))
02301             {
02302               return (message ("g%d", 
02303                                usymtab_convertId (s->info->cvar->index)));
02304             }
02305           else
02306             {
02307               llcontbug (message ("Dumping local variable: %q",
02308                                   sRef_unparseDebug (s)));
02309               return (cstring_makeLiteral ("u"));
02310             }
02311         case SK_UNKNOWN:
02312           return (cstring_makeLiteral ("u"));
02313         case SK_RESULT:
02314           return (message ("r%q", ctype_dump (s->type)));
02315         case SK_TYPE:
02316         case SK_CONST:
02317         case SK_EXTERNAL:
02318         case SK_DERIVED:
02319         case SK_NEW:
02320         case SK_UNCONSTRAINED:
02321           llcontbug (message ("sRef_dump: bad kind: %q",
02322                               sRef_unparseFull (s)));
02323           return (cstring_makeLiteral ("x"));
02324         }
02325     }
02326      
02327   BADEXIT;
02328 }

cstring sRef_dumpGlobal ( sRef s )
 

Definition at line 2330 of file sRef.c.

02331 {
02332   if (sRef_isInvalid (s))
02333     {
02334       return (cstring_makeLiteral ("-"));
02335     }
02336   else
02337     {
02338       switch (s->kind)
02339         {
02340         case SK_CVAR:
02341           if (sRef_isGlobal (s))
02342             {
02343               return (message ("g%d@%d@%d", 
02344                                usymtab_convertId (s->info->cvar->index),
02345                                (int) s->defstate,
02346                                (int) s->nullstate));
02347             }
02348           else
02349             {
02350               llcontbug (message ("Dumping local variable: %q",
02351                                   sRef_unparseDebug (s)));
02352               return (cstring_makeLiteral ("u"));
02353             }
02354         case SK_UNKNOWN:
02355           return (cstring_makeLiteral ("u"));
02356         case SK_SPECIAL:
02357           return (message ("s%d", (int) s->info->spec));
02358         default:
02359           llcontbug (message ("sRef_dumpGlobal: bad kind: %q",
02360                               sRef_unparseFull (s)));
02361           return (cstring_makeLiteral ("x"));
02362         }
02363     }
02364      
02365   BADEXIT;
02366 }

void sRef_enterFunctionScope ( )
 

Definition at line 574 of file sRef.c.

Referenced by context_enterConstantMacro(), and context_enterFunction().

00575 {
00576   llassert (!inFunction);
00577   llassert (sRefTable_isEmpty (allRefs));
00578   inFunction = TRUE;
00579 }

void sRef_exitFunctionScope ( )
 

Definition at line 581 of file sRef.c.

Referenced by context_exitFunction(), and context_quietExitFunction().

00582 {
00583   
00584   if (inFunction)
00585     {
00586       sRefTable_clear (allRefs);
00587       inFunction = FALSE;
00588     }
00589   else
00590     {
00591       llbuglit ("sRef_exitFunctionScope: not in function");
00592     }
00593 }

sRef sRef_fixBase ( sRef s,
sRef base )
 

Definition at line 6902 of file sRef.c.

Referenced by aliasTable_clearAliases(), checkReturnTransfer(), sRef_fixOuterRef(), uentry_returnedRef(), and usymtab_checkFinalScope().

06903 {
06904   sRef tmp = sRef_undefined;
06905   sRef ret;
06906 
06907   if (sRef_isInvalid (s)) return s;
06908   if (sRef_isInvalid (base)) return base;
06909 
06910   switch (s->kind)
06911     {
06912     case SK_RESULT:
06913     case SK_PARAM:
06914     case SK_CVAR:
06915       ret = base;
06916       break;
06917     case SK_ARRAYFETCH:
06918       tmp = sRef_fixBase (s->info->arrayfetch->arr, base);
06919 
06920       if (s->info->arrayfetch->indknown)
06921         {
06922           ret = sRef_makeArrayFetchKnown (tmp, s->info->arrayfetch->ind);
06923         }
06924       else
06925         {
06926           ret = sRef_makeArrayFetch (tmp);
06927         }
06928       break;
06929     case SK_FIELD:
06930       tmp = sRef_fixBase (s->info->field->rec, base);
06931       ret = sRef_buildNCField (tmp, s->info->field->field);
06932       break;
06933     case SK_PTR:
06934       tmp = sRef_fixBase (s->info->ref, base);
06935       ret = sRef_makePointer (tmp);
06936       break;
06937     case SK_ADR:
06938       tmp = sRef_fixBase (s->info->ref, base);
06939       ret = sRef_makeAddress (tmp);
06940       break;
06941     case SK_CONJ:
06942       {
06943         sRef tmpb;
06944 
06945         tmp = sRef_fixBase (s->info->conj->a, base);
06946         tmpb = sRef_fixBase (s->info->conj->b, base);
06947 
06948         ret = sRef_makeConj (tmp, tmpb);
06949         break;
06950       }
06951       BADDEFAULT;
06952     }
06953 
06954   return ret;
06955 }

sRef sRef_fixBaseParam ( sRef s,
exprNodeList args )
 

Definition at line 2039 of file sRef.c.

Referenced by exprNode_checkCallModifyVal().

02040 {
02041   if (sRef_isInvalid (s)) return (sRef_undefined);
02042 
02043   switch (s->kind)
02044     {
02045     case SK_UNCONSTRAINED:
02046     case SK_CVAR:
02047       return s;
02048     case SK_PARAM:
02049       {
02050         if (exprNodeList_size (args) > s->info->paramno)
02051           {
02052             exprNode e = exprNodeList_nth (args, s->info->paramno);
02053 
02054             if (exprNode_isError (e))
02055               {
02056                 return sRef_makeUnknown ();
02057               }
02058             
02059             return (exprNode_getSref (e));
02060           }
02061         else
02062           {
02063             return sRef_makeUnknown ();
02064           }
02065       }
02066     case SK_ARRAYFETCH:
02067 
02068       if (s->info->arrayfetch->indknown)
02069         {
02070           return (sRef_makeArrayFetchKnown 
02071                   (sRef_fixBaseParam (s->info->arrayfetch->arr, args),
02072                    s->info->arrayfetch->ind));
02073         }
02074       else
02075         {
02076           return (sRef_makeArrayFetch 
02077                   (sRef_fixBaseParam (s->info->arrayfetch->arr, args)));
02078         }
02079     case SK_FIELD:
02080       return (sRef_makeField (sRef_fixBaseParam (s->info->field->rec, args),
02081                               s->info->field->field));
02082 
02083     case SK_PTR:
02084       return (sRef_makePointer (sRef_fixBaseParam (s->info->ref, args)));
02085 
02086     case SK_ADR:
02087       return (sRef_makeAddress (sRef_fixBaseParam (s->info->ref, args)));
02088 
02089     case SK_CONJ:
02090       return (sRef_makeConj (sRef_fixBaseParam (s->info->conj->a, args),
02091                              sRef_fixBaseParam (s->info->conj->b, args)));
02092     case SK_DERIVED:
02093     case SK_SPECIAL:
02094     case SK_TYPE:
02095     case SK_CONST:
02096     case SK_NEW:
02097     case SK_UNKNOWN:
02098     case SK_OBJECT:
02099     case SK_EXTERNAL:
02100     case SK_RESULT:
02101       return s;
02102     }
02103   BADEXIT;
02104 }

sRef sRef_fixOuterRef ( sRef s )
 

Definition at line 6811 of file sRef.c.

06812 {
06813   sRef root = sRef_getRootBase (s);
06814 
06815   if (sRef_isCvar (root))
06816     {
06817       uentry ue = usymtab_getRefQuiet (root->info->cvar->lexlevel, 
06818                                        root->info->cvar->index);
06819 
06820       if (uentry_isValid (ue))
06821         {
06822           sRef uref = uentry_getSref (ue);
06823           sRef sr = sRef_fixBase (s, uref);
06824 
06825           return (sr);
06826         }
06827       else
06828         {
06829           llcontbug (message ("sRef_fixOuterRef: undefined: %q", sRef_unparseDebug (s)));
06830           return (s);
06831         }
06832     }
06833 
06834   return (s);
06835 }

sRef sRef_fixResultType ( sRef s,
ctype typ,
uentry ue )
 

Definition at line 8763 of file sRef.c.

Referenced by specialClauses_checkAll().

08764 {
08765   sRef tmp = sRef_undefined;
08766   sRef ret;
08767 
08768   llassert (sRef_isValid (s));
08769 
08770   switch (s->kind)
08771     {
08772     case SK_RESULT:
08773       s->type = typ;
08774       ret = s;
08775       break;
08776     case SK_ARRAYFETCH:
08777       {
08778         ctype ct;
08779         tmp = sRef_fixResultType (s->info->arrayfetch->arr, typ, ue);
08780 
08781         ct = ctype_realType (sRef_getType (tmp));
08782 
08783         
08784         if (ctype_isKnown (ct))
08785           {
08786             if (ctype_isAP (ct))
08787               {
08788                 ;
08789               }
08790             else
08791               {
08792                 voptgenerror 
08793                   (FLG_TYPE,
08794                    message
08795                    ("Special clause indexes non-array (%t): *%q",
08796                     ct, sRef_unparse (s->info->arrayfetch->arr)),
08797                    uentry_whereLast (ue));
08798               }
08799           }
08800 
08801         tmp = sRef_fixResultType (s->info->arrayfetch->arr, typ, ue);
08802 
08803         if (s->info->arrayfetch->indknown)
08804           {
08805             ret = sRef_makeArrayFetchKnown (tmp, s->info->arrayfetch->ind);
08806           }
08807         else
08808           {
08809             ret = sRef_makeArrayFetch (tmp);
08810           }
08811       }
08812       break;
08813     case SK_FIELD:
08814       {
08815         sRef rec = sRef_fixResultType (s->info->field->rec, typ, ue);
08816         ctype ct = ctype_realType (sRef_getType (rec));
08817 
08818         if (ctype_isKnown (ct))
08819           {
08820             if (ctype_isSU (ct))
08821               {
08822                 if (uentry_isValid (uentryList_lookupField (ctype_getFields (ct), 
08823                                                             s->info->field->field)))
08824                   {
08825                     ;
08826                   }
08827                 else
08828                   {
08829                     voptgenerror 
08830                       (FLG_TYPE,
08831                        message
08832                        ("Special clause accesses non-existent field of result: %q.%s",
08833                         sRef_unparse (rec), s->info->field->field),
08834                        uentry_whereLast (ue));
08835                   }
08836               }
08837             else
08838               {
08839                 voptgenerror 
08840                   (FLG_TYPE,
08841                    message
08842                    ("Special clause accesses field of non-struct or union result (%t): %q.%s",
08843                     ct, sRef_unparse (rec), s->info->field->field),
08844                    uentry_whereLast (ue));
08845               }
08846           }
08847         
08848         ret = sRef_makeField (tmp, s->info->field->field);
08849         break;
08850       }
08851     case SK_PTR:
08852       {
08853         ctype ct;
08854         tmp = sRef_fixResultType (s->info->ref, typ, ue);
08855 
08856         ct = ctype_realType (sRef_getType (tmp));
08857 
08858         if (ctype_isKnown (ct))
08859           {
08860             if (ctype_isAP (ct))
08861               {
08862                 ;
08863               }
08864             else
08865               {
08866                 voptgenerror 
08867                   (FLG_TYPE,
08868                    message
08869                    ("Special clause dereferences non-pointer (%t): *%q",
08870                     ct, sRef_unparse (s->info->ref)),
08871                    uentry_whereLast (ue));
08872               }
08873           }
08874         
08875         ret = sRef_makePointer (tmp);
08876         break;
08877       }
08878     case SK_ADR:
08879       voptgenerror 
08880         (FLG_TYPE,
08881          message
08882          ("Special clause uses & operator (not allowed): &%q", sRef_unparse (s->info->ref)),
08883          uentry_whereLast (ue));
08884       ret = s;
08885       break;
08886     BADDEFAULT;
08887     }
08888 
08889   return ret;
08890 }

void sRef_free ( sRef s )
 

Definition at line 5494 of file sRef.c.

Referenced by sRefTable_clear(), sRefTable_free(), and uentry_freeComplete().

05495 {
05496   if (s != sRef_undefined && s->kind != SK_SPECIAL)
05497     {
05498       alinfo_free (s->expinfo);
05499       alinfo_free (s->aliasinfo);
05500       alinfo_free (s->definfo);
05501       alinfo_free (s->nullinfo);
05502       
05503       sRefSet_free (s->deriv);
05504       s->deriv = sRefSet_undefined;
05505       sinfo_free (s);
05506       
05507       sfree (s); 
05508     }
05509 }

sRef sRef_getAliasInfoRef ( sRef s )
 

Definition at line 513 of file sRef.c.

Referenced by usymtab_checkFinalScope().

00514 {
00515   llassert (sRef_isValid (s) && s->aliasinfo != NULL);
00516   return (s->aliasinfo->ref);
00517 }

sRef sRef_getBase ( sRef s )
 

Definition at line 3041 of file sRef.c.

Referenced by sRef_isRecursiveField(), sRef_isThroughArrayFetch(), and sRef_setModified().

03042 {
03043   sRef res;
03044 
03045   if (sRef_isInvalid (s)) return (sRef_undefined);
03046 
03047   s = sRef_fixConj (s);
03048 
03049   switch (s->kind)
03050     {
03051     case SK_ADR:
03052     case SK_PTR:
03053     case SK_DERIVED:
03054     case SK_EXTERNAL:
03055       res = s->info->ref;
03056       break;
03057     case SK_FIELD:
03058       res = s->info->field->rec;
03059       break;
03060 
03061     case SK_ARRAYFETCH:
03062       res = s->info->arrayfetch->arr;
03063       break;
03064 
03065     default:
03066       res = sRef_undefined; /* shouldn't need it */
03067     }
03068 
03069   return (res);
03070 }

sRef sRef_getBaseSafe ( sRef s )
 

Definition at line 3078 of file sRef.c.

Referenced by checkAssignTransfer(), exprNode_checkSet(), sRef_clearDerivedComplete(), sRef_isRecursiveField(), sRef_kill(), sRef_maybeKill(), sRef_setKept(), and sRef_setPdefined().

03079 {
03080   sRef res;
03081 
03082   if (sRef_isInvalid (s)) { return sRef_undefined; }
03083 
03084   s = sRef_fixConj (s);
03085 
03086   switch (s->kind)
03087     {
03088     case SK_PTR:
03089             res = s->info->ref; 
03090       break;
03091     case SK_FIELD:
03092             res = s->info->field->rec; break;
03093     case SK_ARRAYFETCH:
03094             res = s->info->arrayfetch->arr; 
03095       break;
03096     default:
03097       res = sRef_undefined; break;
03098     }
03099 
03100   return res;
03101 }

uentry sRef_getBaseUentry ( sRef s )
 

Definition at line 708 of file sRef.c.

Referenced by exprNode_checkMSet(), and exprNode_checkSet().

00709 {
00710   sRef base = sRef_getRootBase (s);
00711   uentry res = uentry_undefined;
00712   
00713   if (sRef_isValid (base))
00714     {
00715       switch (base->kind)
00716         {
00717         case SK_PARAM:
00718           res = usymtab_getRefQuiet (paramsScope, base->info->paramno);
00719           break;
00720 
00721         case SK_CVAR:
00722           res = usymtab_getRefQuiet (base->info->cvar->lexlevel, 
00723                                      base->info->cvar->index);
00724           break;
00725 
00726         default:
00727           break;
00728         }  
00729     }
00730 
00731   return res;
00732 }

sRef sRef_getConjA ( sRef s )
 

Definition at line 8310 of file sRef.c.

08311 {
08312   sRef ret;
08313   llassert (sRef_isConj (s));
08314 
08315   ret = s->info->conj->a;
08316   llassert (ret != NULL);
08317   return ret;
08318 }

sRef sRef_getConjB ( sRef s )
 

Definition at line 8320 of file sRef.c.

08321 {
08322   sRef ret;
08323   llassert (sRef_isConj (s));
08324 
08325   ret = s->info->conj->b;
08326   llassert (ret != NULL);
08327   return ret;
08328 }

sstate sRef_getDefState ( sRef s )
 

Definition at line 4511 of file sRef.c.

Referenced by uentry_getDefState().

04512 {
04513   if (sRef_isInvalid (s)) return (SS_UNKNOWN);
04514   return (s->defstate);
04515 }

exkind sRef_getExKind ( sRef s )
 

Definition at line 4561 of file sRef.c.

Referenced by uentryList_fixImpParams(), uentry_checkMatchParam(), and uentry_getExpKind().

04562 {
04563   if (sRef_isValid (s))
04564     {
04565       return (s->expkind);
04566     }
04567   else
04568     {
04569       return XO_UNKNOWN;
04570     }
04571 }

cstring sRef_getField ( sRef s )
 

Definition at line 3027 of file sRef.c.

Referenced by sRef_isRecursiveField().

03028 {
03029   cstring res;
03030 
03031   llassert (sRef_isValid (s));
03032   s = sRef_fixConj (s);
03033 
03034   llassertprint (sRef_isValid (s) && (s->kind == SK_FIELD),
03035                  ("s = %s", sRef_unparseDebug (s)));
03036 
03037   res = s->info->field->field;
03038   return (res);
03039 }

int sRef_getIndex ( sRef arr )
 

Definition at line 2954 of file sRef.c.

02955 {
02956   int result;
02957 
02958   llassert (sRef_isValid (arr));
02959   arr = sRef_fixConj (arr);
02960 
02961   llassert (arr->kind == SK_ARRAYFETCH);  
02962 
02963   if (!arr->info->arrayfetch->indknown)
02964     {
02965       llcontbug (message ("sRef_getIndex: unknown: %q", sRef_unparse (arr)));
02966       result = 0; 
02967     }
02968   else
02969     {
02970       result = arr->info->arrayfetch->ind;
02971     }
02972 
02973   return result;
02974 }

exkind sRef_getOrigExKind ( sRef s )
 

Definition at line 4573 of file sRef.c.

Referenced by uentry_compare(), and uentry_makeVarFunction().

04574 {
04575   if (sRef_isValid (s))
04576     {
04577       return (s->oexpkind);
04578     }
04579   else
04580     {
04581       return XO_UNKNOWN;
04582     }
04583 }

int sRef_getParam ( sRef s )
 

Definition at line 892 of file sRef.c.

00893 {
00894   llassert (sRef_isValid (s));
00895   llassert (s->kind == SK_PARAM);
00896 
00897   return s->info->paramno;
00898 }

sRef sRef_getRootBase ( sRef s )
 

Definition at line 3141 of file sRef.c.

Referenced by aliasTable_checkGlobs(), aliasTable_clearAliases(), checkReturnTransfer(), exprNode_assign(), sRef_fixOuterRef(), sRef_getBaseUentry(), sRef_getScopeName(), sRef_lexLevel(), sRef_unparseOpt(), sRef_unparsePreOpt(), sRef_unparseScope(), specialClauses_checkAll(), uentry_returnedRef(), usymtab_checkFinalScope(), and usymtab_unguard().

03142 {
03143   return (sRef_getRootBaseAux (s, 0));
03144 }

int sRef_getScope ( sRef s )
 

Definition at line 7281 of file sRef.c.

Referenced by uentry_checkName().

07282 {
07283   llassert (sRef_isValid (s));
07284 
07285   if (sRef_isCvar (s))
07286     {
07287       return s->info->cvar->lexlevel;
07288     }
07289   else if (sRef_isParam (s))
07290     {
07291       return paramsScope;
07292     }
07293   else
07294     {
07295       return fileScope;
07296     }
07297 }

usymId sRef_getScopeIndex ( sRef s )
 

Definition at line 4138 of file sRef.c.

Referenced by usymtab_enterFunctionScope(), and usymtab_exitScope().

04139 {
04140   llassert (sRef_isValid (s));
04141   llassert (sRef_isCvar (s));
04142 
04143   return (s->info->cvar->index);
04144 }

cstring sRef_getScopeName ( sRef s )
 

Definition at line 7243 of file sRef.c.

07244 {
07245   sRef base = sRef_getRootBase (s);
07246 
07247   if (sRef_isRealGlobal (base))
07248     {
07249       return (cstring_makeLiteralTemp ("Global"));
07250     }
07251   else if (sRef_isFileStatic (base))
07252     {
07253       return (cstring_makeLiteralTemp ("Static"));
07254     }
07255   else
07256     {
07257       return (cstring_makeLiteralTemp ("Local"));
07258     }
07259 }

ctype sRef_getType ( sRef s )
 

Definition at line 2477 of file sRef.c.

Referenced by modListArrayFetch(), modListArrowAccess(), modListFieldAccess(), modListPointer(), and usymtab_enterFunctionScope().

02478 {
02479   if (sRef_isInvalid (s)) return ctype_unknown;
02480   return s->type;
02481 }

uentry sRef_getUentry ( sRef s )
 

Definition at line 862 of file sRef.c.

Referenced by context_checkGlobMod(), exprNode_assign(), sRef_isAliasCheckedGlobal(), sRef_isMacroParamRef(), sRef_isNSLocalVar(), sRef_isRealLocalVar(), sRef_similarRelaxed(), sRef_updateSref(), and usymtab_checkFinalScope().

00863 {
00864   llassert (sRef_isValid (s));
00865 
00866   switch (s->kind)
00867     {
00868     case SK_PARAM:
00869       return (usymtab_getRefQuiet (paramsScope, s->info->paramno));
00870     case SK_CVAR:
00871       return (usymtab_getRefQuiet (s->info->cvar->lexlevel, s->info->cvar->index));
00872     case SK_CONJ:
00873       {
00874         if (sRef_isCvar (s->info->conj->a) || sRef_isParam (s->info->conj->a)
00875             || sRef_isConj (s->info->conj->a))
00876           {
00877             return sRef_getUentry (s->info->conj->a);
00878           }
00879         else 
00880           {
00881             return sRef_getUentry (s->info->conj->b);
00882           }
00883       }
00884     case SK_UNKNOWN:
00885     case SK_SPECIAL:
00886       return uentry_undefined;
00887     BADDEFAULT;
00888     }
00889 }

bool sRef_hasAliasInfoRef ( sRef s )
 

Definition at line 474 of file sRef.c.

00475 {
00476   return (sRef_isValid (s) && (s->aliasinfo != NULL) 
00477           && (sRef_isValid (s->aliasinfo->ref)));
00478 }

bool sRef_hasDerived ( sRef s )
 

Definition at line 6283 of file sRef.c.

Referenced by usymtab_enterFile().

06284 {
06285   return (sRef_isValid (s) && !sRefSet_isEmpty (s->deriv));
06286 }

bool sRef_hasName ( sRef s )
 

Definition at line 6639 of file sRef.c.

06640 {
06641   if (sRef_isInvalid (s))
06642     {
06643       return (FALSE);
06644     }
06645 
06646   switch (s->kind)
06647     {
06648     case SK_CVAR:
06649       {
06650         uentry u = usymtab_getRefQuiet (s->info->cvar->lexlevel,
06651                                          s->info->cvar->index);
06652         return (uentry_hasName (u));
06653       }
06654     case SK_PARAM:
06655       {
06656         uentry u = uentryList_getN (context_getParams (), 
06657                                     s->info->paramno);
06658 
06659         return (uentry_hasName (u));
06660       }
06661     default:
06662       return TRUE;
06663     }
06664 }

bool sRef_hasNoStorage ( sRef s )
 

Definition at line 4253 of file sRef.c.

04254 {
04255   return (!sRef_isAllocatedStorage (s) || sRef_isDefinitelyNull (s));
04256 }

bool sRef_includedBy ( sRef small,
sRef big )
 

Definition at line 1733 of file sRef.c.

Referenced by sRefSet_deleteBase(), and sRef_similar().

01734 {
01735   if (small == big) return TRUE;
01736   if (sRef_isInvalid (small) || sRef_isInvalid (big)) return FALSE;
01737 
01738   if (sRef_isConj (big)) 
01739     return (sRef_similar (small, sRef_getConjA (big)) ||
01740             sRef_similar (small, sRef_getConjB (big)));
01741 
01742   switch (small->kind)
01743     {
01744     case SK_CVAR:
01745     case SK_PARAM:
01746       return (sRef_same (small, big));
01747     case SK_ARRAYFETCH:
01748       if (big->kind == SK_ARRAYFETCH)
01749         {
01750           if (sRef_same (small->info->arrayfetch->arr, big->info->arrayfetch->arr))
01751             {
01752               if (small->info->arrayfetch->indknown)
01753                 {
01754                   if (big->info->arrayfetch->indknown)
01755                     {
01756                       return (small->info->arrayfetch->ind == big->info->arrayfetch->ind);
01757                     }
01758                   else 
01759                     {
01760                       return TRUE;
01761                     }
01762                 }
01763               else
01764                 {
01765                   return TRUE;
01766                 }
01767             }
01768         }
01769       return (sRef_includedBy (small->info->arrayfetch->arr, big));
01770     case SK_FIELD:
01771       if (big->kind == SK_FIELD)
01772         {
01773           return 
01774             (sRef_same (small->info->field->rec, big->info->field->rec) &&
01775              cstring_equal (small->info->field->field, big->info->field->field));
01776         }
01777       else
01778         {
01779           return (sRef_includedBy (small->info->field->rec, big));
01780         }
01781 
01782     case SK_PTR:
01783       if (big->kind == SK_PTR)
01784         {
01785           return sRef_same (small->info->ref, big->info->ref);
01786         }
01787       else
01788         {
01789           return (sRef_includedBy (small->info->ref, big));
01790         }
01791 
01792     case SK_ADR:
01793       return ((big->kind == SK_ADR) && sRef_similar (small->info->ref, big->info->ref));
01794     case SK_CONJ:
01795       return ((sRef_includedBy (small->info->conj->a, big) ||
01796               (sRef_includedBy (small->info->conj->b, big))));
01797     case SK_DERIVED:
01798       return (sRef_includedBy (small->info->ref, big));
01799     case SK_UNCONSTRAINED:
01800     case SK_CONST:
01801     case SK_TYPE:
01802     case SK_NEW:
01803     case SK_UNKNOWN:
01804     case SK_OBJECT:
01805     case SK_EXTERNAL:
01806     case SK_RESULT:
01807       return FALSE;
01808     case SK_SPECIAL:
01809       switch (small->info->spec)
01810         {
01811         case SR_NOTHING: return TRUE;
01812         case SR_SPECSTATE:
01813         case SR_INTERNAL: return (sRef_isSpecInternalState (big) ||
01814                                   sRef_isFileStatic (big));
01815         case SR_SYSTEM: return (sRef_isSystemState (big));
01816         }
01817     }
01818   BADEXIT;
01819 }

bool sRef_isAddress ( sRef s )
 

Definition at line 5323 of file sRef.c.

Referenced by checkPassTransfer(), sRefSet_removeIndirection(), sRef_buildPointer(), sRef_isIReference(), sRef_makeAnyArrayFetch(), usymtab_addForceMustAlias(), and usymtab_addMustAlias().

05324 {
05325   PREDTEST (sRef_isAddress, s);
05326   return (s->kind == SK_ADR);
05327 }

bool sRef_isAliasCheckedGlobal ( sRef s )
 

Definition at line 5480 of file sRef.c.

Referenced by aliasTable_checkGlobs().

05481 {
05482   if (sRef_isGlobal (s))
05483     {
05484       uentry ue = sRef_getUentry (s);
05485 
05486       return context_checkAliasGlob (ue);
05487     }
05488   else
05489     {
05490       return FALSE;
05491     }
05492 }

bool sRef_isAllocIndexRef ( sRef s )
 

Definition at line 7007 of file sRef.c.

07008 {
07009   return (sRef_isArrayFetch (s) && !(s->info->arrayfetch->indknown) 
07010           && sRef_isAllocated (s->info->arrayfetch->arr));
07011 }

bool sRef_isAllocated ( sRef s )
 

Definition at line 8953 of file sRef.c.

Referenced by exprNode_assign(), exprNode_checkSet(), sRef_isAllocIndexRef(), sRef_isJustAllocated(), sRef_isReallyDefined(), sRef_showNotReallyDefined(), uentry_isOut(), uentry_isPartial(), usymtab_enterFunctionScope(), and usymtab_popAndBranch().

08954 {
08955   return (sRef_isValid (s) && (s->defstate == SS_ALLOCATED));
08956 }

bool sRef_isAnyParam ( sRef s )
 

Definition at line 5419 of file sRef.c.

Referenced by aliasTable_checkGlobs(), sRef_unparseKindName(), and sRef_unparseKindNamePlain().

05420 {
05421   PREDTEST (sRef_isAnyParam, s);
05422   return (s->kind == SK_PARAM);  
05423 }

bool sRef_isArrayFetch ( sRef s )
 

Definition at line 5356 of file sRef.c.

Referenced by sRef_isAllocIndexRef(), sRef_isIReference(), and sRef_isThroughArrayFetch().

05357 {
05358   PREDTEST (sRef_isArrayFetch, s);
05359   return (s->kind == SK_ARRAYFETCH);
05360 }

bool sRef_isConst ( sRef s )
 

Definition at line 5383 of file sRef.c.

Referenced by checkAssignTransfer(), globSet_insert(), sRef_kill(), sRef_setDependent(), sRef_setKept(), sRef_setOwned(), sRef_unparseOpt(), sRef_unparsePreOpt(), usymtab_addForceMustAlias(), and usymtab_addMustAlias().

05384 {
05385   PREDTEST (sRef_isConst, s);
05386   return (s->kind == SK_CONST);
05387 }

bool sRef_isCvar ( sRef s )
 

Definition at line 5377 of file sRef.c.

Referenced by aliasTable_clearAliases(), checkInitTransfer(), sRef_fixOuterRef(), sRef_getScope(), sRef_getUentry(), sRef_isFileStatic(), sRef_isGlobal(), sRef_isMacroParamRef(), sRef_isRealGlobal(), sRef_similarRelaxed(), usymtab_exitScope(), and usymtab_unguard().

05378 {
05379   PREDTEST (sRef_isCvar, s);
05380   return (s->kind == SK_CVAR);
05381 }

bool sRef_isDead ( sRef s )
 

Definition at line 7300 of file sRef.c.

Referenced by aliasTable_checkGlobs(), checkPassTransfer(), exprNode_checkSet(), sRef_stateAltVerb(), sRef_stateVerb(), specialClause_preErrorString(), uentry_mergeState(), uentry_returnedRef(), and usymtab_checkFinalScope().

07301 {
07302   return (sRef_isValid (s) && (s)->defstate == SS_DEAD);
07303 }

bool sRef_isDeadStorage ( sRef s )
 

Definition at line 7306 of file sRef.c.

07307 {
07308   if (sRef_isValid (s))
07309     {
07310       if (s->defstate == SS_DEAD
07311           || s->defstate == SS_UNUSEABLE
07312           || s->defstate == SS_UNDEFINED
07313           || s->defstate == SS_UNKNOWN)
07314         {
07315           return TRUE;
07316         }
07317       else 
07318         {
07319           return (sRef_isDefinitelyNull (s));
07320         }
07321     }
07322   else
07323     {
07324       return FALSE;
07325     }
07326 }

bool sRef_isDefinitelyNull ( sRef s )
 

Definition at line 8947 of file sRef.c.

Referenced by sRef_hasNoStorage(), sRef_isDeadStorage(), specialClause_postErrorString(), and specialClause_preErrorString().

08948 {
08949   return (sRef_isValid (s) && (s->nullstate == NS_DEFNULL 
08950                                || s->nullstate == NS_CONSTNULL));
08951 }

bool sRef_isDependent ( sRef s )
 

Definition at line 8897 of file sRef.c.

Referenced by sRef_stateAltVerb(), sRef_stateVerb(), specialClause_preErrorString(), uentry_mergeState(), and usymtab_checkFinalScope().

08898 {
08899   return (sRef_isValid(s) && alkind_isDependent (s->aliaskind));
08900 }

bool sRef_isDirectParam ( sRef s )
 

Definition at line 5431 of file sRef.c.

Referenced by usymtab_addForceMustAlias(), and usymtab_addMustAlias().

05432 {
05433   PREDTEST (sRef_isDirectParam, s);
05434 
05435   return ((s->kind == SK_CVAR) &&
05436           (s->info->cvar->lexlevel == functionScope) &&
05437           (context_inFunction () && 
05438            (s->info->cvar->index <= uentryList_size (context_getParams ()))));
05439 }

bool sRef_isExposed ( sRef s )
 

Definition at line 8932 of file sRef.c.

Referenced by aliasTable_checkGlobs(), checkAssignTransfer(), checkLocalDestroyed(), checkStructDestroyed(), exprNode_cast(), sRef_similarRelaxed(), and specialClause_preErrorString().

08933 {
08934   return (sRef_isValid (s) && (s->expkind == XO_EXPOSED));
08935 }

bool sRef_isExternal ( sRef s )
 

Definition at line 5395 of file sRef.c.

05396 {
05397   PREDTEST (sRef_isExternal, s);
05398   return (s->kind == SK_EXTERNAL);
05399 }

bool sRef_isExternallyVisible ( sRef s )
 

Definition at line 702 of file sRef.c.

Referenced by exprNode_cast().

00703 {
00704   return (sRef_aliasCheckSimplePred (sRef_isExternallyVisibleAux, s));
00705 }

bool sRef_isField ( sRef s )
 

Definition at line 5407 of file sRef.c.

Referenced by exprNode_assign(), sRef_isIReference(), sRef_isRecursiveField(), and sRef_isReference().

05408 {
05409   PREDTEST (sRef_isField, s);
05410   return (s->kind == SK_FIELD);
05411 }

bool sRef_isFileStatic ( sRef s )
 

Definition at line 5475 of file sRef.c.

Referenced by globSet_hasStatic(), processNamedDecl(), sRefSet_clearStatics(), sRef_getScopeName(), sRef_includedBy(), sRef_unparseScope(), uentry_isFileStatic(), usymtab_enterFunctionScope(), and usymtab_exitScope().

05476 {
05477   return (sRef_isCvar (s) && (s->info->cvar->lexlevel == fileScope));
05478 }

bool sRef_isFresh ( sRef s )
 

Definition at line 8942 of file sRef.c.

Referenced by checkPassTransfer(), sRef_showAliasInfo(), and usymtab_checkFinalScope().

08943 {
08944   return (sRef_isValid (s) && (s->aliaskind == AK_FRESH));
08945 }

bool sRef_isGlobal ( sRef s )
 

Definition at line 5465 of file sRef.c.

Referenced by checkInitTransfer(), checkSpecClausesId(), fixSpecClausesId(), sRef_dump(), sRef_dumpGlobal(), sRef_isAliasCheckedGlobal(), sRef_isReference(), uentry_isGlobal(), uentry_isNonLocal(), and usymtab_checkFinalScope().

05466 {
05467   return (sRef_isCvar (s) && (s->info->cvar->lexlevel <= fileScope));
05468 }

bool sRef_isIReference ( sRef s )
 

Definition at line 5459 of file sRef.c.

05460 {
05461   return (sRef_isPointer (s) || sRef_isAddress (s) || sRef_isIndex (s)
05462           || sRef_isField (s) || sRef_isArrayFetch (s));
05463 }

bool sRef_isIndexKnown ( sRef arr )
 

Definition at line 2941 of file sRef.c.

Referenced by sRef_unparseKindName(), and sRef_unparseKindNamePlain().

02942 {
02943   bool res;
02944 
02945   llassert (sRef_isValid (arr));
02946   arr = sRef_fixConj (arr);
02947   
02948   llassert (arr->kind == SK_ARRAYFETCH);  
02949   res = arr->info->arrayfetch->indknown;
02950   return (res);
02951 }

bool sRef_isInternalState ( sRef s )
 

Definition at line 4107 of file sRef.c.

Referenced by exprNode_checkAllMods().

04108 {
04109   return (sRef_isKindSpecial (s) && s->info->spec == SR_INTERNAL);
04110 }

bool sRef_isJustAllocated ( sRef s )
 

Definition at line 7357 of file sRef.c.

Referenced by exprNode_assign().

07358 {
07359   if (sRef_isAllocated (s))
07360     {
07361       sRefSet_allElements (s->deriv, el)
07362         {
07363           if (!(sRef_isStateUndefined (el) || sRef_isUnuseable (el)))
07364             {
07365               return FALSE;
07366             }
07367         } end_sRefSet_allElements ;
07368 
07369       return TRUE;
07370     }
07371 
07372   return FALSE;
07373 }

bool sRef_isKeep ( sRef s )
 

Definition at line 8907 of file sRef.c.

Referenced by usymtab_checkFinalScope().

08908 {
08909   return (sRef_isValid (s) && (s->aliaskind == AK_KEEP));
08910 }

bool sRef_isLocalParamVar ( sRef s )
 

Definition at line 8668 of file sRef.c.

Referenced by uentry_mergeState().

08669 {
08670   if (sRef_isValid(s))
08671     {
08672       return (s->kind == SK_PARAM
08673               || (s->kind == SK_CVAR 
08674                   && (s->info->cvar->lexlevel > fileScope)));
08675     }
08676   
08677   return FALSE;
08678 }

bool sRef_isLocalState ( sRef s )
 

Definition at line 8917 of file sRef.c.

Referenced by checkAssignTransfer(), uentry_mergeState(), and usymtab_checkFinalScope().

08918 {
08919   return (sRef_isValid (s) && (s->aliaskind == AK_LOCAL));
08920 }

bool sRef_isLocalVar ( sRef s )
 

Definition at line 8627 of file sRef.c.

Referenced by aliasTable_clearAliases(), aliasTable_fixSrefs(), exprNode_createId(), exprNode_functionCall(), processNamedDecl(), sRefSet_fixSrefs(), sRef_isNSLocalVar(), sRef_makeAddress(), sRef_unparseKindName(), sRef_unparseKindNamePlain(), uentry_setUsed(), usymtab_addForceMustAlias(), usymtab_addMustAlias(), and usymtab_checkFinalScope().

08628 {
08629   if (sRef_isValid(s))
08630     {
08631       return (s->kind == SK_CVAR 
08632               && (s->info->cvar->lexlevel > fileScope));
08633     }
08634   
08635   return FALSE;
08636 }

bool sRef_isMacroParamRef ( sRef s )
 

Definition at line 5362 of file sRef.c.

Referenced by checkPassTransfer(), exprNode_assign(), exprNode_preOp(), uentry_mergeState(), and uentry_setUsed().

05363 {
05364   if (context_inMacro () && sRef_isCvar (s))
05365     {
05366       uentry ue = sRef_getUentry (s);
05367       cstring pname = makeParam (uentry_rawName (ue));
05368       uentry mac = usymtab_lookupSafe (pname);
05369 
05370       cstring_free (pname);
05371       return (uentry_isValid (mac));
05372     }
05373 
05374   return FALSE;
05375 }

bool sRef_isModified ( sRef s )
 

Definition at line 901 of file sRef.c.

Referenced by exprNode_checkAllMods(), and uentry_mergeState().

00902 {
00903     return (!sRef_isValid (s) || s->modified);
00904 }

bool sRef_isNSLocalVar ( sRef s )
 

Definition at line 8613 of file sRef.c.

08614 {
08615   if (sRef_isLocalVar (s))
08616     {
08617       uentry ue = sRef_getUentry (s);
08618 
08619       return (!uentry_isStatic (ue));
08620     }
08621   else
08622     {
08623       return FALSE;
08624     }
08625 }

bool sRef_isNotNull ( sRef s )
 

Definition at line 8963 of file sRef.c.

08964 {
08965   return (sRef_isValid(s) && (s->nullstate == NS_MNOTNULL 
08966                               || s->nullstate == NS_NOTNULL));
08967 }

bool sRef_isNotUndefined ( sRef s )
 

Definition at line 4218 of file sRef.c.

04219 {
04220   return (sRef_isInvalid (s)
04221           || (s->defstate != SS_UNDEFINED
04222               && s->defstate != SS_UNUSEABLE
04223               && s->defstate != SS_DEAD));
04224 }

bool sRef_isNothing ( sRef s )
 

Definition at line 4101 of file sRef.c.

Referenced by exprChecks_checkUsedGlobs(), exprNode_checkAllMods(), exprNode_checkMSet(), and exprNode_checkSet().

04102 {
04103   return (sRef_isKindSpecial (s) && s->info->spec == SR_NOTHING);
04104 }

bool sRef_isObject ( sRef s )
 

Definition at line 5389 of file sRef.c.

05390 {
05391   PREDTEST (sRef_isObject, s);
05392   return (s->kind == SK_OBJECT);
05393 }

bool sRef_isObserver ( sRef s )
 

Definition at line 8937 of file sRef.c.

Referenced by checkAssignTransfer(), checkLocalDestroyed(), checkStructDestroyed(), specialClause_postErrorString(), and specialClause_preErrorString().

08938 {
08939   return (sRef_isValid (s) && (s->expkind == XO_OBSERVER));
08940 }

bool sRef_isOnly ( sRef s )
 

Definition at line 8892 of file sRef.c.

Referenced by checkPassTransfer(), exprNode_cast(), uentry_mergeState(), and usymtab_checkFinalScope().

08893 {
08894   return (sRef_isValid(s) && alkind_isOnly (s->aliaskind));
08895 }

bool sRef_isOwned ( sRef s )
 

Definition at line 8902 of file sRef.c.

Referenced by uentry_mergeState(), and usymtab_checkFinalScope().

08903 {
08904   return (sRef_isValid (s) && (s->aliaskind == AK_OWNED));
08905 }

bool sRef_isParam ( sRef s )
 

Definition at line 5425 of file sRef.c.

Referenced by aliasTable_clearAliases(), sRef_getScope(), sRef_getUentry(), sRef_resetState(), specialClauses_checkAll(), uentry_mergeState(), uentry_setParamNo(), and usymtab_checkFinalScope().

05426 {
05427   PREDTEST (sRef_isParam, s);
05428   return (s->kind == SK_PARAM);
05429 }

bool sRef_isPointer ( sRef s )
 

Definition at line 5441 of file sRef.c.

Referenced by exprNode_assign(), sRef_isIReference(), sRef_isReference(), sRef_makeAddress(), and sRef_setModified().

05442 {
05443   PREDTEST (sRef_isPointer, s);
05444   return (s->kind == SK_PTR);
05445 }

bool sRef_isPossiblyDead ( sRef s )
 

Definition at line 7329 of file sRef.c.

Referenced by checkPassTransfer(), and uentry_mergeState().

07330 {
07331   return (sRef_isValid (s) && s->defstate == SS_HOFFA);
07332 }

ynm sRef_isReadable ( sRef s )
 

Definition at line 4263 of file sRef.c.

04264 {
04265   sstate ss;
04266 
04267   if (sRef_isInvalid (s)) return YES;
04268 
04269   ss = s->defstate;
04270   
04271   if (sRef_isConj (s) && s->defstate == SS_UNKNOWN)
04272     {
04273       if (ynm_toBoolStrict (sRef_isReadable (sRef_getConjA (s))))
04274         {
04275           if (ynm_toBoolStrict (sRef_isReadable (sRef_getConjB (s))))
04276             {
04277               return YES;
04278             }
04279           return MAYBE;
04280         }
04281       else
04282         {
04283           if (ynm_toBoolStrict (sRef_isReadable (sRef_getConjB (s))))
04284             {
04285               return MAYBE;
04286             }
04287           return NO;
04288         }
04289     }
04290   else if (ss == SS_HOFFA)
04291     {
04292       if (context_getFlag (FLG_STRICTUSERELEASED))
04293         {
04294           return MAYBE;
04295         }
04296       else
04297         {
04298           return YES;
04299         }
04300     }
04301   else
04302     {
04303       return (ynm_fromBool (ss == SS_DEFINED 
04304                             || ss == SS_FIXED 
04305                             || ss == SS_RELDEF 
04306                             || ss == SS_PDEFINED 
04307                             || ss == SS_PARTIAL
04308                             || ss == SS_SPECIAL
04309                             || ss == SS_ALLOCATED
04310                             || ss == SS_UNKNOWN));
04311     }
04312 }

bool sRef_isRealGlobal ( sRef s )
 

Definition at line 5470 of file sRef.c.

Referenced by sRef_getScopeName(), sRef_unparseScope(), and uentry_isExported().

05471 {
05472   return (sRef_isCvar (s) && (s->info->cvar->lexlevel == globScope));
05473 }

bool sRef_isRealLocalVar ( sRef s )
 

Definition at line 8638 of file sRef.c.

08639 {
08640   if (sRef_isValid(s))
08641     {
08642       if (s->kind == SK_CVAR)
08643         {
08644           if (s->info->cvar->lexlevel == functionScope)
08645             {
08646               uentry ue = sRef_getUentry (s);
08647 
08648               if (uentry_isAnyParam (ue)
08649                   || uentry_isRefParam (ue))
08650                 {
08651                   return FALSE;
08652                 }
08653               else
08654                 {
08655                   return TRUE;
08656                 }
08657             }
08658           else
08659             {
08660               return (s->info->cvar->lexlevel > functionScope);
08661             }
08662         }
08663     }
08664   
08665   return FALSE;
08666 }

bool sRef_isReallyDefined ( sRef s )
 

Definition at line 4449 of file sRef.c.

04450 {
04451   if (sRef_isValid (s))
04452     {
04453       if (sRef_isAnyDefined (s))
04454         {
04455           return TRUE;
04456         }
04457       else
04458         {
04459           if (sRef_isAllocated (s) || sRef_isPdefined (s))
04460             {
04461               return checkDefined (s);
04462             }
04463           else
04464             {
04465               return FALSE;
04466             }
04467         }
04468     }
04469   else
04470     {
04471       return TRUE;
04472     }
04473 }

bool sRef_isRecursiveField ( sRef s )
 

Definition at line 216 of file sRef.c.

00217 {
00218   if (sRef_isField (s))
00219     {
00220       if (sRef_depth (s) > 13)
00221         {
00222           sRef base;
00223           cstring fieldname;
00224           
00225           fieldname = sRef_getField (s);
00226           base = sRef_getBase (s);
00227           
00228           while (sRef_isValid (base))
00229             {
00230               if (sRef_isField (base))
00231                 {
00232                   if (cstring_equal (fieldname, sRef_getField (base)))
00233                     {
00234                       return TRUE;
00235                     }
00236                 }
00237               
00238               base = sRef_getBaseSafe (base);
00239             }
00240         }
00241     }
00242 
00243   return FALSE;
00244 }

bool sRef_isReference ( sRef s )
 

Definition at line 5451 of file sRef.c.

05452 {
05453   PREDTEST (sRef_isReference, s);
05454 
05455   return (sRef_isPointer (s) || sRef_isIndex (s) || sRef_isGlobal (s)
05456           || (sRef_isField (s) && (sRef_isReference (s->info->field->rec))));
05457 }

bool sRef_isResult ( sRef s )
 

Definition at line 4126 of file sRef.c.

Referenced by checkReturnTransfer(), specialClauses_checkAll(), uentry_returnedRef(), and usymtab_checkFinalScope().

04127 {
04128   return (sRef_isValid (s) && s->kind == SK_RESULT);
04129 }

bool sRef_isShared ( sRef s )
 

Definition at line 8927 of file sRef.c.

Referenced by aliasTable_checkGlobs(), sRef_kill(), and specialClause_preErrorString().

08928 {
08929   return (sRef_isValid (s) && (s->aliaskind == AK_SHARED));
08930 }

bool sRef_isSpecInternalState ( sRef s )
 

Definition at line 4113 of file sRef.c.

Referenced by exprChecks_checkUsedGlobs(), and sRef_includedBy().

04114 {
04115   return (sRef_isKindSpecial (s) 
04116           && (s->info->spec == SR_INTERNAL || s->info->spec == SR_SPECSTATE));
04117 }

bool sRef_isSpecState ( sRef s )
 

Definition at line 4120 of file sRef.c.

Referenced by exprNode_checkAllMods().

04121 {
04122   return (sRef_isKindSpecial (s) && s->info->spec == SR_SPECSTATE);
04123 }

bool sRef_isStack ( sRef s )
 

Definition at line 8958 of file sRef.c.

08959 {
08960   return (sRef_isValid (s) && (s->aliaskind == AK_STACK));
08961 }

bool sRef_isStackAllocated ( sRef s )
 

Definition at line 5773 of file sRef.c.

05774 {
05775   return (sRef_isValid(s) 
05776           && s->defstate == SS_ALLOCATED && ctype_isStackAllocated (s->type));
05777 }

bool sRef_isStateLive ( sRef s )
 

Definition at line 7334 of file sRef.c.

07335 {
07336   if (sRef_isValid (s))
07337     {
07338       sstate ds = s->defstate;
07339 
07340       return (!(ds == SS_UNDEFINED 
07341                 || ds == SS_DEAD
07342                 || ds == SS_UNUSEABLE
07343                 || ds == SS_HOFFA));
07344     }
07345   else
07346     {
07347       return FALSE;
07348     }
07349 }

bool sRef_isStateUndefined ( sRef s )
 

Definition at line 7352 of file sRef.c.

Referenced by checkPassTransfer(), sRef_isJustAllocated(), and usymtab_popAndBranch().

07353 {
07354   return ((sRef_isValid(s)) && ((s)->defstate == SS_UNDEFINED));
07355 }

bool sRef_isStrictReadable ( sRef s )
 

Definition at line 4258 of file sRef.c.

04259 {
04260   return (ynm_toBoolStrict (sRef_isReadable (s)));
04261 }

bool sRef_isSystemState ( sRef s )
 

Definition at line 4132 of file sRef.c.

Referenced by sRef_includedBy().

04133 {
04134   return (sRef_isKindSpecial (s) && s->info->spec == SR_SYSTEM);
04135 }

bool sRef_isTemp ( sRef s )
 

Definition at line 8912 of file sRef.c.

08913 {
08914   return (sRef_isValid (s) && alkind_isTemp (s->aliaskind));
08915 }

bool sRef_isThroughArrayFetch ( sRef s )
 

Definition at line 5333 of file sRef.c.

Referenced by sRef_similarRelaxed(), and uentry_mergeState().

05334 {
05335   if (sRef_isValid (s))
05336     {
05337       sRef tref = s;
05338 
05339       do 
05340         {
05341           sRef lt;
05342 
05343           if (sRef_isArrayFetch (tref)) 
05344             {
05345                       return TRUE;
05346             }
05347           
05348           lt = sRef_getBase (tref);
05349           tref = lt;
05350         } while (sRef_isValid (tref));
05351     } 
05352 
05353   return FALSE;
05354 }

bool sRef_isUnconstrained ( sRef s )
 

Definition at line 2841 of file sRef.c.

Referenced by sRefSet_hasRealElement(), sRefSet_unparseUnconstrained(), and sRefSet_unparseUnconstrainedPlain().

02842 {
02843   return (sRef_isValid(s) && s->kind == SK_UNCONSTRAINED);
02844 }

bool sRef_isUnionField ( sRef s )
 

Definition at line 4802 of file sRef.c.

04803 {
04804   if (sRef_isValid (s) && s->kind == SK_FIELD)
04805     {
04806       /*
04807        ** defining one field of a union defines the union
04808        */
04809       
04810       sRef base = s->info->field->rec;
04811 
04812       if (sRef_isValid (base))
04813         {
04814           return (ctype_isUnion (ctype_realType (base->type)));
04815         }
04816     }
04817 
04818   return FALSE;
04819 }

bool sRef_isUnique ( sRef s )
 

Definition at line 8922 of file sRef.c.

08923 {
08924   return (sRef_isValid (s) && (s->aliaskind == AK_UNIQUE));
08925 }

bool sRef_isUnknownArrayFetch ( sRef s )
 

Definition at line 5588 of file sRef.c.

05589 {
05590   return (sRef_isValid (s) 
05591           && s->kind == SK_ARRAYFETCH
05592           && !s->info->arrayfetch->indknown);
05593 }

bool sRef_isUnuseable ( sRef s )
 

Definition at line 7389 of file sRef.c.

Referenced by checkPassTransfer(), and sRef_isJustAllocated().

07390 {
07391   return ((sRef_isValid(s)) && ((s)->defstate == SS_UNUSEABLE));
07392 }

ynm sRef_isWriteable ( sRef s )
 

Definition at line 4226 of file sRef.c.

04227 {
04228   if (sRef_isInvalid (s)) return MAYBE;
04229 
04230   if (sRef_isConj (s) && s->defstate == SS_UNKNOWN)
04231     {
04232       if (ynm_toBoolStrict (sRef_isWriteable (sRef_getConjA (s))))
04233         {
04234           if (ynm_toBoolStrict (sRef_isWriteable (sRef_getConjB (s))))
04235             {
04236               return YES;
04237             }
04238           return MAYBE;
04239         }
04240       else
04241         {
04242           if (ynm_toBoolStrict (sRef_isWriteable (sRef_getConjB (s))))
04243             {
04244               return MAYBE;
04245             }
04246           return NO;
04247         }
04248     }
04249 
04250   return (ynm_fromBool (s->defstate != SS_UNUSEABLE));
04251 }

void sRef_kill ( sRef s,
fileloc loc )
 

Definition at line 5144 of file sRef.c.

05145 {
05146   DPRINTF (("Kill: %s", sRef_unparseFull (s)));
05147 
05148   if (sRef_isValid (s) && !sRef_isShared (s) && !sRef_isConst (s))
05149     {
05150       sRef base = sRef_getBaseSafe (s);  
05151       
05152       while (sRef_isValid (base) && sRef_isKnown (base))
05153         {
05154           if (base->defstate == SS_DEFINED) 
05155             {
05156               base->defstate = SS_PDEFINED; 
05157               base = sRef_getBaseSafe (base); 
05158             }
05159           else 
05160             {
05161               break; 
05162             }
05163 
05164         }
05165       
05166       s->aliaskind = s->oaliaskind;
05167       s->defstate = SS_DEAD;
05168       s->definfo = alinfo_updateLoc (s->definfo, loc);
05169 
05170       sRef_clearDerived (s);
05171     }
05172 }

void sRef_killComplete ( sRef s,
fileloc loc )
 

Definition at line 5227 of file sRef.c.

05228 {
05229   DPRINTF (("Kill complete: %s", sRef_unparseFull (s)));
05230   sRef_aliasSetComplete (sRef_killAux, s, loc);
05231 }

int sRef_lexLevel ( sRef s )
 

Definition at line 2894 of file sRef.c.

Referenced by aliasTable_levelUnion(), aliasTable_levelUnionSeq(), sRefSet_levelCopy(), sRefSet_levelPrune(), sRefSet_levelUnion(), uentry_directParamNo(), and usymtab_unguard().

02895 {
02896   if (sRef_isValid (s))
02897     {
02898       sRef conj;
02899 
02900       conj = sRef_fixConj (s);
02901       s = sRef_getRootBase (conj);
02902       
02903       if (sRef_isValid (s) && s->kind == SK_CVAR)
02904         {
02905           return (s->info->cvar->lexlevel);
02906         }
02907     }
02908 
02909   return globScope;
02910 }

sRef sRef_makeAddress ( sRef t )
 

Definition at line 2983 of file sRef.c.

Referenced by exprNode_preOp(), sRef_fixBase(), sRef_fixBaseParam(), sRef_undump(), and sRef_updateSref().

02984 {
02985   
02986   if (sRef_isInvalid (t)) return sRef_undefined;
02987 
02988   if (sRef_isPointer (t))
02989     {
02990       return (t->info->ref);
02991     }
02992   else if (sRef_isZerothArrayFetch (t))
02993     {
02994       return (t->info->arrayfetch->arr);
02995     }
02996   else
02997     {
02998       sRef s = sRef_new ();
02999       
03000       s->kind = SK_ADR;
03001       s->type = ctype_makePointer (t->type);
03002       s->info = (sinfo) dmalloc (sizeof (*s->info));
03003       s->info->ref = t;
03004       
03005       if (t->defstate == SS_UNDEFINED) 
03006         /* no! it is allocated even still: && !ctype_isPointer (t->type)) */
03007         {
03008           s->defstate = SS_ALLOCATED;
03009         }
03010       else
03011         {
03012           s->defstate = t->defstate;
03013         }
03014 
03015       if (t->aliaskind == AK_LOCAL)
03016         {
03017           if (sRef_isLocalVar (t))
03018             {
03019               s->aliaskind = AK_STACK;
03020             }
03021         }
03022 
03023       return s;
03024     }
03025 }

sRef sRef_makeAnyArrayFetch ( sRef arr )
 

Definition at line 6330 of file sRef.c.

Referenced by modListArrayFetch().

06331 {
06332   
06333   if (sRef_isAddress (arr))
06334     {
06335             return (arr->info->ref);
06336     }
06337   else
06338     {
06339       return (sRef_buildArrayFetch (arr));
06340     }
06341 }

sRef sRef_makeArrayFetch ( sRef arr )
 

Definition at line 6344 of file sRef.c.

Referenced by exprNode_arrayFetch(), sRef_fixBase(), sRef_fixResultType(), and sRef_updateSref().

06345 {
06346   return (sRef_buildArrayFetch (arr));
06347 }

sRef sRef_makeArrayFetchKnown ( sRef arr,
int i )
 

Definition at line 6350 of file sRef.c.

Referenced by exprNode_arrayFetch(), sRef_fixBase(), and sRef_fixResultType().

06351 {
06352   return (sRef_buildArrayFetchKnown (arr, i));
06353 }

sRef sRef_makeArrow ( sRef s,
cstring f )
 

Definition at line 8330 of file sRef.c.

Referenced by exprNode_arrowAccess(), and modListArrowAccess().

08331 {
08332   sRef p;
08333   sRef ret;
08334 
08335     p = sRef_makePointer (s);
08336   ret = sRef_makeField (p, f);
08337     return ret;
08338 }

sRef sRef_makeConj ( sRef a,
sRef b )
 

Definition at line 3959 of file sRef.c.

Referenced by sRefSet_mergeIntoOne(), sRef_fixBase(), sRef_fixBaseParam(), sRef_undump(), and sRef_updateSref().

03960 {
03961   llassert (sRef_isValid (a));
03962   llassert (sRef_isValid (b));
03963       
03964   if (!sRef_equivalent (a, b))
03965     {
03966       sRef s = sRef_new ();
03967       
03968       s->kind = SK_CONJ;
03969       s->info = (sinfo) dmalloc (sizeof (*s->info));
03970       s->info->conj = (cjinfo) dmalloc (sizeof (*s->info->conj));
03971       s->info->conj->a = a;
03972       s->info->conj->b = b;
03973       
03974       if (ctype_equal (a->type, b->type)) s->type = a->type;
03975       else s->type = ctype_makeConj (a->type, b->type);
03976       
03977       if (a->defstate == b->defstate)
03978         {
03979           s->defstate = a->defstate;
03980         }
03981       else
03982         {
03983           s->defstate = SS_UNKNOWN; 
03984         }
03985       
03986       s->nullstate = NS_UNKNOWN;
03987       
03988       s->safe = a->safe && b->safe;
03989       s->aliaskind = alkind_resolve (a->aliaskind, b->aliaskind);
03990 
03991       return s;
03992     }
03993   else
03994     {
03995       /*@-exposetrans@*/ return a; /*@=exposetrans@*/
03996     }
03997 }

sRef sRef_makeConst ( ctype ct )
 

Definition at line 6609 of file sRef.c.

Referenced by uentry_makeConstantAux().

06610 {
06611   sRef s = sRef_new ();
06612   
06613   s->kind = SK_CONST;
06614   s->type = ct;
06615 
06616   s->defstate = SS_UNKNOWN;
06617   s->aliaskind = AK_UNKNOWN;
06618   s->nullstate = NS_UNKNOWN;
06619 
06620   
06621   if (ctype_isUA (ct))
06622     {
06623       typeId uid = ctype_typeId (ct);
06624       uentry te = usymtab_getTypeEntrySafe (uid);
06625       
06626       if (uentry_isValid (te))
06627         {
06628           sRef_mergeStateQuiet (s, uentry_getSref (te));
06629         }
06630     }
06631 
06632   
06633   s->oaliaskind = s->aliaskind;
06634   s->oexpkind = s->expkind;
06635 
06636   return s;
06637 }

sRef sRef_makeCvar ( int level,
usymId index,
ctype ct )
 

Definition at line 2889 of file sRef.c.

Referenced by sRef_makeGlobal().

02890 {
02891   return (sRef_makeCvarAux (level, index, ct));
02892 }

sRef sRef_makeDerived ( sRef t )
 

Definition at line 3210 of file sRef.c.

03211 {
03212   if (sRef_isValid (t))
03213     {
03214       sRef s = sRef_new ();
03215       
03216       s->kind = SK_DERIVED;
03217       s->info = (sinfo) dmalloc (sizeof (*s->info));
03218       s->info->ref = t;
03219       
03220       s->type = t->type;
03221       return s;
03222     }
03223   else
03224     {
03225       return sRef_undefined;
03226     }
03227 }

sRef sRef_makeExternal ( sRef t )
 

Definition at line 3197 of file sRef.c.

03198 {
03199   sRef s = sRef_new ();
03200 
03201   llassert (sRef_isValid (t));
03202 
03203   s->kind = SK_EXTERNAL;
03204   s->info = (sinfo) dmalloc (sizeof (*s->info));
03205   s->type = t->type;
03206   s->info->ref = t;
03207   return s;
03208 }

sRef sRef_makeField ( sRef rec,
cstring f )
 

Definition at line 6356 of file sRef.c.

Referenced by exprNode_fieldAccess(), modListFieldAccess(), sRef_fixBaseParam(), sRef_fixResultType(), sRef_makeArrow(), and sRef_updateSref().

06357 {
06358   sRef ret;
06359   ret = sRef_buildField (rec, f);
06360   return ret;
06361 }

sRef sRef_makeGlobal ( usymId l,
ctype ct )
 

Definition at line 2913 of file sRef.c.

Referenced by sRef_undump(), and sRef_undumpGlobal().

02914 {
02915   return (sRef_makeCvar (globScope, l, ct));
02916 }

sRef sRef_makeInternalState ( void )
 

Definition at line 4038 of file sRef.c.

Referenced by fixModifiesId(), globListUnrecognized(), makeInternalStateNode(), makeStoreRefNodeInternal(), sRef_undump(), and sRef_undumpGlobal().

04039 {
04040   if (sRef_isInvalid (srinternal))
04041     {
04042       srinternal = sRef_makeSpecial (SR_INTERNAL);
04043     }
04044 
04045   /*@-retalias@*/
04046   return srinternal;
04047   /*@=retalias@*/
04048 }

sRef sRef_makeNCField ( sRef rec,
cstring f )
 

Definition at line 6364 of file sRef.c.

06365 {
06366     return (sRef_buildNCField (rec, f));
06367 }

sRef sRef_makeNew ( ctype ct,
sRef t,
cstring name )
 

Definition at line 6554 of file sRef.c.

Referenced by checkReturnTransfer(), and uentry_returnedRef().

06555 {
06556   sRef s = sRef_new ();
06557 
06558   s->kind = SK_NEW;
06559   s->type = ct;
06560 
06561   llassert (sRef_isValid (t));
06562   s->defstate = t->defstate;
06563 
06564   s->aliaskind = t->aliaskind;
06565   s->oaliaskind = s->aliaskind;
06566 
06567   s->nullstate = t->nullstate;
06568 
06569   s->expkind = t->expkind;
06570   s->oexpkind = s->expkind;
06571 
06572   s->info = (sinfo) dmalloc (sizeof (*s->info));
06573   s->info->fname = name;
06574 
06575     return s;
06576 }

sRef sRef_makeNothing ( void )
 

Definition at line 4025 of file sRef.c.

Referenced by fixModifiesId(), globListUnrecognized(), sRef_undump(), and sRef_undumpGlobal().

04026 {
04027   if (sRef_isInvalid (srnothing))
04028     {
04029       srnothing = sRef_makeSpecial (SR_NOTHING);
04030     }
04031 
04032   /*@-retalias@*/
04033   return srnothing;
04034   /*@=retalias@*/
04035 }

sRef sRef_makeObject ( ctype o )
 

Definition at line 3187 of file sRef.c.

Referenced by sRef_undump().

03188 {
03189   sRef s = sRef_new ();
03190 
03191   s->kind = SK_OBJECT;
03192   s->info = (sinfo) dmalloc (sizeof (*s->info));
03193   s->info->object = o;
03194   return s;
03195 }

sRef sRef_makeParam ( int l,
ctype ct )
 

Definition at line 2926 of file sRef.c.

Referenced by sRef_undump(), and uentry_makeParam().

02927 {
02928   sRef s = sRef_new ();
02929 
02930   s->kind = SK_PARAM;
02931   s->type = ct;
02932 
02933   s->info = (sinfo) dmalloc (sizeof (*s->info));
02934   s->info->paramno = l; 
02935   s->defstate = SS_UNKNOWN; /* (probably defined, unless its an out parameter) */
02936 
02937   return s;
02938 }

sRef sRef_makePointer ( sRef s )
 

Definition at line 6316 of file sRef.c.

Referenced by checkPassTransfer(), exprNode_initMod(), exprNode_preOp(), sRef_fixBase(), sRef_fixBaseParam(), sRef_fixResultType(), sRef_makeArrow(), sRef_undump(), and sRef_updateSref().

06318 {
06319   sRef res = sRef_buildPointer (s); 
06320 
06321   DPRINTF (("Res: %s", sRef_unparse (res)));
06322   return res;
06323 }

sRef sRef_makeResult ( )
 

Definition at line 4086 of file sRef.c.

Referenced by fixSpecClausesId().

04087 {
04088   sRef s = sRef_new ();
04089   
04090   s->kind = SK_RESULT;
04091   s->type = ctype_unknown;
04092   s->defstate = SS_UNKNOWN; 
04093   s->aliaskind = AK_UNKNOWN;
04094   s->nullstate = NS_UNKNOWN;
04095   
04096   return s;
04097 }

void sRef_makeSafe ( sRef s )
 

Definition at line 4147 of file sRef.c.

Referenced by exprNode_postOp(), and uentry_returnedRef().

04148 {
04149   if (sRef_isValid (s)) 
04150     {
04151       s->safe = TRUE;
04152     }
04153 }

sRef sRef_makeSpecState ( void )
 

Definition at line 4051 of file sRef.c.

Referenced by sRef_undump(), and sRef_undumpGlobal().

04052 {
04053   if (sRef_isInvalid (srspec))
04054     {
04055       srspec = sRef_makeSpecial (SR_SPECSTATE);
04056     }
04057 
04058   /*@-retalias@*/
04059   return srspec;
04060   /*@=retalias@*/
04061 }

sRef sRef_makeSystemState ( void )
 

Definition at line 4064 of file sRef.c.

Referenced by fixModifiesId(), globListUnrecognized(), makeFileSystemNode(), makeStoreRefNodeSystem(), sRef_undump(), and sRef_undumpGlobal().

04065 {
04066   if (sRef_isInvalid (srsystem))
04067     {
04068       srsystem = sRef_makeSpecial (SR_SYSTEM);
04069     }
04070 
04071   /*@-retalias@*/
04072   return (srsystem);
04073   /*@=retalias@*/
04074 }

sRef sRef_makeType ( ctype ct )
 

Definition at line 6579 of file sRef.c.

Referenced by exprNode_stringLiteral(), and uentry_makeVarFunction().

06580 {
06581   sRef s = sRef_new ();
06582   
06583   s->kind = SK_TYPE;
06584   s->type = ct;
06585 
06586   s->defstate = SS_UNKNOWN; 
06587   s->aliaskind = AK_UNKNOWN;
06588   s->nullstate = NS_UNKNOWN;
06589 
06590     
06591   if (ctype_isUA (ct))
06592     {
06593       typeId uid = ctype_typeId (ct);
06594       uentry ue = usymtab_getTypeEntrySafe (uid);
06595 
06596       if (uentry_isValid (ue))
06597         {
06598           sRef_mergeStateQuiet (s, uentry_getSref (ue));
06599         }
06600     }
06601 
06602     s->oaliaskind = s->aliaskind;
06603   s->oexpkind = s->expkind;
06604 
06605   return s;
06606 }

sRef sRef_makeUnconstrained ( cstring fname )
 

Definition at line 2823 of file sRef.c.

02824 {
02825   sRef s = sRef_new ();
02826 
02827   s->kind = SK_UNCONSTRAINED;
02828   s->info = (sinfo) dmalloc (sizeof (*s->info));
02829   s->info->fname = fname;
02830 
02831   return (s);
02832 }

sRef sRef_makeUnknown ( )
 

Definition at line 4000 of file sRef.c.

Referenced by exprNode_getSref(), exprNode_numLiteral(), sRef_fixBaseParam(), sRef_undump(), sRef_undumpGlobal(), and uentry_makeDatatypeAux().

04001 {
04002   sRef s = sRef_new ();
04003 
04004   s->kind = SK_UNKNOWN;
04005   return s;
04006 }

void sRef_makeUnsafe ( sRef s )
 

Definition at line 4156 of file sRef.c.

04157 {
04158   if (sRef_isValid (s)) 
04159     {
04160       s->safe = FALSE;
04161     }
04162 }

void sRef_maybeKill ( sRef s,
fileloc loc )
 

Definition at line 5174 of file sRef.c.

Referenced by uentry_mergeState().

05175 {
05176         
05177   if (sRef_isValid (s))
05178     {
05179       sRef base = sRef_getBaseSafe (s);  
05180 
05181             
05182       while (sRef_isValid (base) && sRef_isKnown (base))
05183         {
05184           if (base->defstate == SS_DEFINED || base->defstate == SS_RELDEF)
05185             {
05186               base->defstate = SS_PDEFINED; 
05187                       base = sRef_getBaseSafe (base); 
05188             }
05189           else 
05190             {
05191                       break; 
05192             }
05193           
05194         }
05195       
05196       s->aliaskind = s->oaliaskind;
05197       s->defstate = SS_HOFFA; 
05198       s->definfo = alinfo_updateLoc (s->definfo, loc);
05199       sRef_clearDerived (s); 
05200     }
05201 
05202   }

void sRef_mergeNullState ( sRef s,
nstate n )
 

Definition at line 7184 of file sRef.c.

07185 {
07186   if (sRef_isValid (s))
07187     {
07188       nstate old;
07189       
07190       old = s->nullstate;
07191       
07192       if (n != old && n != NS_UNKNOWN)
07193         {
07194                   
07195           s->nullstate = n;
07196           s->nullinfo = alinfo_updateLoc (s->nullinfo, g_currentloc);
07197         }
07198     }
07199   else
07200     {
07201       llbuglit ("sRef_mergeNullState: invalid");
07202     }
07203 }

void sRef_mergeOptState ( sRef res,
sRef other,
clause cl,
fileloc loc )
 

Definition at line 3408 of file sRef.c.

Referenced by uentry_mergeState().

03409 {
03410   if (sRef_isValid (res) && sRef_isValid (other))
03411     {
03412       sRef_mergeStateAux (res, other, cl, TRUE, loc, TRUE);
03413     }
03414   else
03415     {
03416       if (sRef_isInvalid (res))
03417         {
03418           llbug (message ("sRef_mergeOptState: invalid res sRef: %q", 
03419                           sRef_unparseDebug (other)));
03420         }
03421       else 
03422         {
03423           llbug (message ("sRef_mergeOptState: invalid other sRef: %q", 
03424                           sRef_unparseDebug (res)));
03425         }
03426     }
03427 }

void sRef_mergeState ( sRef res,
sRef other,
clause cl,
fileloc loc )
 

Definition at line 3386 of file sRef.c.

Referenced by uentry_mergeState().

03387 {
03388   if (sRef_isValid (res) && sRef_isValid (other))
03389     {
03390       sRef_mergeStateAux (res, other, cl, FALSE, loc, TRUE);
03391     }
03392   else
03393     {
03394       if (sRef_isInvalid (res))
03395         {
03396           llbug (message ("sRef_mergeState: invalid res sRef: %q", 
03397                           sRef_unparseDebug (other)));
03398         }
03399       else 
03400         {
03401           llbug (message ("sRef_mergeState: invalid other sRef: %q", 
03402                           sRef_unparseDebug (res)));
03403         }
03404     }
03405 }

void sRef_mergeStateQuiet ( sRef res,
sRef other )
 

Definition at line 3236 of file sRef.c.

Referenced by exprNode_iterNewId(), sRef_makeConst(), sRef_makeType(), and usymtab_supEntrySref().

03237 {
03238   llassert (sRef_isValid (res));
03239   llassert (sRef_isValid (other));
03240 
03241   res->modified = res->modified || other->modified;
03242   res->safe = res->safe && other->safe;
03243 
03244   if (res->defstate == SS_UNKNOWN) 
03245     {
03246       res->defstate = other->defstate;
03247       res->definfo = alinfo_update (res->definfo, other->definfo);
03248     }
03249 
03250   if (res->aliaskind == AK_UNKNOWN || 
03251       (res->aliaskind == AK_LOCAL && alkind_isKnown (other->aliaskind)))
03252     {
03253       res->aliaskind = other->aliaskind;
03254       res->oaliaskind = other->oaliaskind;
03255       res->aliasinfo = alinfo_update (res->aliasinfo, other->aliasinfo);
03256     }
03257 
03258   if (res->expkind == XO_UNKNOWN)
03259     {
03260       res->expkind = other->expkind;
03261       res->oexpkind = other->oexpkind;
03262       res->expinfo = alinfo_update (res->expinfo, other->expinfo);
03263     }
03264   
03265   /* out takes precedence over implicitly defined */
03266   if (res->defstate == SS_DEFINED && other->defstate != SS_UNKNOWN) 
03267     {
03268       res->defstate = other->defstate;
03269       res->definfo = alinfo_update (res->definfo, other->definfo);
03270     }
03271 
03272   if (other->nullstate == NS_ERROR || res->nullstate == NS_ERROR) 
03273     {
03274       res->nullstate = NS_ERROR;
03275     }
03276   else
03277     {
03278       if (other->nullstate != NS_UNKNOWN 
03279           && (res->nullstate == NS_UNKNOWN || res->nullstate == NS_NOTNULL 
03280               || res->nullstate == NS_MNOTNULL))
03281         {
03282           res->nullstate = other->nullstate;
03283           res->nullinfo = alinfo_update (res->nullinfo, other->nullinfo);
03284         }
03285     }
03286 }

void sRef_mergeStateQuietReverse ( sRef res,
sRef other )
 

Definition at line 3295 of file sRef.c.

Referenced by uentry_setSref().

03296 {
03297   bool changed = FALSE;
03298 
03299   llassert (sRef_isValid (res));
03300   llassert (sRef_isValid (other));
03301 
03302   if (res->kind != other->kind)
03303     {
03304       changed = TRUE;
03305 
03306       sinfo_free (res);
03307 
03308       res->kind = other->kind;
03309       res->type = other->type;
03310       res->info = sinfo_fullCopy (other);
03311     }
03312   else
03313     {
03314       if (!ctype_equal (res->type, other->type))
03315         {
03316           changed = TRUE;
03317           res->type = other->type;
03318         }
03319       
03320       sinfo_update (res, other);
03321     }
03322 
03323   res->modified = res->modified || other->modified;
03324   res->safe = res->safe && other->safe;
03325 
03326   if (res->aliaskind != other->aliaskind
03327       && (res->aliaskind == AK_UNKNOWN
03328           || ((res->aliaskind == AK_LOCAL 
03329                || (res->aliaskind == AK_REFCOUNTED
03330                    && other->aliaskind != AK_LOCAL))
03331               && other->aliaskind != AK_UNKNOWN)))
03332     {
03333       changed = TRUE;
03334       res->aliaskind = other->aliaskind;
03335       res->oaliaskind = other->oaliaskind;
03336       res->aliasinfo = alinfo_update (res->aliasinfo, other->aliasinfo);
03337           }
03338 
03339   if (other->expkind != XO_UNKNOWN && other->expkind != res->expkind)
03340     {
03341       changed = TRUE;
03342       res->expkind = other->expkind;
03343       res->expinfo = alinfo_update (res->expinfo, other->expinfo);
03344     }
03345 
03346   if (other->oexpkind != XO_UNKNOWN)
03347     {
03348       res->oexpkind = other->oexpkind;
03349     }
03350 
03351   /* out takes precedence over implicitly defined */
03352 
03353   if (res->defstate != other->defstate)
03354     {
03355       if (other->defstate != SS_UNKNOWN)
03356         {
03357           res->defstate = other->defstate;
03358         }
03359     }
03360 
03361   if (other->nullstate == NS_ERROR || res->nullstate == NS_ERROR)
03362     {
03363       if (res->nullstate != NS_ERROR)
03364         {
03365           res->nullstate = NS_ERROR;
03366           changed = TRUE;
03367         }
03368     }
03369   else
03370     {
03371       if (other->nullstate != NS_UNKNOWN && other->nullstate != res->nullstate)
03372         {
03373           changed = TRUE;
03374           res->nullstate = other->nullstate;
03375           res->nullinfo = alinfo_update (res->nullinfo, other->nullinfo);
03376         }
03377     }
03378 
03379   if (changed)
03380     {
03381       sRef_clearDerived (res); 
03382     }
03383 }

bool sRef_modInFunction ( void )
 

Definition at line 324 of file sRef.c.

Referenced by uentry_setModifies(), usymtab_supAbstractTypeEntry(), usymtab_supExposedTypeEntry(), usymtab_supForwardTypeEntry(), usymtab_supGlobalEntry(), usymtab_supGlobalEntryReturn(), usymtab_supReturnTypeEntry(), and usymtab_supTypeEntry().

00325 {
00326   return inFunction;
00327 }

cstring sRef_nullMessage ( sRef s )
 

Definition at line 8748 of file sRef.c.

08749 {
08750   llassert (sRef_isValid (s));
08751 
08752   switch (s->nullstate)
08753     {
08754     case NS_DEFNULL:
08755     case NS_CONSTNULL:
08756       return (cstring_makeLiteralTemp ("null"));
08757     default:
08758       return (cstring_makeLiteralTemp ("possibly null"));
08759     }
08760   BADEXIT;
08761 }

bool sRef_perhapsNull ( sRef s )
 

Definition at line 7395 of file sRef.c.

07396 {
07397   if (sRef_isValid (s))
07398     {
07399       if (s->nullstate == NS_ABSNULL)
07400         {
07401           ctype rct = ctype_realType (s->type);
07402 
07403           if (ctype_isAbstract (rct))
07404             {
07405               return FALSE;
07406             }
07407           else
07408             {
07409               if (ctype_isUser (rct))
07410                 {
07411                   uentry ue = usymtab_getTypeEntry (ctype_typeId (rct));
07412 
07413                   return (nstate_perhapsNull 
07414                           (sRef_getNullState (uentry_getSref (ue))));
07415                 }
07416               else
07417                 {
07418                   return FALSE;
07419                 }
07420             }
07421         }
07422       else
07423         {
07424           return nstate_perhapsNull (s->nullstate);
07425         }
07426     }
07427 
07428   return FALSE;
07429 }

bool sRef_possiblyNull ( sRef s )
 

Definition at line 7206 of file sRef.c.

Referenced by exprNode_arrayFetch(), exprNode_arrowAccess(), exprNode_checkMacroBody(), exprNode_functionCall(), exprNode_preOp(), and uentry_possiblyNull().

07207 {
07208   if (sRef_isValid (s))
07209     {
07210       if (s->nullstate == NS_ABSNULL)
07211         {
07212           ctype rct = ctype_realType (s->type);
07213 
07214           if (ctype_isAbstract (rct))
07215             {
07216               return FALSE;
07217             }
07218           else
07219             {
07220               if (ctype_isUser (rct))
07221                 {
07222                   uentry ue = usymtab_getTypeEntry (ctype_typeId (rct));
07223                   
07224                   return (nstate_possiblyNull
07225                           (sRef_getNullState (uentry_getSref (ue))));
07226                 }
07227               else
07228                 {
07229                   return FALSE;
07230                 }
07231             }
07232         }
07233       else
07234         {
07235           return nstate_possiblyNull (s->nullstate);
07236         }
07237     }
07238 
07239   return FALSE;
07240 }

void sRef_protectDerivs ( void )
 

Definition at line 198 of file sRef.c.

Referenced by checkGlobReturn().

00199 {
00200   llassert (!protectDerivs);
00201   protectDerivs = TRUE;
00202 }

bool sRef_realSame ( sRef s1,
sRef s2 )
 

Definition at line 1839 of file sRef.c.

Referenced by sRefSet_delete().

01840 {
01841   if (s1 == s2) return TRUE;  
01842   if (sRef_isInvalid (s1) || sRef_isInvalid (s2)) return FALSE;
01843 
01844   switch (s1->kind)
01845     {
01846     case SK_CVAR:
01847       return ((s2->kind == SK_CVAR) && (cref_equal (s1->info->cvar, s2->info->cvar)));
01848     case SK_PARAM:
01849       return ((s2->kind == SK_PARAM) && (s1->info->paramno == s2->info->paramno));
01850     case SK_ARRAYFETCH:
01851       if (s2->kind == SK_ARRAYFETCH)
01852         {
01853           if (sRef_realSame (s1->info->arrayfetch->arr, s2->info->arrayfetch->arr))
01854             {
01855               if (s1->info->arrayfetch->indknown && s2->info->arrayfetch->indknown)
01856                 {
01857                   return (s1->info->arrayfetch->ind == s2->info->arrayfetch->ind);
01858                 }
01859               if (!s1->info->arrayfetch->indknown && !s2->info->arrayfetch->indknown)
01860                 {
01861                   return TRUE;
01862                 }
01863               return FALSE;
01864             }
01865         }
01866       return FALSE;
01867     case SK_FIELD:
01868       return ((s2->kind == SK_FIELD &&
01869                (sRef_realSame (s1->info->field->rec, s2->info->field->rec) &&
01870                 cstring_equal (s1->info->field->field, s2->info->field->field))));
01871     case SK_PTR:
01872       return ((s2->kind == SK_PTR) && sRef_realSame (s1->info->ref, s2->info->ref));
01873     case SK_ADR:
01874       return ((s2->kind == SK_ADR) && sRef_realSame (s1->info->ref, s2->info->ref));
01875     case SK_CONJ:
01876       return ((sRef_realSame (s1->info->conj->a, s2) ||
01877               (sRef_realSame (s1->info->conj->b, s2))));
01878     case SK_OBJECT:
01879       return ((s2->kind == SK_OBJECT) 
01880               && ctype_match (s1->info->object, s2->info->object));
01881     case SK_EXTERNAL:
01882       return ((s2->kind == SK_EXTERNAL) 
01883               && sRef_realSame (s1->info->ref, s2->info->ref));
01884     case SK_SPECIAL:
01885       return ((s2->kind == SK_SPECIAL) && s1->info->spec == s2->info->spec);
01886     case SK_DERIVED:
01887       return ((s2->kind == SK_DERIVED) && sRef_realSame (s1->info->ref, s2->info->ref));
01888     case SK_UNCONSTRAINED:
01889       return ((s2->kind == SK_UNCONSTRAINED) 
01890               && (cstring_equal (s1->info->fname, s2->info->fname)));
01891     case SK_TYPE:
01892     case SK_CONST:
01893     case SK_NEW:
01894     case SK_UNKNOWN:
01895     case SK_RESULT:
01896       return TRUE; /* changed this! was false */
01897     }
01898   BADEXIT;
01899 }

void sRef_resetState ( sRef s )
 

Definition at line 6852 of file sRef.c.

Referenced by uentry_fixupSref(), and uentry_getOrigSref().

06853 {
06854   bool changed = FALSE;
06855   if (sRef_isInvalid (s)) return;
06856 
06857   
06858   if (s->oaliaskind == AK_KILLREF && !sRef_isParam (s))
06859     {
06860       /*
06861       ** killref is used in a kludgey way, to save having to add
06862       ** another alias kind (see usymtab_handleParams)
06863       */
06864  
06865       if (s->expkind != s->oexpkind)
06866         {
06867           changed = TRUE;
06868           s->expkind = s->oexpkind;
06869         }
06870     }
06871   else
06872     {
06873       if (s->expkind != s->oexpkind)
06874         {
06875           changed = TRUE;
06876           s->expkind = s->oexpkind;       
06877         }
06878 
06879       if (s->aliaskind != s->oaliaskind
06880           && s->aliaskind != AK_REFCOUNTED
06881           && s->aliaskind != AK_REFS)
06882         {
06883           changed = TRUE;
06884           s->aliaskind = s->oaliaskind;
06885                 }
06886     }
06887 
06888   if (changed)
06889     {
06890       sRef_clearDerived (s);
06891     }
06892   
06893   }

void sRef_resetStateComplete ( sRef s )
 

Definition at line 6896 of file sRef.c.

06897 {
06898   sRef_innerAliasSetComplete (sRef_resetStateAux, s, fileloc_undefined);
06899 }

bool sRef_same ( sRef s1,
sRef s2 )
 

Definition at line 1910 of file sRef.c.

Referenced by sRefSet_unionExcept(), and sRef_includedBy().

01911 {
01912   if (s1 == s2) return TRUE;
01913   if (sRef_isInvalid (s1) || sRef_isInvalid (s2)) return FALSE;
01914 
01915   switch (s1->kind)
01916     {
01917     case SK_CVAR:
01918       return ((s2->kind == SK_CVAR) && (cref_equal (s1->info->cvar, s2->info->cvar)));
01919     case SK_PARAM:
01920       return ((s2->kind == SK_PARAM) && (s1->info->paramno == s2->info->paramno));
01921     case SK_ARRAYFETCH:
01922       if (s2->kind == SK_ARRAYFETCH)
01923         {
01924           llassert (s1->info->field->rec != s1);
01925           if (sRef_same (s1->info->arrayfetch->arr, s2->info->arrayfetch->arr))
01926             {
01927               if (s1->info->arrayfetch->indknown && s2->info->arrayfetch->indknown)
01928                 {
01929                   return (s1->info->arrayfetch->ind == s2->info->arrayfetch->ind);
01930                 }
01931               return TRUE;
01932             }
01933         }
01934       return FALSE;
01935     case SK_FIELD:
01936       {
01937         llassert (s1->info->field->rec != s1);
01938         return ((s2->kind == SK_FIELD &&
01939                  (sRef_same (s1->info->field->rec, s2->info->field->rec) &&
01940                   cstring_equal (s1->info->field->field, s2->info->field->field))));
01941       }
01942     case SK_PTR:
01943       {
01944         llassert (s1->info->ref != s1);
01945         return ((s2->kind == SK_PTR) && sRef_same (s1->info->ref, s2->info->ref));
01946       }
01947     case SK_ADR:
01948       {
01949         llassert (s1->info->ref != s1);
01950         return ((s2->kind == SK_ADR) && sRef_same (s1->info->ref, s2->info->ref));
01951       }
01952     case SK_CONJ:
01953       llassert (s1->info->conj->a != s1);
01954       llassert (s1->info->conj->b != s1);
01955       return ((sRef_same (s1->info->conj->a, s2)) && /* or or and? */
01956               (sRef_same (s1->info->conj->b, s2)));
01957     case SK_SPECIAL:
01958       return ((s2->kind == SK_SPECIAL) && s1->info->spec == s2->info->spec);
01959     case SK_DERIVED:
01960       llassert (s1->info->ref != s1);
01961       return ((s2->kind == SK_DERIVED) && sRef_same (s1->info->ref, s2->info->ref));
01962     case SK_CONST:
01963     case SK_UNCONSTRAINED:
01964     case SK_TYPE:
01965     case SK_UNKNOWN:
01966     case SK_NEW:
01967     case SK_OBJECT:
01968     case SK_EXTERNAL:
01969     case SK_RESULT:
01970       return FALSE; 
01971     }
01972   BADEXIT;
01973 }

bool sRef_sameName ( sRef s1,
sRef s2 )
 

Definition at line 6667 of file sRef.c.

Referenced by aliasTable_clearAliases(), and sRef_aliasCheckPred().

06668 {
06669   if (sRef_isInvalid (s1))
06670     {
06671       return sRef_isInvalid (s2);
06672     }
06673 
06674   if (sRef_isInvalid (s2))
06675     {
06676       return (FALSE);
06677     }
06678 
06679   switch (s1->kind)
06680     {
06681     case SK_CVAR:
06682       if (s2->kind == SK_CVAR)
06683         {
06684           return (s1->info->cvar->lexlevel == s2->info->cvar->lexlevel
06685                   && s1->info->cvar->index == s2->info->cvar->index);
06686         }
06687       else if (s2->kind == SK_PARAM)
06688         {
06689           if (context_inFunctionLike ())
06690             {
06691               uentry u1 = usymtab_getRefQuiet (s1->info->cvar->lexlevel,
06692                                                s1->info->cvar->index);
06693               uentry u2 = uentryList_getN (context_getParams (), 
06694                                            s2->info->paramno);
06695           
06696               return (cstring_equalFree (uentry_getName (u1),
06697                                          uentry_getName (u2)));
06698             }
06699           else 
06700             {
06701               return FALSE;
06702             }
06703         }
06704       else
06705         {
06706           return FALSE;
06707         }
06708     case SK_PARAM:
06709       {
06710         if (s2->kind == SK_PARAM)
06711           {
06712             return (s1->info->paramno == s2->info->paramno);
06713           }
06714         else if (s2->kind == SK_CVAR)
06715           {
06716             if (context_inFunctionLike ())
06717               {
06718                 uentry u1 = uentryList_getN (context_getParams (), 
06719                                              s1->info->paramno);
06720                 uentry u2 = usymtab_getRefQuiet (s2->info->cvar->lexlevel,
06721                                                  s2->info->cvar->index);
06722 
06723                 
06724                 return (cstring_equalFree (uentry_getName (u1),
06725                                            uentry_getName (u2)));
06726               }
06727             else 
06728               {
06729                 return FALSE;
06730               }
06731           }
06732         else
06733           {
06734             return FALSE;
06735           }
06736       }
06737 
06738     case SK_UNCONSTRAINED:
06739       return FALSE;
06740 
06741     case SK_ARRAYFETCH:
06742       if (s2->kind == SK_ARRAYFETCH)
06743         {
06744           if (bool_equal (s1->info->arrayfetch->indknown,
06745                           s2->info->arrayfetch->indknown))
06746             {
06747               if (!s1->info->arrayfetch->indknown 
06748                   || (s1->info->arrayfetch->ind == s2->info->arrayfetch->ind))
06749                 {
06750                   return sRef_sameName (s1->info->arrayfetch->arr,
06751                                         s2->info->arrayfetch->arr);
06752                 }
06753             }
06754         }
06755 
06756       return FALSE;
06757     case SK_FIELD:
06758       if (s2->kind == SK_FIELD)
06759         {
06760           if (cstring_equal (s1->info->field->field,
06761                              s2->info->field->field))
06762             {
06763               return sRef_sameName (s1->info->field->rec,
06764                                     s2->info->field->rec);
06765             }
06766 
06767         }
06768       return FALSE;
06769     case SK_PTR:
06770     case SK_ADR:
06771     case SK_DERIVED:
06772     case SK_EXTERNAL:
06773       if (s2->kind == s1->kind)
06774         {
06775           return sRef_sameName (s1->info->ref,
06776                                 s2->info->ref);
06777         }
06778 
06779       return FALSE;
06780     case SK_OBJECT:
06781       return FALSE;
06782     case SK_CONJ:
06783       return sRef_sameName (sRef_getConjA (s1), s2);
06784     case SK_NEW:
06785       return FALSE;
06786     case SK_UNKNOWN:
06787       return (s2->kind == SK_UNKNOWN);
06788     case SK_TYPE:
06789     case SK_CONST:
06790       if (s2->kind == s1->kind)
06791         {
06792           return (ctype_equal (s1->type, s2->type));
06793         }
06794       
06795       return FALSE;
06796     case SK_SPECIAL:
06797       if (s2->kind == SK_SPECIAL)
06798         {
06799           return (s1->info->spec == s2->info->spec);
06800         }
06801       return FALSE;
06802     case SK_RESULT:
06803       return (s2->kind == SK_RESULT);
06804     default:
06805       return FALSE;
06806     }
06807   BADEXIT;
06808 }

sRef sRef_saveCopy ( sRef s )
 

Definition at line 5242 of file sRef.c.

Referenced by uentry_setSref(), and uentry_setState().

05243 {
05244   sRef ret;
05245 
05246   if (sRef_isValid (s))
05247     {
05248       bool old = inFunction;
05249 
05250       /*
05251       ** Exit the function scope, so this sRef is not
05252       ** stored in the deallocation table.
05253       */
05254       
05255       inFunction = FALSE;
05256       DPRINTF (("Copying sref: %s", sRef_unparseFull(s)));
05257       ret = sRef_copy (s);
05258       DPRINTF (("Copying ===>: %s", sRef_unparseFull(ret)));
05259       inFunction = old;
05260     }
05261   else
05262     {
05263       ret = sRef_undefined;
05264     }
05265 
05266   /*@-dependenttrans@*/ 
05267   return ret;
05268   /*@=dependenttrans@*/ 
05269 }

void sRef_setAliasKind ( sRef s,
alkind kind,
fileloc loc )
 

Definition at line 4537 of file sRef.c.

Referenced by checkAssignTransfer(), exprNode_fromUIO(), exprNode_getSref(), exprNode_stringLiteral(), uentryList_fixImpParams(), uentry_makeVarFunction(), uentry_reflectQualifiers(), uentry_returnedRef(), and uentry_setStatic().

04538 {
04539   if (sRef_isValid (s))
04540     {
04541       sRef_clearDerived (s);
04542 
04543       if ((kind != s->aliaskind && kind != s->oaliaskind)
04544           && fileloc_isDefined (loc))
04545         {
04546           s->aliasinfo = alinfo_updateLoc (s->aliasinfo, loc);
04547         }
04548       
04549       s->aliaskind = kind;
04550     }
04551 }

void sRef_setAliasKindComplete ( sRef s,
alkind kind,
fileloc loc )
 

Definition at line 4532 of file sRef.c.

Referenced by uentry_returnedRef().

04533 {
04534   sRef_aliasSetCompleteParam (sRef_setAliasKind, s, kind, loc);
04535 }

void sRef_setAllocated ( sRef s,
fileloc loc )
 

Definition at line 4924 of file sRef.c.

Referenced by checkPassTransfer(), uentry_returnedRef(), and usymtab_enterFunctionScope().

04925 {
04926   sRef_setStateAux (s, SS_ALLOCATED, loc);
04927   }

void sRef_setAllocatedComplete ( sRef s,
fileloc loc )
 

Definition at line 4898 of file sRef.c.

Referenced by exprNode_assign().

04899 {
04900   sRef_innerAliasSetComplete (sRef_setAllocated, s, loc);
04901 }

void sRef_setAllocatedShallowComplete ( sRef s,
fileloc loc )
 

Definition at line 4919 of file sRef.c.

Referenced by exprNode_assign().

04920 {
04921   sRef_innerAliasSetComplete (sRef_setAllocatedShallow, s, loc);
04922 }

void sRef_setDefNull ( sRef s,
fileloc loc )
 

Definition at line 5028 of file sRef.c.

Referenced by exprNode_numLiteral(), and uentry_makeConstantAux().

05029 {
05030   if (sRef_isValid (s))
05031     {
05032       sRef_setNullStateAux (s, NS_DEFNULL, loc);
05033     }
05034 }

void sRef_setDefState ( sRef s,
sstate defstate,
fileloc loc )
 

Definition at line 4517 of file sRef.c.

Referenced by exprNode_makeInitialization(), uentry_fixupSref(), uentry_getOrigSref(), uentry_makeVarFunction(), uentry_mergeState(), uentry_reflectQualifiers(), and uentry_setDefState().

04518 {
04519   sRef_setStateAux (s, defstate, loc);
04520 }

void sRef_setDefined ( sRef s,
fileloc loc )
 

Definition at line 4778 of file sRef.c.

Referenced by checkPassTransfer(), exprNode_createId(), exprNode_iterNewId(), exprNode_makeInitialization(), processNamedDecl(), uentry_returnedRef(), and usymtab_popAndBranch().

04779 {
04780   sRef_setDefinedAux (s, loc, TRUE);
04781 }

void sRef_setDefinedComplete ( sRef s,
fileloc loc )
 

Definition at line 4773 of file sRef.c.

Referenced by exprNode_checkMSet(), and exprNode_checkSet().

04774 {
04775   sRef_innerAliasSetComplete (sRef_setDefined, s, loc);
04776 }

void sRef_setDefinedNCComplete ( sRef s,
fileloc loc )
 

Definition at line 4790 of file sRef.c.

Referenced by exprNode_checkSet().

04791 {
04792   DPRINTF (("Set Defined Complete: %s", sRef_unparseFull (s)));
04793   sRef_innerAliasSetComplete (sRef_setDefinedNoClear, s, loc);
04794   DPRINTF (("==> %s", sRef_unparseFull (s)));
04795 }

void sRef_setDependent ( sRef s,
fileloc loc )
 

Definition at line 5066 of file sRef.c.

Referenced by uentry_mergeState().

05067 {
05068   if (sRef_isValid (s) && !sRef_isConst (s) && (s->aliaskind != AK_DEPENDENT))
05069     {
05070       s->aliaskind = AK_DEPENDENT;
05071       s->aliasinfo = alinfo_updateLoc (s->aliasinfo, loc);
05072           }
05073 }

void sRef_setDependentComplete ( sRef s,
fileloc loc )
 

Definition at line 5130 of file sRef.c.

05131 {
05132   sRef_aliasSetComplete (sRef_setDependentAux, s, loc);
05133 }

void sRef_setDerivNullState ( sRef set,
sRef guide,
nstate ns )
 

Definition at line 7447 of file sRef.c.

07448 {
07449   if (sRef_isValid (set))
07450     {
07451       sRef deriv = sRef_getDeriv (set, guide);
07452       
07453       if (sRef_isValid (deriv))
07454         {
07455           deriv->nullstate = ns;
07456         }
07457     }
07458 }

void sRef_setExKind ( sRef s,
exkind exp,
fileloc loc )
 

Definition at line 4605 of file sRef.c.

Referenced by checkAssignTransfer(), exprNode_stringLiteral(), sRef_buildArrayFetch(), sRef_buildArrayFetchKnown(), sRef_buildPointer(), sRef_setExposed(), sRef_setObserver(), uentry_makeVarFunction(), and uentry_reflectQualifiers().

04606 {
04607   if (sRef_isValid (s))
04608     {
04609       if (s->expkind != exp)
04610         {
04611           s->expinfo = alinfo_updateLoc (s->expinfo, loc);
04612         }
04613       
04614       s->expkind = exp;
04615     }
04616 }

void sRef_setExposed ( sRef s,
fileloc loc )
 

Definition at line 4595 of file sRef.c.

04596 {
04597   sRef_setExKind (s, XO_EXPOSED, loc);
04598 }

void sRef_setFresh ( sRef s,
fileloc loc )
 

Definition at line 5135 of file sRef.c.

05136 {
05137   if (sRef_isValid (s))
05138     {
05139       s->aliaskind = AK_FRESH;
05140       s->aliasinfo = alinfo_updateLoc (s->aliasinfo, loc);
05141     }
05142 }

void sRef_setGlobalScope ( )
 

Definition at line 549 of file sRef.c.

Referenced by declareFunction(), declareStaticFunction(), and exprNode_iterNewId().

00550 {
00551   llassert (inFunction);
00552   inFunction = FALSE;
00553 }

void sRef_setGlobalScopeSafe ( )
 

Definition at line 563 of file sRef.c.

Referenced by uentry_makeUnrecognized().

00564 {
00565     oldInFunction = inFunction;
00566   inFunction = FALSE;
00567 }

void sRef_setKept ( sRef s,
fileloc loc )
 

Definition at line 5084 of file sRef.c.

Referenced by uentry_mergeState().

05085 {
05086   if (sRef_isValid (s) && !sRef_isConst (s) && (s->aliaskind != AK_KEPT))
05087     {
05088       sRef base = sRef_getBaseSafe (s);  
05089       
05090       while (sRef_isValid (base) && sRef_isKnown (base))
05091         {
05092           if (base->defstate == SS_DEFINED) 
05093             {
05094               base->defstate = SS_PDEFINED; 
05095                       base = sRef_getBaseSafe (base); 
05096             }
05097           else 
05098             {
05099               break; 
05100             }
05101 
05102         }
05103 
05104       s->aliaskind = AK_KEPT;
05105       s->aliasinfo = alinfo_updateLoc (s->aliasinfo, loc);
05106           }
05107 }

void sRef_setKeptComplete ( sRef s,
fileloc loc )
 

Definition at line 5125 of file sRef.c.

05126 {
05127   sRef_aliasSetComplete (sRef_setKeptAux, s, loc);
05128 }

void sRef_setLastReference ( sRef s,
sRef ref,
fileloc loc )
 

Definition at line 4948 of file sRef.c.

Referenced by canLoseReference().

04949 {
04950   if (sRef_isValid (s))
04951     {
04952       s->aliaskind = sRef_getAliasKind (ref);
04953       s->aliasinfo = alinfo_updateRefLoc (s->aliasinfo, ref, loc);
04954     }
04955 }

void sRef_setModified ( sRef s )
 

Definition at line 906 of file sRef.c.

Referenced by sRefSet_modifyMember(), and uentry_mergeState().

00907 {
00908   if (sRef_isValid (s))
00909     {
00910       s->modified = TRUE;
00911 
00912       
00913       if (sRef_isRefsField (s))
00914         {
00915           sRef base = sRef_getBase (s);
00916 
00917           
00918           llassert (s->kind == SK_FIELD);
00919 
00920           
00921           if (sRef_isPointer (base))
00922             {
00923               base = sRef_getBase (base);
00924                     }
00925 
00926           if (sRef_isRefCounted (base))
00927             {
00928               base->aliaskind = AK_NEWREF;
00929                     }
00930         }
00931 
00932           }
00933 }

void sRef_setNotNull ( sRef s,
fileloc loc )
 

Definition at line 4968 of file sRef.c.

Referenced by exprNode_preOp(), and uentry_returnedRef().

04969 {
04970   if (sRef_isValid (s))
04971     {
04972       sRef_setNullStateAux (s, NS_NOTNULL, loc);
04973     }
04974 }

void sRef_setNullError ( sRef s )
 

Definition at line 5044 of file sRef.c.

Referenced by exprNode_arrayFetch(), exprNode_arrowAccess(), exprNode_functionCall(), and exprNode_preOp().

05045 {
05046   if (sRef_isValid (s))
05047     {
05048       sRef_setNullStateAux (s, NS_UNKNOWN, fileloc_undefined);
05049     }
05050 }

void sRef_setNullState ( sRef s,
nstate n,
fileloc loc )
 

Definition at line 4976 of file sRef.c.

Referenced by sRef_setNullStateInnerComplete(), uentry_fixupSref(), uentry_getOrigSref(), uentry_makeDatatypeAux(), uentry_makeVarFunction(), and uentry_returnedRef().

04977 {
04978   if (sRef_isValid (s))
04979     {
04980       sRef_setNullStateAux (s, n, loc);
04981     }
04982 }

void sRef_setNullStateInnerComplete ( sRef s,
nstate n,
fileloc loc )
 

Definition at line 4984 of file sRef.c.

Referenced by checkAssignTransfer().

04985 {
04986   sRef_setNullState (s, n, loc);
04987 
04988   switch (n)
04989     {
04990     case NS_POSNULL:
04991       sRef_innerAliasSetComplete (sRef_setPosNull, s, loc);
04992       break;
04993     case NS_DEFNULL:
04994       sRef_innerAliasSetComplete (sRef_setDefNull, s, loc);
04995       break;
04996     case NS_UNKNOWN:
04997       sRef_innerAliasSetComplete (sRef_setNullUnknown, s, loc);
04998       break;
04999     case NS_NOTNULL:
05000       sRef_innerAliasSetComplete (sRef_setNotNull, s, loc);
05001       break;
05002     case NS_MNOTNULL:
05003       sRef_innerAliasSetComplete (sRef_setNotNull, s, loc);
05004       break;
05005     case NS_RELNULL:
05006       sRef_innerAliasSetComplete (sRef_setNullUnknown, s, loc);
05007       break;
05008     case NS_CONSTNULL:
05009       sRef_innerAliasSetComplete (sRef_setDefNull, s, loc);
05010       break;
05011     case NS_ABSNULL:
05012       sRef_innerAliasSetComplete (sRef_setNullUnknown, s, loc);
05013       break;
05014     case NS_ERROR:
05015       sRef_innerAliasSetComplete (sRef_setNullErrorLoc, s, loc);
05016       break;
05017     }
05018 }

void sRef_setNullUnknown ( sRef s,
fileloc loc )
 

Definition at line 5036 of file sRef.c.

Referenced by checkPassTransfer().

05037 {
05038   if (sRef_isValid (s))
05039     {
05040       sRef_setNullStateAux (s, NS_UNKNOWN, loc);
05041     }
05042 }

void sRef_setObserver ( sRef s,
fileloc loc )
 

Definition at line 4590 of file sRef.c.

04591 {
04592   sRef_setExKind (s, XO_OBSERVER, loc);
04593 }

void sRef_setOnly ( sRef s,
fileloc loc )
 

Definition at line 5057 of file sRef.c.

Referenced by uentry_returnedRef().

05058 {
05059   if (sRef_isValid (s) && s->aliaskind != AK_ONLY)
05060     {
05061       s->aliaskind = AK_ONLY;
05062       s->aliasinfo = alinfo_updateLoc (s->aliasinfo, loc);
05063           }
05064 }

void sRef_setOrigAliasKind ( sRef s,
alkind kind )
 

Definition at line 4553 of file sRef.c.

Referenced by uentry_setStatic().

04554 {
04555   if (sRef_isValid (s))
04556     {
04557       s->oaliaskind = kind;
04558     }
04559 }

void sRef_setOwned ( sRef s,
fileloc loc )
 

Definition at line 5075 of file sRef.c.

05076 {
05077   if (sRef_isValid (s) && !sRef_isConst (s) && (s->aliaskind != AK_OWNED))
05078     {
05079       s->aliaskind = AK_OWNED;
05080       s->aliasinfo = alinfo_updateLoc (s->aliasinfo, loc);
05081           }
05082 }

void sRef_setParamNo ( sRef s,
int l )
 

Definition at line 2919 of file sRef.c.

Referenced by uentry_setParamNo().

02920 {
02921   llassert (sRef_isValid (s) && s->kind == SK_PARAM);
02922   s->info->paramno = l;
02923 }

void sRef_setPartial ( sRef s,
fileloc loc )
 

Definition at line 4929 of file sRef.c.

Referenced by checkAssignTransfer(), checkPassTransfer(), exprNode_checkSet(), and usymtab_enterFunctionScope().

04930 {
04931   sRef_setStateAux (s, SS_PARTIAL, loc);
04932   }

void sRef_setPartialDefinedComplete ( sRef s,
fileloc loc )
 

Definition at line 4768 of file sRef.c.

Referenced by exprNode_checkSet().

04769 {
04770   sRef_innerAliasSetComplete (sRef_setPartialDefined, s, loc);
04771 }

void sRef_setPdefined ( sRef s,
fileloc loc )
 

Definition at line 4821 of file sRef.c.

Referenced by checkAssignTransfer(), and exprNode_checkSet().

04822 {
04823   if (sRef_isValid (s) && !sRef_isPartial (s))
04824     {
04825       sRef base = sRef_getBaseSafe (s);
04826 
04827       if (s->defstate == SS_ALLOCATED)
04828         {
04829           return;
04830         }
04831       
04832       if (s->defstate != SS_PDEFINED && fileloc_isDefined (loc))
04833         {
04834           s->definfo = alinfo_updateLoc (s->definfo, loc);
04835         }
04836 
04837       s->defstate = SS_PDEFINED;
04838       
04839       /* e.g., if x is allocated, *x = 3 defines x */
04840       
04841       while (sRef_isValid (base) && sRef_isKnown (base))
04842         {
04843           if (base->defstate == SS_DEFINED)
04844             { 
04845               sRef nb;
04846 
04847                       base->defstate = SS_PDEFINED; 
04848               nb = sRef_getBaseSafe (base); 
04849               base = nb;
04850             }
04851           else 
04852             { 
04853               break; 
04854             }
04855         }      
04856     }
04857 }

void sRef_setPosNull ( sRef s,
fileloc loc )
 

Definition at line 5020 of file sRef.c.

05021 {
05022   if (sRef_isValid (s))
05023     {
05024       sRef_setNullStateAux (s, NS_POSNULL, loc);
05025     }
05026 }

void sRef_setShared ( sRef s,
fileloc loc )
 

Definition at line 4934 of file sRef.c.

04935 {
04936   if (sRef_isValid (s))
04937     {
04938       if (s->aliaskind != AK_SHARED && fileloc_isDefined (loc))
04939         {
04940           s->aliasinfo = alinfo_updateLoc (s->aliasinfo, loc);
04941         }
04942 
04943       s->aliaskind = AK_SHARED;
04944       /* don't! sRef_clearDerived (s); */
04945     }
04946 }

void sRef_setStateFromType ( sRef s,
ctype ct )
 

Definition at line 329 of file sRef.c.

Referenced by uentry_makeDatatypeAux().

00330 {
00331   if (sRef_isValid (s))
00332     {
00333       if (ctype_isUser (ct))
00334         {
00335           sRef_setStateFromUentry 
00336             (s, usymtab_getTypeEntry (ctype_typeId (ct)));
00337         }
00338       else if (ctype_isAbstract (ct))
00339         {
00340           sRef_setStateFromAbstractUentry 
00341             (s, usymtab_getTypeEntry (ctype_typeId (ct)));
00342         }
00343       else
00344         {
00345           ; /* not a user type */
00346         }
00347     }
00348 }

void sRef_setStateFromUentry ( sRef s,
uentry ue )
 

Definition at line 6106 of file sRef.c.

Referenced by uentry_returnedRef().

06107 {
06108   sstate defstate;
06109 
06110   llassert (sRef_isValid (s));
06111   
06112   sRef_setPartsFromUentry (s, ue);
06113 
06114   defstate = uentry_getDefState (ue);
06115 
06116   if (sstate_isKnown (defstate))
06117     {
06118       s->defstate = defstate;
06119     }
06120   else
06121     {
06122       ;
06123     }
06124 }

void sRef_setType ( sRef s,
ctype t )
 

Definition at line 5511 of file sRef.c.

Referenced by uentry_setType().

05512 {
05513   if (sRef_isValid (s))
05514     {
05515       s->type = t;
05516     }
05517 }

void sRef_setTypeFull ( sRef s,
ctype t )
 

Definition at line 5519 of file sRef.c.

Referenced by exprNode_cast().

05520 {
05521   if (sRef_isValid (s))
05522     {
05523       s->type = t;
05524 
05525       sRefSet_allElements (s->deriv, current)
05526         {
05527           sRef_setTypeFull (current, ctype_unknown);
05528         } end_sRefSet_allElements ;
05529     }
05530 }

void sRef_setUndefined ( sRef s,
fileloc loc )
 

Definition at line 4661 of file sRef.c.

Referenced by usymtab_enterFunctionScope().

04662 {
04663   if (sRef_isValid (s))
04664     {
04665       s->defstate = SS_UNDEFINED;
04666 
04667       if (fileloc_isDefined (loc))
04668         {
04669           s->definfo = alinfo_updateLoc (s->definfo, loc);
04670         }
04671 
04672       sRef_clearDerived (s);
04673     }
04674 }

void sRef_showAliasInfo ( sRef s )
 

Definition at line 7159 of file sRef.c.

Referenced by usymtab_checkFinalScope().

07160 {
07161   if (sRef_hasAliasInfoLoc (s))
07162     {
07163       if (sRef_isFresh (s))
07164         {
07165           llgenindentmsg 
07166             (message ("Fresh storage %qallocated", sRef_unparseOpt (s)),
07167              sRef_getAliasInfoLoc (s));
07168         }
07169       else 
07170         {
07171           if (!sRef_isRefCounted (s))
07172             {
07173               llgenindentmsg 
07174                 (message ("Storage %qbecomes %s", 
07175                           sRef_unparseOpt (s),
07176                           alkind_unparse (sRef_getAliasKind (s))),
07177                  sRef_getAliasInfoLoc (s));
07178             }
07179         }
07180     }
07181 }

void sRef_showExpInfo ( sRef s )
 

Definition at line 7083 of file sRef.c.

07084 {
07085   if (sRef_hasExpInfoLoc (s))
07086     {
07087       llgenindentmsg (message ("Storage %qbecomes %s", sRef_unparseOpt (s), 
07088                                exkind_unparse (s->expkind)),
07089                       sRef_getExpInfoLoc (s));
07090     }
07091 }

void sRef_showNotReallyDefined ( sRef s )
 

Definition at line 4475 of file sRef.c.

04476 {
04477   if (sRef_isValid (s))
04478     {
04479       if (sRef_isAnyDefined (s))
04480         {
04481           BADBRANCH;
04482         }
04483       else
04484         {
04485           if (sRef_isAllocated (s) || sRef_isPdefined (s))
04486             {
04487               sRef ref = whatUndefined (s, 0);
04488 
04489               llassert (sRef_isValid (ref));
04490 
04491               if (ref != s)
04492                 {
04493                   llgenindentmsgnoloc
04494                     (message ("This sub-reference is %s: %q",
04495                               sstate_unparse (sRef_getDefState (ref)),
04496                               sRef_unparse (ref)));
04497                 }
04498             }
04499           else
04500             {
04501               ;
04502             }
04503         }
04504     }
04505   else
04506     {
04507       BADBRANCH;
04508     }
04509 }

void sRef_showNullInfo ( sRef s )
 

Definition at line 7094 of file sRef.c.

Referenced by exprNode_arrayFetch(), exprNode_arrowAccess(), exprNode_functionCall(), and exprNode_preOp().

07095 {
07096   if (sRef_hasNullInfoLoc (s) && sRef_isKnown (s))
07097     {
07098       switch (s->nullstate)
07099         {
07100         case NS_CONSTNULL:
07101           {
07102             fileloc loc = sRef_getNullInfoLoc (s);
07103             
07104             if (fileloc_isDefined (loc) && !fileloc_isLib (loc))
07105               {
07106                 llgenindentmsg 
07107                   (message ("Storage %qbecomes null", sRef_unparseOpt (s)),
07108                    loc);
07109               }
07110             break;
07111           }
07112         case NS_DEFNULL:
07113           {
07114             fileloc loc = sRef_getNullInfoLoc (s);
07115             
07116             if (fileloc_isDefined (loc) && !fileloc_isLib (loc))
07117               {
07118                 llgenindentmsg (message ("Storage %qbecomes null", sRef_unparseOpt (s)),
07119                                 loc);
07120               }
07121             break;
07122           }
07123         case NS_ABSNULL:
07124         case NS_POSNULL:
07125           llgenindentmsg
07126             (message ("Storage %qmay become null", sRef_unparseOpt (s)),
07127              sRef_getNullInfoLoc (s));
07128           break;
07129         case NS_NOTNULL:
07130         case NS_MNOTNULL:
07131           llgenindentmsg
07132             (message ("Storage %qbecomes not null", sRef_unparseOpt (s)),
07133              sRef_getNullInfoLoc (s));
07134           break;
07135         case NS_UNKNOWN:
07136           llgenindentmsg
07137             (message ("Storage %qnull state becomes unknown",
07138                       sRef_unparseOpt (s)),
07139              sRef_getNullInfoLoc (s));
07140           break;
07141 
07142         case NS_ERROR:
07143           BADBRANCHCONT;
07144           break;
07145 
07146         default:
07147           llgenindentmsg
07148             (message ("<error case> Storage %q becomes %s",
07149                       sRef_unparse (s), 
07150                       nstate_unparse (s->nullstate)),
07151              sRef_getNullInfoLoc (s));
07152           
07153           break;
07154         }
07155     }
07156 }

void sRef_showRefKilled ( sRef s )
 

Definition at line 7024 of file sRef.c.

07025 {
07026   if (sRef_hasStateInfoLoc (s))
07027     {
07028       llgenindentmsg (message ("Storage %q released", 
07029                                sRef_unparse (s)), sRef_getStateInfoLoc (s));
07030     }
07031 }

void sRef_showRefLost ( sRef s )
 

Definition at line 7014 of file sRef.c.

Referenced by usymtab_checkFinalScope().

07015 {
07016   if (sRef_hasAliasInfoLoc (s))
07017     {
07018       llgenindentmsg (cstring_makeLiteral ("Original reference lost"),
07019                 sRef_getAliasInfoLoc (s));
07020     }
07021 }

void sRef_showStateInconsistent ( sRef s )
 

Definition at line 7034 of file sRef.c.

07035 {
07036   if (sRef_hasStateInfoLoc (s))
07037     {
07038       llgenindentmsg
07039         (message ("Storage %qbecomes inconsistent (released on one branch)",
07040                   sRef_unparseOpt (s)), 
07041          sRef_getStateInfoLoc (s));
07042     }
07043 }

void sRef_showStateInfo ( sRef s )
 

Definition at line 7046 of file sRef.c.

Referenced by checkPassTransfer().

07047 {
07048   if (sRef_hasStateInfoLoc (s))
07049     {
07050       if (s->defstate == SS_DEAD)
07051         {
07052           llgenindentmsg 
07053             (message ("Storage %qis released", sRef_unparseOpt (s)),
07054              sRef_getStateInfoLoc (s));
07055         }
07056       else if (s->defstate == SS_ALLOCATED || s->defstate == SS_DEFINED)
07057         {
07058           llgenindentmsg 
07059             (message ("Storage %qis %s", sRef_unparseOpt (s), 
07060                       sstate_unparse (s->defstate)),
07061              sRef_getStateInfoLoc (s));
07062         }
07063       else if (s->defstate == SS_UNUSEABLE)
07064         {
07065           llgenindentmsg 
07066             (message ("Storage %qbecomes inconsistent (clauses merge with"
07067                       "%qreleased on one branch)",
07068                       sRef_unparseOpt (s), 
07069                       sRef_unparseOpt (s)),
07070              sRef_getStateInfoLoc (s));
07071         }
07072       else 
07073         {
07074           llgenindentmsg (message ("Storage %qbecomes %s", 
07075                                    sRef_unparseOpt (s), 
07076                                    sstate_unparse (s->defstate)),
07077                           sRef_getStateInfoLoc (s));
07078         }
07079     }
07080 }

bool sRef_similar ( sRef s1,
sRef s2 )
 

Definition at line 1613 of file sRef.c.

Referenced by aliasTable_checkGlobs(), globSet_lookup(), sRefSet_lookupMember(), sRefSet_modifyMember(), sRef_aliasCheckPred(), sRef_includedBy(), and usymtab_addMustAlias().

01614 {
01615   if (s1 == s2) return TRUE;
01616   if (sRef_isInvalid (s1) || sRef_isInvalid (s2)) return FALSE;
01617 
01618   if (sRef_isConj (s2)) 
01619     {
01620       return (sRef_similar (s1, sRef_getConjA (s2)) ||
01621               sRef_similar (s1, sRef_getConjB (s2)));
01622     }
01623 
01624   if (sRef_isDerived (s2))
01625    {
01626      return (sRef_includedBy (s1, s2->info->ref));
01627    }
01628 
01629   switch (s1->kind)
01630     {
01631     case SK_CVAR:
01632       return ((s2->kind == SK_CVAR)
01633               && (cref_equal (s1->info->cvar, s2->info->cvar)));
01634     case SK_PARAM:
01635       return ((s2->kind == SK_PARAM)
01636               && (s1->info->paramno == s2->info->paramno));
01637     case SK_ARRAYFETCH:
01638       if (s2->kind == SK_ARRAYFETCH)
01639         {
01640           if (sRef_similar (s1->info->arrayfetch->arr,
01641                             s2->info->arrayfetch->arr))
01642             {
01643               if (s1->info->arrayfetch->indknown)
01644                 {
01645                   if (s2->info->arrayfetch->indknown)
01646                     {
01647                       return (s1->info->arrayfetch->ind == s2->info->arrayfetch->ind);
01648                     }
01649                   else 
01650                     {
01651                       return TRUE;
01652                     }
01653                 }
01654               else
01655                 {
01656                   return TRUE;
01657                 }
01658             }
01659         }
01660       else 
01661         {
01662           if (s2->kind == SK_PTR)
01663             {
01664               if (sRef_similar (s1->info->arrayfetch->arr,
01665                                 s2->info->ref))
01666                 {
01667                   return TRUE; 
01668                 }
01669             }
01670         }
01671 
01672       return FALSE;
01673     case SK_FIELD:
01674       return ((s2->kind == SK_FIELD
01675                && (sRef_similar (s1->info->field->rec,
01676                                  s2->info->field->rec)
01677                    && cstring_equal (s1->info->field->field,
01678                                      s2->info->field->field))));
01679     case SK_PTR:
01680       if (s2->kind == SK_PTR)
01681         {
01682           return sRef_similar (s1->info->ref, s2->info->ref);
01683         }
01684       else 
01685         {
01686           if (s2->kind == SK_ARRAYFETCH)
01687             {
01688               if (sRef_similar (s2->info->arrayfetch->arr,
01689                                 s1->info->ref))
01690                 {
01691                   return TRUE; 
01692                 }
01693             }
01694         }
01695 
01696       return FALSE;
01697     case SK_ADR:
01698       return ((s2->kind == SK_ADR)
01699               && sRef_similar (s1->info->ref, s2->info->ref));
01700     case SK_CONJ:
01701       return ((sRef_similar (s1->info->conj->a, s2) ||
01702               (sRef_similar (s1->info->conj->b, s2))));
01703     case SK_DERIVED:
01704       return (sRef_includedBy (s2, s1->info->ref));
01705     case SK_UNCONSTRAINED:
01706       return (s2->kind == SK_UNCONSTRAINED
01707               && cstring_equal (s1->info->fname, s2->info->fname));
01708     case SK_CONST:
01709     case SK_TYPE:
01710     case SK_NEW:
01711     case SK_UNKNOWN:
01712     case SK_OBJECT:
01713     case SK_EXTERNAL:
01714     case SK_RESULT:
01715       return FALSE;
01716     case SK_SPECIAL:
01717       return (s2->kind == SK_SPECIAL 
01718               && (s1->info->spec == s2->info->spec));
01719     }
01720 
01721   /*@notreached@*/ DPRINTF (("Fell through for: %s / %s", sRef_unparse (s1), sRef_unparse (s2)));
01722   BADEXIT;
01723 }

bool sRef_similarRelaxed ( sRef s1,
sRef s2 )
 

Definition at line 1552 of file sRef.c.

01553 {
01554   bool us1, us2;
01555 
01556   if (s1 == s2) 
01557     {
01558       if (sRef_isThroughArrayFetch (s1))
01559         {
01560           return FALSE;
01561         }
01562       else
01563         {
01564           return TRUE;
01565         }
01566     }
01567 
01568   if (sRef_isInvalid (s1) || sRef_isInvalid (s2)) return FALSE;
01569 
01570   us1 = sRef_uniqueReference (s1);
01571   us2 = sRef_uniqueReference (s2);
01572 
01573   if ((s1->kind == SK_EXTERNAL && (s2->kind != SK_EXTERNAL && !us2))
01574       || (s2->kind == SK_EXTERNAL && (s1->kind != SK_EXTERNAL && !us1)))
01575     {
01576       /*
01577       ** Previously, also:
01578       **   || (sRef_isExposed (s1) && !us2) || (sRef_isExposed (s2) && !us1)) ???? 
01579       **
01580       ** No clue why this was there?!
01581       */
01582 
01583 
01584       if (sRef_isExposed (s1) && sRef_isCvar (s1))
01585         {
01586           uentry ue1 = sRef_getUentry (s1);
01587 
01588           if (uentry_isRefParam (ue1))
01589             {
01590               return sRef_similarRelaxedAux (s1, s2);
01591             }
01592         }
01593       
01594       if (sRef_isExposed (s2) && sRef_isCvar (s2))
01595         {
01596           uentry ue2 = sRef_getUentry (s2);
01597 
01598           if (uentry_isRefParam (ue2))
01599             {
01600               return sRef_similarRelaxedAux (s1, s2);
01601             }
01602         }
01603       
01604             return (ctype_match (s1->type, s2->type));
01605     }
01606   else
01607     {
01608             return sRef_similarRelaxedAux (s1, s2);
01609     }
01610 }

cstring sRef_stateAltVerb ( sRef s )
 

Definition at line 1154 of file sRef.c.

01155 {
01156   if (sRef_isDead (s))
01157     {
01158       return cstring_makeLiteralTemp ("live");
01159     }
01160   else if (sRef_isKept (s))
01161     {
01162       return cstring_makeLiteralTemp ("not kept");
01163     }
01164   else if (sRef_isDependent (s))
01165     {
01166       return cstring_makeLiteralTemp ("independent");
01167     }
01168   else
01169     {
01170       BADEXIT;
01171     }
01172 }

cstring sRef_stateVerb ( sRef s )
 

Definition at line 1134 of file sRef.c.

01135 {
01136   if (sRef_isDead (s))
01137     {
01138       return cstring_makeLiteralTemp ("released");
01139     }
01140   else if (sRef_isKept (s))
01141     {
01142       return cstring_makeLiteralTemp ("kept");
01143     }
01144   else if (sRef_isDependent (s))
01145     {
01146       return cstring_makeLiteralTemp ("dependent");
01147     }
01148   else
01149     {
01150       BADEXIT;
01151     }
01152 }

void sRef_storeState ( sRef s )
 

Definition at line 6838 of file sRef.c.

Referenced by uentry_mergeDefinition(), uentry_mergeEntries(), uentry_reflectQualifiers(), and uentry_setRefCounted().

06839 {
06840   if (sRef_isInvalid (s)) return;
06841 
06842   s->oaliaskind = s->aliaskind;
06843   s->oexpkind = s->expkind;
06844 }

cstring sRef_unconstrainedName ( sRef s )
 

Definition at line 2834 of file sRef.c.

02835 {
02836   llassert (sRef_isUnconstrained (s));
02837 
02838   return s->info->fname;
02839 }

sRef sRef_undump ( char ** c )
 

Definition at line 2161 of file sRef.c.

02162 {
02163   char p = **c;
02164 
02165   (*c)++;
02166 
02167   switch (p)
02168     {
02169     case 'g':
02170       return (sRef_makeGlobal (usymId_fromInt (getInt (c)), ctype_unknown));
02171     case 'p':
02172       return (sRef_makeParam (getInt (c), ctype_unknown));
02173     case 'r':
02174       return (sRef_makeResultType (ctype_undump (c)));
02175     case 'a':
02176       {
02177         if ((**c >= '0' && **c <= '9') || **c == '-')
02178           {
02179             int i = getInt (c);
02180             sRef arr = sRef_undump (c);
02181             sRef ret = sRef_buildArrayFetchKnown (arr, i);
02182 
02183             return ret;
02184           }
02185         else
02186           {
02187             sRef arr = sRef_undump (c);
02188             sRef ret = sRef_buildArrayFetch (arr);
02189 
02190             return ret;
02191           }
02192       }
02193     case 'f':
02194       {
02195         cstring fname = cstring_undefined;
02196         sRef ret;
02197 
02198         while (**c != '.')
02199           {
02200             fname = cstring_appendChar (fname, **c);
02201             (*c)++;
02202           }
02203         (*c)++;
02204 
02205         ret = sRef_buildField (sRef_undump (c), fname);
02206         cstring_markOwned (fname);
02207         return (ret);
02208       }
02209     case 's':
02210       {
02211         int i = getInt (c);
02212         speckind sk = speckind_fromInt (i);
02213 
02214         switch (sk)
02215           {
02216           case SR_NOTHING:   return (sRef_makeNothing ());
02217           case SR_INTERNAL:  return (sRef_makeInternalState ());
02218           case SR_SPECSTATE: return (sRef_makeSpecState ());
02219           case SR_SYSTEM:    return (sRef_makeSystemState ());
02220           }
02221         BADEXIT;
02222       }
02223     case 't':
02224       {
02225         sRef ptr = sRef_undump (c);
02226         sRef ret = sRef_makePointer (ptr);
02227 
02228         return (ret);
02229       }
02230     case 'd':
02231       {
02232         sRef adr = sRef_undump (c);
02233         sRef ret = sRef_makeAddress (adr);
02234 
02235         return (ret);
02236       }
02237     case 'o':
02238       {
02239         return (sRef_makeObject (ctype_undump (c)));
02240       }
02241     case 'c':
02242       {
02243         sRef s1 = sRef_undump (c);
02244         sRef s2 = ((*c)++, sRef_undump (c));
02245         sRef ret = sRef_makeConj (s1, s2);
02246 
02247         return (ret);
02248       }
02249     case '-':
02250       return sRef_undefined;
02251     case 'u':
02252       return sRef_makeUnknown ();
02253     case 'x':
02254       return sRef_makeUnknown ();
02255     default:
02256       llfatalerror (message ("sRef_undump: bad line: %s", cstring_fromChars (*c)));
02257     }
02258   BADEXIT;
02259 }

sRef sRef_undumpGlobal ( char ** c )
 

Definition at line 2107 of file sRef.c.

02108 {
02109   char p = **c;
02110 
02111   (*c)++;
02112 
02113   switch (p)
02114     {
02115     case 'g':
02116       {
02117         usymId uid = usymId_fromInt (getInt (c));
02118         sstate defstate;
02119         nstate nullstate;
02120         sRef ret;
02121 
02122         checkChar (c, '@');
02123         defstate = sstate_fromInt (getInt (c));
02124 
02125         checkChar (c, '@');
02126         nullstate = nstate_fromInt (getInt (c));
02127 
02128         ret = sRef_makeGlobal (uid, ctype_unknown);
02129         ret->nullstate = nullstate;
02130         ret->defstate = defstate;
02131         return ret;
02132       }
02133     case 's':
02134       {
02135         int i = getInt (c);
02136         speckind sk = speckind_fromInt (i);
02137 
02138         switch (sk)
02139           {
02140           case SR_NOTHING:   return (sRef_makeNothing ());
02141           case SR_INTERNAL:  return (sRef_makeInternalState ());
02142           case SR_SPECSTATE: return (sRef_makeSpecState ());
02143           case SR_SYSTEM:    return (sRef_makeSystemState ());
02144           }
02145         BADEXIT;
02146       }
02147     case '-':
02148       return sRef_undefined;
02149     case 'u':
02150       return sRef_makeUnknown ();
02151     case 'x':
02152       return sRef_makeUnknown ();
02153     default:
02154       llfatalerror (message ("sRef_undumpGlobal: bad line: %s",
02155                              cstring_fromChars (*c)));
02156     }
02157   BADEXIT;
02158 }

cstring sRef_unparse ( sRef s )
 

Definition at line 2525 of file sRef.c.

Referenced by aliasTable_checkGlobs(), checkReturnTransfer(), context_getAliasAnnote(), exprChecks_checkUsedGlobs(), exprNode_arrayFetch(), exprNode_checkAllMods(), exprNode_functionCall(), exprNode_preOp(), globSet_insert(), modListArrayFetch(), modListArrowAccess(), modListFieldAccess(), modListPointer(), sRefSet_unparsePlain(), sRef_fixResultType(), sRef_showNotReallyDefined(), sRef_similar(), sRef_unparseOpt(), sRef_unparsePreOpt(), specialClauses_checkAll(), usymtab_checkFinalScope(), and varDeclarationNode_unparse().

02526 {
02527   if (sRef_isInvalid (s)) return (cstring_makeLiteral ("?"));
02528 
02529   if (context_inFunctionLike ())
02530     {
02531       return (sRef_unparseWithArgs (s, context_getParams ()));
02532     }
02533   else
02534     {
02535       return (sRef_unparseNoArgs (s));
02536     }
02537 }

cstring sRef_unparseDebug ( sRef s )
 

Definition at line 2655 of file sRef.c.

Referenced by sRef_getField(), sRef_unparseFull(), sRef_unparseOpt(), and sRef_unparsePreOpt().

02656 {
02657   if (sRef_isInvalid (s)) return (cstring_makeLiteral ("<undef>"));
02658 
02659   switch (s->kind)
02660     {
02661     case SK_UNCONSTRAINED:
02662       return (message ("<unconstrained %s>", s->info->fname));
02663     case SK_CVAR:
02664       {
02665         uentry ce;
02666 
02667         ce = usymtab_getRefQuiet (s->info->cvar->lexlevel, s->info->cvar->index);
02668 
02669         if (uentry_isInvalid (ce))
02670           {
02671             return (message ("<scope: %d.%d *invalid*>", 
02672                              s->info->cvar->lexlevel,
02673                              s->info->cvar->index));
02674           }
02675         else
02676           {
02677             return (message ("<scope: %d.%d *%q*>", 
02678                              s->info->cvar->lexlevel,
02679                              s->info->cvar->index,
02680                              uentry_getName (ce)));
02681           }
02682 
02683       }
02684     case SK_PARAM:
02685       {
02686         return (message ("<parameter %d>", s->info->paramno + 1));
02687       }
02688     case SK_ARRAYFETCH:
02689       if (s->info->arrayfetch->indknown)
02690         {
02691           return (message ("%q[%d]", sRef_unparseDebug (s->info->arrayfetch->arr),
02692                            s->info->arrayfetch->ind));
02693         }
02694       else
02695         {
02696           return (message ("%q[]", sRef_unparseDebug (s->info->arrayfetch->arr)));
02697         }
02698     case SK_FIELD:
02699       return (message ("%q.%s", sRef_unparseDebug (s->info->field->rec),
02700                        s->info->field->field));
02701     case SK_PTR:
02702       return (message ("*(%q)", sRef_unparseDebug (s->info->ref)));
02703     case SK_ADR:
02704       return (message ("&%q", sRef_unparseDebug (s->info->ref)));
02705     case SK_OBJECT:
02706       return (message ("<object type %s>", ctype_unparse (s->info->object)));
02707     case SK_CONJ:
02708       return (message ("%q | %q", sRef_unparseDebug (s->info->conj->a),
02709                        sRef_unparseDebug (s->info->conj->b)));
02710     case SK_NEW:
02711       return message ("<new: %s>", s->info->fname);
02712     case SK_DERIVED:
02713       return (message ("<derived %q>", sRef_unparseDebug (s->info->ref)));
02714     case SK_EXTERNAL:
02715       return (message ("<external %q>", sRef_unparseDebug (s->info->ref)));
02716     case SK_TYPE:
02717       return (message ("<type %s>", ctype_unparse (s->type)));
02718     case SK_CONST:
02719       return (message ("<const %s>", ctype_unparse (s->type)));
02720     case SK_RESULT:
02721       return (message ("<result %s>", ctype_unparse (s->type)));
02722     case SK_SPECIAL:
02723       return (message ("<spec %s>",
02724                        cstring_makeLiteralTemp
02725                        (s->info->spec == SR_NOTHING ? "nothing"
02726                         : s->info->spec == SR_INTERNAL ? "internalState"
02727                         : s->info->spec == SR_SPECSTATE ? "spec state"
02728                         : s->info->spec == SR_SYSTEM ? "fileSystem"
02729                         : "error")));
02730     case SK_UNKNOWN:
02731       return cstring_makeLiteral ("<unknown>");
02732     }
02733 
02734   BADEXIT;
02735 }

cstring sRef_unparseDeep ( sRef s )
 

Definition at line 4180 of file sRef.c.

Referenced by uentry_unparseFull().

04181 {
04182   cstring st = cstring_undefined;
04183 
04184   st = message ("%q:", sRef_unparseFull (s));
04185 
04186   if (sRef_isValid (s))
04187     {
04188       sRefSet_allElements (s->deriv, el)
04189         {
04190           st = message("%q\n%q", st, sRef_unparseDeep (el));
04191         } end_sRefSet_allElements ;
04192     }
04193 
04194   return st;
04195 }

cstring sRef_unparseFull ( sRef s )
 

Definition at line 4168 of file sRef.c.

Referenced by checkPassTransfer(), exprNode_cast(), sRef_saveCopy(), and uentry_unparseFull().

04169 {
04170   if (sRef_isInvalid (s)) return (cstring_undefined);
04171 
04172   return (message ("[%d] %q - %q [%s] { %q }", 
04173                    (int) s,
04174                    sRef_unparseDebug (s), 
04175                    sRef_unparseState (s),
04176                    exkind_unparse (s->oexpkind),
04177                    sRefSet_unparseDebug (s->deriv)));
04178 }

cstring sRef_unparseKindName ( sRef s )
 

Definition at line 6370 of file sRef.c.

06371 {
06372   cstring result;
06373 
06374   if (s == sRef_undefined) return cstring_makeLiteral ("<invalid>");
06375 
06376   s = sRef_fixConj (s);
06377 
06378   switch (s->kind)
06379     {
06380     case SK_CVAR: 
06381       if (sRef_isLocalVar (s)) 
06382         {
06383           result = cstring_makeLiteral ("Variable");
06384         }
06385       else
06386         {
06387           result = cstring_makeLiteral ("Undef global");
06388         }
06389       break;
06390     case SK_PARAM:
06391       result = cstring_makeLiteral ("Out parameter");
06392       break;
06393     case SK_ARRAYFETCH:
06394       if (sRef_isAnyParam (s->info->arrayfetch->arr)) 
06395         {
06396           result = cstring_makeLiteral ("Out parameter");
06397         }
06398       else if (sRef_isIndexKnown (s))
06399         {
06400           result = cstring_makeLiteral ("Array element");
06401         }
06402       else
06403         {
06404           result = cstring_makeLiteral ("Value");
06405         }
06406       break;
06407     case SK_PTR:
06408       if (sRef_isAnyParam (s->info->ref)) 
06409         {
06410           result = cstring_makeLiteral ("Out parameter");
06411         }
06412       else
06413         {
06414           result = cstring_makeLiteral ("Value");
06415         }
06416       break;
06417     case SK_ADR:
06418       result = cstring_makeLiteral ("Value");
06419       break;
06420     case SK_FIELD:
06421       result = cstring_makeLiteral ("Field");
06422       break;
06423     case SK_OBJECT:
06424       result = cstring_makeLiteral ("Object");
06425       break;
06426     case SK_UNCONSTRAINED:
06427       result = cstring_makeLiteral ("<anything>");
06428       break;
06429     case SK_RESULT:
06430     case SK_SPECIAL:
06431     case SK_UNKNOWN:
06432     case SK_EXTERNAL:
06433     case SK_DERIVED:
06434     case SK_CONST:
06435     case SK_TYPE:
06436       result = cstring_makeLiteral ("<unknown>");
06437       break;
06438     case SK_CONJ:
06439       result = cstring_makeLiteral ("<conj>");
06440       break;
06441     case SK_NEW:
06442       result = cstring_makeLiteral ("Storage");
06443       break;
06444     }
06445   
06446   return result;
06447 }

cstring sRef_unparseKindNamePlain ( sRef s )
 

Definition at line 6450 of file sRef.c.

06451 {
06452   cstring result;
06453 
06454   if (s == sRef_undefined) return cstring_makeLiteral ("<invalid>");
06455 
06456   s = sRef_fixConj (s);
06457 
06458   switch (s->kind)
06459     {
06460     case SK_CVAR: 
06461       if (sRef_isLocalVar (s)) 
06462         {
06463           result = cstring_makeLiteral ("Variable");
06464         }
06465       else 
06466         {
06467           result = cstring_makeLiteral ("Global");
06468         }
06469       break;
06470     case SK_PARAM:
06471       result = cstring_makeLiteral ("Parameter");
06472       break;
06473     case SK_ARRAYFETCH:
06474       if (sRef_isAnyParam (s->info->arrayfetch->arr)) 
06475         {
06476           result = cstring_makeLiteral ("Parameter");
06477         }
06478       else if (sRef_isIndexKnown (s))
06479         {
06480           result = cstring_makeLiteral ("Array element");
06481         }
06482       else 
06483         {
06484           result = cstring_makeLiteral ("Value");
06485         }
06486       break;
06487     case SK_PTR:
06488       if (sRef_isAnyParam (s->info->ref))
06489         {
06490           result = cstring_makeLiteral ("Parameter");
06491         }
06492       else
06493         {
06494           result = cstring_makeLiteral ("Value");
06495         }
06496       break;
06497     case SK_ADR:
06498       result = cstring_makeLiteral ("Value");
06499       break;
06500     case SK_FIELD:
06501       result = cstring_makeLiteral ("Field");
06502       break;
06503     case SK_OBJECT:
06504       result = cstring_makeLiteral ("Object");
06505       break;
06506     case SK_NEW:
06507       result = cstring_makeLiteral ("Storage");
06508       break;
06509     case SK_UNCONSTRAINED:
06510       result = cstring_makeLiteral ("<anything>");
06511       break;
06512     case SK_RESULT:
06513     case SK_TYPE:
06514     case SK_CONST:
06515     case SK_EXTERNAL:
06516     case SK_DERIVED:
06517     case SK_UNKNOWN:
06518     case SK_SPECIAL:
06519       result = cstring_makeLiteral ("<unknown>");
06520       break;
06521     case SK_CONJ:
06522       result = cstring_makeLiteral ("<conj>");
06523       break;
06524     }
06525   
06526   return result;
06527 }

cstring sRef_unparseOpt ( sRef s )
 

Definition at line 2485 of file sRef.c.

Referenced by checkPassTransfer(), sRef_showStateInfo(), and usymtab_checkFinalScope().

02486 {
02487   sRef rb = sRef_getRootBase (s);
02488 
02489   if (sRef_isMeaningful (rb) && !sRef_isConst (rb))
02490     {
02491       cstring ret = sRef_unparse (s);
02492       
02493       llassertprint (!cstring_equalLit (ret, "?"), ("print: %s", sRef_unparseDebug (s)));
02494 
02495       if (!cstring_isEmpty (ret))
02496         {
02497           return (cstring_appendChar (ret, ' '));
02498         }
02499       else
02500         {
02501           return ret;
02502         }
02503     }
02504 
02505   return cstring_undefined;
02506 }

cstring sRef_unparsePreOpt ( sRef s )
 

Definition at line 2509 of file sRef.c.

Referenced by exprNode_arrowAccess().

02510 {
02511   sRef rb = sRef_getRootBase (s);
02512 
02513   if (sRef_isMeaningful (rb) && !sRef_isConst (rb))
02514     {
02515       cstring ret = sRef_unparse (s);
02516       
02517       llassertprint (!cstring_equalLit (ret, "?"), ("print: %s", sRef_unparseDebug (s)));
02518       return (cstring_prependCharO (' ', ret));
02519     }
02520 
02521   return cstring_undefined;
02522 }

cstring sRef_unparseScope ( sRef s )
 

Definition at line 7262 of file sRef.c.

07263 {
07264   sRef base = sRef_getRootBase (s);
07265 
07266   if (sRef_isRealGlobal (base))
07267     {
07268       return (cstring_makeLiteralTemp ("global"));
07269     }
07270   else if (sRef_isFileStatic (base))
07271     {
07272       return (cstring_makeLiteralTemp ("file static"));
07273     }
07274   else
07275     {
07276       BADEXIT;
07277     }
07278 }

cstring sRef_unparseState ( sRef s )
 

Definition at line 4197 of file sRef.c.

Referenced by sRef_unparseFull(), and uentry_unparseFull().

04198 {
04199   if (sRef_isConj (s))
04200     {
04201       return (message ("%q | %q", 
04202                        sRef_unparseState (s->info->conj->a),
04203                        sRef_unparseState (s->info->conj->b)));
04204     }
04205 
04206   if (sRef_isInvalid (s))
04207     {
04208       return (cstring_makeLiteral ("<invalid>"));
04209     }
04210 
04211   return (message ("%s.%s.%s.%s", 
04212                    alkind_unparse (s->aliaskind), 
04213                    nstate_unparse (s->nullstate),
04214                    exkind_unparse (s->expkind),
04215                    sstate_unparse (s->defstate)));
04216 }

sRef sRef_updateSref ( sRef s )
 

Definition at line 740 of file sRef.c.

Referenced by sRef_aliasCheckSimplePred(), sRef_aliasCompleteSimplePred(), usymtab_checkFinalScope(), and usymtab_enterFunctionScope().

00741 {
00742   sRef inner;
00743   sRef ret;
00744   sRef res;
00745 
00746   if (!sRef_isValid (s)) return sRef_undefined;
00747 
00748   
00749   switch (s->kind)
00750     {
00751     case SK_UNKNOWN:
00752     case SK_OBJECT:
00753     case SK_NEW:
00754     case SK_TYPE:
00755     case SK_EXTERNAL:
00756     case SK_DERIVED:
00757     case SK_UNCONSTRAINED:
00758     case SK_CONST:
00759     case SK_SPECIAL:
00760     case SK_RESULT:
00761       return s; 
00762     case SK_PARAM:
00763     case SK_CVAR:
00764       {
00765         uentry ue = sRef_getUentry (s);
00766 
00767         /* must be raw name!  (need the marker) */
00768         ue = usymtab_lookupSafe (uentry_rawName (ue));
00769         
00770         if (uentry_isUndefined (ue))
00771           {
00772                     return s;
00773           }
00774         else
00775           {
00776                     return (uentry_getSref (ue));
00777           }
00778       }
00779     case SK_ARRAYFETCH:
00780       /* special case if ind known */
00781       inner = s->info->arrayfetch->arr;
00782       ret = sRef_updateSref (inner);
00783 
00784       if (ret == inner) 
00785         {
00786           res = s; 
00787         }
00788       else 
00789         {
00790           res = sRef_makeArrayFetch (ret);
00791         }
00792 
00793       return res;
00794 
00795     case SK_FIELD:
00796       inner = s->info->field->rec;
00797       ret = sRef_updateSref (inner);
00798 
00799       if (ret == inner) 
00800         {
00801           res = s; 
00802         }
00803       else 
00804         {
00805           res = (sRef_makeField (ret, s->info->field->field));
00806         }
00807 
00808       return (res);
00809     case SK_PTR:
00810       inner = s->info->ref;
00811       ret = sRef_updateSref (inner);
00812       if (ret == inner) 
00813         {
00814           res = s; 
00815         }
00816       else
00817         {
00818           res = sRef_makePointer (ret);
00819         }
00820 
00821       return (res);
00822 
00823     case SK_ADR:
00824       inner = s->info->ref;
00825       ret = sRef_updateSref (inner);
00826 
00827       if (ret == inner)
00828         {
00829           res = s; 
00830         }
00831       else 
00832         {
00833           res = sRef_makeAddress (ret);
00834         }
00835 
00836       return (res);
00837 
00838     case SK_CONJ:
00839       {
00840         sRef innera = s->info->conj->a;
00841         sRef innerb = s->info->conj->b;
00842         sRef reta = sRef_updateSref (innera);
00843         sRef retb = sRef_updateSref (innerb);
00844 
00845         if (innera == reta && innerb == retb)
00846           {
00847             res = s;
00848           }
00849         else 
00850           {
00851             res = sRef_makeConj (reta, retb);
00852           }
00853 
00854         return (res);
00855       }
00856     }
00857   
00858   BADEXIT;
00859 }


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