#include "lclintMacros.nf"#include "basic.h"#include "structNames.h"#include "exprChecks.h"#include "aliasChecks.h"Go to the source code of this file.
|
|
Definition at line 3827 of file usymtab.c. Referenced by uentry_setUsed(). 03828 {
03829 if (uentry_isVar (ue))
03830 {
03831 sRef sr = uentry_getSref (ue);
03832
03833 if (sRef_lexLevel (sr) == functionScope)
03834 {
03835 /*@access sRef@*/ /*@-null@*/
03836 int index = sr->info->cvar->index;
03837 /*@noaccess sRef@*/ /*@=null@*/
03838
03839 if (index < uentryList_size (context_getParams ()))
03840 {
03841 return index;
03842 }
03843 }
03844 }
03845 return -1;
03846 }
|
|
|
Definition at line 580 of file usymtab.c. Referenced by o_fctInfo(). 00583 {
00584
00585 llassertprint (!usymtab_exists (uentry_rawName (e)),
00586 ("Entry already exists: %s", uentry_unparse (e)));
00587
00588 return usymtab_addEntryAux (utab, e, FALSE);
00589 }
|
|
|
Definition at line 4943 of file usymtab.c. Referenced by exprNode_cast(). 04945 {
04946 if (sRef_isMeaningful (s)
04947 && sRef_isMeaningful (al)
04948 && !(sRef_isConst (s) || sRef_isConst (al))
04949 && !(sRef_isAddress (al) && sRef_isDirectParam (sRef_getBase (al))))
04950 {
04951 utab->aliases = aliasTable_addMustAlias (utab->aliases, s, al);
04952 DPRINTF (("Must alias: %s", aliasTable_unparse (utab->aliases)));
04953
04954 /*
04955 ** for local variable, aliasing is symmetric
04956 */
04957
04958 if (sRef_isLocalVar (s) && sRef_isLocalVar (al))
04959 {
04960 utab->aliases = aliasTable_addMustAlias (utab->aliases, al, s);
04961 }
04962 }
04963 else
04964 {
04965 ;
04966 }
04967 }
|
|
|
Definition at line 592 of file usymtab.c. 00594 {
00595 DPRINTF (("Add global: %s / %s", uentry_unparse (e), bool_unparse (uentry_isForward (e))));
00596
00597 (void) usymtab_addEntryAux (globtab, e, FALSE);
00598 }
|
|
|
Definition at line 4688 of file usymtab.c. Referenced by context_exitDoWhileClause(), context_exitForClause(), and context_exitWhileClause(). 04690 {
04691 utab->guards = guardSet_union (utab->guards, guards);
04692 }
|
|
|
Definition at line 4913 of file usymtab.c. 04915 {
04916 if (sRef_isMeaningful (s) && sRef_isMeaningful (al)
04917 && !(sRef_isConst (s) || sRef_isConst (al))
04918 && !(sRef_isAddress (al) && sRef_isDirectParam (sRef_getBase (al)))
04919 && !(sRef_similar (s, al)))
04920 {
04921 utab->aliases = aliasTable_addMustAlias (utab->aliases, s, al);
04922 DPRINTF (("Must alias: %s", aliasTable_unparse (utab->aliases)));
04923
04924 /*
04925 ** for local variable, aliasing is symmetric
04926 */
04927
04928 if (sRef_isLocalVar (s) && sRef_isLocalVar (al))
04929 {
04930 utab->aliases = aliasTable_addMustAlias (utab->aliases, al, s);
04931 }
04932 }
04933 else
04934 {
04935 ;
04936 }
04937 }
|
|
|
Definition at line 5007 of file usymtab.c. Referenced by canLoseReference(), and usymtab_checkFinalScope(). 05009 {
05010 return (aliasTable_aliasedBy (utab->aliases, s));
05011 }
|
|
|
Definition at line 4976 of file usymtab.c. Referenced by sRef_aliasCheckPred(), sRef_aliasCheckSimplePred(), sRef_aliasCompleteSimplePred(), and usymtab_checkFinalScope(). 04978 {
04979 if (sRef_isMeaningful (s))
04980 {
04981 sRefSet ret;
04982
04983
04984 ret = sRefSet_unionFree (aliasTable_aliasedBy (utab->aliases, s),
04985 aliasTable_canAlias (utab->aliases, s));
04986 return (ret);
04987 }
04988 else
04989 {
04990 return sRefSet_undefined;
04991 }
04992 }
|
|
|
Definition at line 2716 of file usymtab.c. Referenced by main(). 02718 {
02719 int i;
02720
02721 llassert (utab == globtab);
02722
02723 for (i = 0; i < utab->nentries; i++)
02724 {
02725 uentry e = utab->entries[i];
02726
02727 if (uentry_isPriv (e))
02728 {
02729 ; /* no need to define it */
02730 }
02731 else
02732 {
02733 if (context_getFlag (FLG_SPECUNDECL))
02734 {
02735 fileloc sloc = uentry_whereSpecified (e);
02736 fileloc dloc = uentry_whereDeclared (e);
02737
02738 if (fileloc_isDefined (sloc)
02739 && !uentry_isFakeTag (e)
02740 && !fileloc_isDefined (dloc))
02741 {
02742 voptgenerror
02743 (FLG_SPECUNDECL,
02744 message ("%s %q specified but not declared",
02745 ekind_capName (uentry_getKind (e)),
02746 uentry_getName (e)),
02747 sloc);
02748 }
02749 }
02750
02751 if (!uentry_isCodeDefined (e))
02752 {
02753 fileloc dloc = uentry_whereDeclared (e);
02754
02755 if (fileloc_isLib (dloc))
02756 {
02757 ;
02758 }
02759 else if (fileloc_isDefined (dloc))
02760 {
02761 if (!uentry_isAnyTag (e))
02762 {
02763 if (fileloc_isUser (dloc))
02764 {
02765 voptgenerror
02766 (FLG_DECLUNDEF,
02767 message ("%s %q declared but not defined",
02768 ekind_capName (uentry_getKind (e)),
02769 uentry_getName (e)),
02770 dloc);
02771 }
02772 }
02773 }
02774 else
02775 {
02776 fileloc sloc = uentry_whereSpecified (e);
02777
02778 if (fileloc_isDefined (sloc)
02779 && !fileloc_isImport (sloc)
02780 && !fileloc_isLib (sloc)
02781 && !fileloc_isPreproc (sloc)
02782 && !uentry_isFakeTag (e))
02783 {
02784 if (uentry_isVariable (e) || uentry_isFunction (e))
02785 {
02786 voptgenerror
02787 (FLG_SPECUNDEF,
02788 message ("%s %q specified but not declared or defined",
02789 ekind_capName (uentry_getKind (e)),
02790 uentry_getName (e)),
02791 sloc);
02792 }
02793 else
02794 {
02795 voptgenerror
02796 (FLG_SPECUNDEF,
02797 message ("%s %q specified but not defined",
02798 ekind_capName (uentry_getKind (e)),
02799 uentry_getName (e)),
02800 sloc);
02801 }
02802 }
02803 }
02804 }
02805 }
02806 }
02807 }
|
|
|
Definition at line 2939 of file usymtab.c. Referenced by main(), and usymtab_exitScope(). 02941 {
02942 int i;
02943 bool isFileStatic = usymtab_inFileScope ();
02944 cstring last_file = cstring_undefined;
02945
02946 for (i = 0; i < utab->nentries; i++)
02947 {
02948 bool hasError = FALSE;
02949 uentry ce = utab->entries[i];
02950 fileloc fwhere = uentry_whereDeclared (ce);
02951
02952 if (fileloc_isUndefined (fwhere))
02953 {
02954 fwhere = uentry_whereDefined (ce);
02955 }
02956
02957 if (fileloc_isInvalid (fwhere)
02958 || fileloc_isLib (fwhere)
02959 || fileloc_isBuiltin (fwhere)
02960 || ((fileloc_isSpecialFile (fwhere)
02961 || fileloc_isSpecialFile (uentry_whereDefined (ce)))
02962 && !context_getFlag (FLG_UNUSEDSPECIAL)))
02963 {
02964 ;
02965 }
02966 else if (!uentry_wasUsed (ce) && !uentry_isAnyTag (ce))
02967 {
02968 cstring fname = fileloc_filename (fwhere);
02969
02970 if (cstring_isUndefined (last_file))
02971 {
02972 last_file = fname;
02973 }
02974 else if (cstring_equal (fname, last_file))
02975 {
02976 }
02977 else
02978 {
02979 cleanupMessages ();
02980 last_file = fname;
02981 }
02982
02983 if (uentry_isParam (ce))
02984 {
02985 if (context_inMacro ())
02986 {
02987 sRef cref = uentry_getSref (ce);
02988
02989 if (uentry_isYield (ce))
02990 {
02991 ; /* no checks (for now) */
02992 }
02993 else if (sRef_isSafe (cref))
02994 {
02995 ; /* no error */
02996 }
02997 else
02998 {
02999 if (uentry_hasRealName (ce))
03000 {
03001 hasError =
03002 optgenerror (FLG_MACROPARAMS,
03003 message ("Macro parameter %q not used",
03004 uentry_getName (ce)),
03005 fwhere);
03006 }
03007 }
03008 }
03009 else
03010 {
03011 if (cstring_equalFree (uentry_getName (ce),
03012 cstring_makeLiteral ("...")))
03013 {
03014 ;
03015 }
03016 else
03017 {
03018 hasError = optgenerror (FLG_PARAMUNUSED,
03019 message ("Parameter %q not used",
03020 uentry_getName (ce)),
03021 fwhere);
03022 }
03023 }
03024 } /* isParam */
03025 else if (uentry_isFunction (ce) || uentry_isIter (ce))
03026 {
03027 if (fileloc_isUser (fwhere))
03028 {
03029 hasError = optgenerror
03030 (FLG_FUNCUNUSED,
03031 message ("%q %q declared but not used",
03032 cstring_makeLiteral
03033 (uentry_isIter (ce) ? "Iterator"
03034 : (isFileStatic ? "File static function" : "Function")),
03035 uentry_getName (ce)),
03036 fwhere);
03037 }
03038 }
03039 else if (uentry_isEndIter (ce))
03040 {
03041 ; /* no error (already reported for iter */
03042 }
03043 else if (uentry_isEnumConstant (ce))
03044 {
03045 if (fileloc_isUser (fwhere))
03046 {
03047 hasError = optgenerror
03048 (FLG_ENUMMEMUNUSED,
03049 message ("Enum member %q not used",
03050 uentry_getName (ce)),
03051 fwhere);
03052 }
03053 }
03054 else if (uentry_isConstant (ce))
03055 {
03056 if (fileloc_isUser (fwhere))
03057 {
03058 hasError = optgenerror
03059 (FLG_CONSTUNUSED,
03060 message ("Constant %q declared but not used",
03061 uentry_getName (ce)),
03062 fwhere);
03063 }
03064 }
03065 else if (uentry_isDatatype (ce))
03066 {
03067 if (fileloc_isUser (fwhere))
03068 {
03069 hasError = optgenerror
03070 (FLG_TYPEUNUSED,
03071 message ("Type %q declared but not used",
03072 uentry_getName (ce)),
03073 fwhere);
03074 }
03075 }
03076 else if (!uentry_isRefParam (ce) && !uentry_isExpandedMacro (ce))
03077 { /* errors for ref params will be reported in the next scope */
03078 llassertprint (uentry_isVar (ce),
03079 ("ce: %s", uentry_unparseFull (ce)));
03080
03081 if (ctype_isFunction (uentry_getType (ce)))
03082 {
03083 if (fileloc_isUser (fwhere))
03084 {
03085 hasError = optgenerror
03086 (FLG_FUNCUNUSED,
03087 message ("%q %q declared but not used",
03088 cstring_makeLiteral
03089 (isFileStatic ? "File static function"
03090 : "Function"),
03091 uentry_getName (ce)),
03092 fwhere);
03093 }
03094 }
03095 else
03096 {
03097 if (fileloc_isUser (fwhere))
03098 {
03099
03100
03101 hasError = optgenerror
03102 (FLG_VARUNUSED,
03103 message ("%q %q declared but not used",
03104 cstring_makeLiteral
03105 (isFileStatic ? "File static variable"
03106 : "Variable"),
03107 uentry_getName (ce)),
03108 fwhere);
03109 }
03110 }
03111 }
03112 else
03113 {
03114 ; /* no errors */
03115 }
03116 } /* unused */
03117 else if (uentry_isDatatype (ce) || uentry_isAnyTag (ce))
03118 { /* check all fields */
03119 ctype ct = uentry_getRealType (ce);
03120
03121
03122 while (ctype_isAP (ct))
03123 {
03124 ct = ctype_getBaseType (ct);
03125 }
03126
03127
03128 if (ctype_isSU (ct))
03129 {
03130 uentryList fields = ctype_getFields (ct);
03131
03132 uentryList_elements (fields, field)
03133 {
03134 if (!uentry_isUsed (field))
03135 {
03136 if (uentry_hasName (ce))
03137 {
03138 hasError |= optgenerror
03139 (FLG_FIELDUNUSED,
03140 message ("Field %q of %s %q declared but not used",
03141 uentry_getName (field),
03142 cstring_makeLiteralTemp
03143 (ctype_isStruct (ct) ? "structure" : "union"),
03144 uentry_getName (ce)),
03145 uentry_whereEarliest (field));
03146 }
03147 else
03148 {
03149 hasError |= optgenerror
03150 (FLG_FIELDUNUSED,
03151 message ("Field %q of unnamed %s declared but not used",
03152 uentry_getName (field),
03153 cstring_makeLiteralTemp
03154 (ctype_isStruct (ct) ? "structure" : "union")),
03155 uentry_whereEarliest (field));
03156 }
03157
03158 uentry_setUsed (field, fileloc_undefined);
03159 }
03160 } end_uentryList_elements;
03161 }
03162 }
03163 else
03164 {
03165 ; /* no errors */
03166 }
03167
03168 if (hasError)
03169 {
03170 if (uentry_isParam (ce) && context_inMacro ())
03171 {
03172 if (fileloc_isDefined (uentry_whereSpecified (ce)))
03173 {
03174 uentry_showWhereSpecified (ce);
03175 }
03176 }
03177 else
03178 {
03179 uentry_showDefSpecInfo (ce, fwhere);
03180 }
03181
03182 uentry_setUsed (ce, fileloc_undefined);
03183 }
03184 }
03185 }
|
|
|
Definition at line 2689 of file usymtab.c. Referenced by usymtab_popTrueBranch(), and usymtab_popTrueExecBranch(). 02691 {
02692 usymtab t = usymtab_create (US_FBRANCH, utab, FALSE);
02693 usymtab parent = utab->env;
02694
02695 /*
02696 ** If we are in a case, need to close it. The C syntax
02697 ** is very liberal, so this kludge is necessary.
02698 */
02699
02700 usymtab_fixCases ();
02701
02702 DPRINTF (("Current kind: %s", usymtab_unparseStack ()));
02703 llassert (utab->kind == US_TBRANCH);
02704 llassert (parent != GLOBAL_ENV);
02705
02706 guardSet_free (t->guards);
02707 t->guards = guards;
02708
02709 aliasTable_free (t->aliases);
02710 t->aliases = aliasTable_copy (parent->aliases);
02711
02712 utab = t;
02713 }
|
|
|
Definition at line 4994 of file usymtab.c. 04996 {
04997 if (sRef_isMeaningful (s))
04998 {
04999 sRefSet res = aliasTable_canAlias (utab->aliases, s);
05000
05001 return res;
05002 }
05003
05004 return sRefSet_undefined;
05005 }
|
|
|
Definition at line 5567 of file usymtab.c. Referenced by uentry_checkName(). 05569 {
05570 bool hasError = FALSE;
05571 fileloc where = uentry_whereLast (e);
05572
05573 if (!fileloc_isPreproc (where) && !fileloc_isBuiltin (where))
05574 {
05575 if (scope == globScope)
05576 {
05577 if (context_getFlag (FLG_DISTINCTEXTERNALNAMES))
05578 {
05579 hasError = checkDistinctExternalName (e);
05580 }
05581 }
05582
05583 if (!hasError && context_getFlag (FLG_DISTINCTINTERNALNAMES))
05584 {
05585 hasError = checkDistinctInternalName (e);
05586 }
05587 }
05588
05589 if (hasError)
05590 {
05591 uentry_setHasNameError (e);
05592 }
05593 }
|
|
|
Definition at line 3283 of file usymtab.c. Referenced by context_returnFunction(), exprChecks_checkEmptyMacroBody(), exprNode_checkMacroBody(), and usymtab_exitScope(). 03285 {
03286 bool mustFree = context_getFlag (FLG_MUSTFREE);
03287 bool mustDefine = context_getFlag (FLG_MUSTDEFINE);
03288 /* bool mustNotAlias = context_getFlag (FLG_MUSTNOTALIAS); */
03289 sRefSet checked = sRefSet_new ();
03290 usymtab stab = utab;
03291 int i;
03292
03293 /*
03294 ** need to check all scopes out to function parameters.
03295 */
03296
03297 do
03298 {
03299 for (i = 0; i < stab->nentries; i++)
03300 {
03301 uentry ce = stab->entries[i];
03302 sRef sr = uentry_getSref (ce);
03303 sRef rb = sRef_getRootBase (sr);
03304
03305 if (ctype_isFunction (uentry_getType (ce)))
03306 {
03307 /*@innercontinue@*/ continue;
03308 }
03309
03310 if (mustFree)
03311 {
03312 DPRINTF (("Check entry: %s", uentry_unparseFull (ce)));
03313
03314 if (!sRefSet_member (checked, sr) && !sRef_isGlobal (rb))
03315 {
03316 if (ctype_isRealSU (uentry_getType (ce))
03317 && !uentry_isAnyParam (ce)
03318 && !uentry_isRefParam (ce)
03319 && !uentry_isStatic (ce)
03320 && !sRef_isDependent (sr)
03321 && !sRef_isOwned (sr))
03322 {
03323 sRefSet als = usymtab_allAliases (sr);
03324
03325
03326 if (sRefSet_isEmpty (als))
03327 {
03328 checkLocalDestroyed (sr, g_currentloc);
03329 }
03330 else
03331 {
03332 /* aliased, no problem */ ;
03333 }
03334
03335 sRefSet_free (als);
03336 }
03337 else if
03338 (!uentry_isStatic (ce)
03339 && ((sRef_isNewRef (sr))
03340 || (((sRef_isOnly (sr) || sRef_isFresh (sr)
03341 || sRef_isKeep (sr) || sRef_isOwned (sr))
03342 && !sRef_isDead (sr))
03343 && (!sRef_definitelyNull (sr))
03344 && (!usymtab_isProbableNull (sr)))))
03345 {
03346 bool hasError = TRUE;
03347
03348 /*
03349 ** If its a scope exit, check if there is an alias.
03350 ** If so, make it only. If not, there is an error.
03351 */
03352
03353 if (!isReturn)
03354 {
03355 if (canLoseReference (sr, g_currentloc))
03356 {
03357 hasError = FALSE;
03358 }
03359 }
03360
03361 if (hasError)
03362 {
03363 if (sRef_hasLastReference (sr))
03364 {
03365 sRef ar = sRef_getAliasInfoRef (sr);
03366
03367 if (optgenerror
03368 (FLG_MUSTFREE,
03369 message
03370 ("Last reference %q to %s storage %qnot %q before %q",
03371 sRef_unparse (sr),
03372 alkind_unparse (sRef_getAliasKind (sr)),
03373 sRef_unparseOpt (ar),
03374 cstring_makeLiteral (sRef_isKeep (sr)
03375 ? "transferred" : "released"),
03376 cstring_makeLiteral (isReturn
03377 ? "return" : "scope exit")),
03378 g_currentloc))
03379 {
03380 sRef_showRefLost (sr);
03381 }
03382 }
03383 else if (sRef_isNewRef (sr))
03384 {
03385 if (optgenerror
03386 (FLG_MUSTFREE,
03387 message
03388 ("%q %q not released before %q",
03389 cstring_makeLiteral
03390 (alkind_isKillRef (sRef_getOrigAliasKind (sr))
03391 ? "Kill reference parameter" : "New reference"),
03392 uentry_getName (ce),
03393 cstring_makeLiteral (isReturn
03394 ? "return" : "scope exit")),
03395 g_currentloc))
03396 {
03397 sRef_showAliasInfo (sr);
03398 }
03399 }
03400 else
03401 {
03402 if (ctype_isRealSU (sRef_getType (sr)))
03403 {
03404 checkStructDestroyed (sr, g_currentloc);
03405 }
03406 else
03407 {
03408 if (optgenerror
03409 (FLG_MUSTFREE,
03410 message
03411 ("%s storage %q not %q before %q",
03412 alkind_capName (sRef_getAliasKind (sr)),
03413 uentry_getName (ce),
03414 cstring_makeLiteral (sRef_isKeep (sr)
03415 ? "transferred" : "released"),
03416 cstring_makeLiteral (isReturn
03417 ? "return" : "scope exit")),
03418 g_currentloc))
03419 {
03420 sRef_showAliasInfo (sr);
03421 }
03422 }
03423 }
03424 }
03425 }
03426 else
03427 {
03428 ;
03429 }
03430 }
03431 else if (mustDefine && uentry_isOut (ce))
03432 {
03433 if (!ynm_toBoolStrict (sRef_isReadable (sr)))
03434 {
03435 voptgenerror
03436 (FLG_MUSTDEFINE,
03437 message ("Out storage %q not defined before %q",
03438 uentry_getName (ce),
03439 cstring_makeLiteral
03440 (isReturn ? "return" : "scope exit")),
03441 g_currentloc);
03442
03443 /* uentry_showWhereDeclared (ce); */
03444 }
03445 }
03446 else
03447 {
03448 ;
03449 }
03450
03451 /*
03452 ** also check state is okay
03453 */
03454
03455 if (usymtab_lexicalLevel () > functionScope
03456 && uentry_isVariable (ce)
03457 && (sRef_isLocalVar (sr)
03458 && (sRef_isDependent (sr) || sRef_isLocalState (sr))))
03459 {
03460 sRefSet ab = usymtab_aliasedBy (sr);
03461
03462 /* should do something more efficient here */
03463
03464 if (sRefSet_isEmpty (ab))
03465 {
03466 /* and no local ref */
03467 checkLoseRef (ce);
03468 }
03469 else
03470 {
03471 ;
03472 }
03473
03474 sRefSet_free (ab);
03475 }
03476 else
03477 {
03478 ;
03479 }
03480
03481 checked = sRefSet_insert (checked, sr);
03482 }
03483 }
03484 llassert (usymtab_isDefined (stab->env));
03485
03486 if (usymtab_isBranch (stab))
03487 {
03488 stab = usymtab_dropEnv (stab);
03489 }
03490 else
03491 {
03492 stab = stab->env;
03493 }
03494
03495 llassert (stab != usymtab_undefined);
03496 } while (isReturn && (stab->lexlevel >= paramsScope));
03497
03498 sRefSet_free (checked);
03499
03500 /*
03501 ** for returns:
03502 ** all globals are appropriately defined
03503 ** all parameters are appropriately defined
03504 ** special clauses are followed
03505 */
03506
03507 if (isReturn || (utab->lexlevel == paramsScope))
03508 {
03509 uentry fcn = context_getHeader ();
03510 uentryList params = context_getParams ();
03511 globSet uglobs = context_getUsedGlobs ();
03512 globSet sglobs = context_getGlobs ();
03513
03514
03515 if (isReturn && context_maybeSet (FLG_GLOBALIAS))
03516 {
03517 aliasTable_checkGlobs (utab->aliases);
03518 }
03519
03520 /*
03521 ** special clauses (defines, sets, allocates, releases)
03522 */
03523
03524 if (uentry_hasSpecialClauses (fcn))
03525 {
03526 specialClauses clauses = uentry_getSpecialClauses (fcn);
03527
03528 specialClauses_elements (clauses, cl)
03529 {
03530 if (specialClause_isAfter (cl))
03531 { /* evs - 2000 07 10 - added this */
03532 sRefTest tst = specialClause_getPostTestFunction (cl);
03533 sRefSet rfs = specialClause_getRefs (cl);
03534
03535 sRefSet_elements (rfs, el)
03536 {
03537 sRef base = sRef_getRootBase (el);
03538
03539 if (sRef_isResult (base))
03540 {
03541 ;
03542 }
03543 else if (sRef_isParam (base))
03544 {
03545 sRef sr = sRef_updateSref (base);
03546 sr = sRef_fixBase (el, sr);
03547
03548 if (tst != NULL && !tst (sr))
03549 {
03550 if (optgenerror
03551 (specialClause_postErrorCode (cl),
03552 message ("%s storage %qcorresponds to "
03553 "storage listed in %q clause",
03554 specialClause_postErrorString (cl, sr),
03555 sRef_unparseOpt (sr),
03556 specialClause_unparseKind (cl)),
03557 g_currentloc))
03558 {
03559 sRefShower ss = specialClause_getPostTestShower (cl);
03560
03561 if (ss != NULL)
03562 {
03563 ss (sr);
03564 }
03565 }
03566 }
03567 }
03568 else
03569 {
03570 if (sRef_isMeaningful (el))
03571 {
03572 BADBRANCH;
03573 }
03574 }
03575 } end_sRefSet_elements ;
03576 }
03577 } end_specialClauses_elements ;
03578 }
03579
03580 /*
03581 ** check parameters on return
03582 */
03583
03584 uentryList_elements (params, arg)
03585 {
03586 if (!uentry_isElipsisMarker (arg))
03587 {
03588 ctype rt = ctype_realType (uentry_getType (arg));
03589
03590 if (ctype_isMutable (rt) || ctype_isSU (rt))
03591 {
03592 uentry param = usymtab_lookupQuiet (utab, uentry_rawName (arg));
03593 checkParamReturn (param);
03594 }
03595 }
03596 } end_uentryList_elements;
03597
03598 globSet_allElements (sglobs, el)
03599 {
03600 uentry current = sRef_getUentry (el);
03601
03602 if (uentry_isVariable (current) && !uentry_isRealFunction (current))
03603 {
03604 checkGlobalReturn (current, el);
03605 }
03606 } end_globSet_allElements;
03607
03608 globSet_allElements (uglobs, el)
03609 {
03610 if (!globSet_member (sglobs, el))
03611 {
03612 uentry current = sRef_getUentry (el);
03613
03614
03615 if (uentry_isVariable (current)
03616 && !uentry_isRealFunction (current))
03617 {
03618 checkGlobalReturn (current, sRef_undefined);
03619 }
03620 }
03621 } end_globSet_allElements;
03622 }
03623
03624 }
|
|
|
Definition at line 4969 of file usymtab.c. Referenced by checkPassTransfer(). 04971 {
04972
04973 aliasTable_clearAliases (utab->aliases, s);
04974 }
|
|
|
Definition at line 1465 of file usymtab.c. Referenced by ctype_dump(), and usymIdSet_dump(). 01467 {
01468 uentry ue;
01469 usymId ret;
01470 cstring name;
01471
01472 llassert (usymtab_isDefined (oldtab));
01473
01474 ue = usymtab_getEntryAux (oldtab, uid);
01475
01476 llassertprint (uentry_isValid (ue), ("convertId: undefined: %d", uid));
01477
01478 name = uentry_rawName (ue);
01479
01480 ret = usymtab_getIndex (utab, name);
01481
01482 llassertprint (ret != USYMIDINVALID, ("convertId: return is invalid"));
01483
01484 return (ret);
01485 }
|
|
|
Definition at line 4821 of file usymtab.c. Referenced by main(). 04823 {
04824 usymtab copy;
04825
04826 /* only in top scope */
04827 llassert (utab == globtab);
04828
04829 /* need a copy, so order is not messed up by sort! */
04830 copy = usymtab_shallowCopy (globtab);
04831
04832 qsort (copy->entries, (size_t)copy->nentries,
04833 sizeof (*copy->entries), (int (*)(const void *, const void *)) uentry_xcompareuses);
04834
04835 usymtab_entries (copy, ue)
04836 {
04837 if (uentry_isValid (ue))
04838 {
04839 filelocList uses = uentry_getUses (ue);
04840 int size = filelocList_realSize (uses);
04841
04842 if (fileloc_isDefined (uentry_whereDefined (ue))
04843 && !fileloc_isLib (uentry_whereDefined (ue))
04844 && (size > 0))
04845 {
04846 llmsg (message ("%q (%q), %d use%p:\n %q",
04847 uentry_getName (ue),
04848 fileloc_unparse (uentry_whereDefined (ue)),
04849 size, filelocList_unparseUses (uses)));
04850 }
04851 }
04852 } end_usymtab_entries;
04853
04854 usymtab_shallowFree (copy);
04855 }
|
|
|
Definition at line 1510 of file usymtab.c. Referenced by dumpState(). 01512 {
01513 int i;
01514 bool neednl = FALSE;
01515 uentry lastentry = uentry_undefined;
01516 ekind lastekind = KINVALID;
01517 int linelen = 0;
01518
01519 /*
01520 ** must call prepareDump first
01521 */
01522
01523 llassert (oldtab != usymtab_undefined);
01524
01525 for (i = 0; i < utab->nentries; i++)
01526 {
01527 uentry thisentry = utab->entries[i];
01528 ekind thisekind = uentry_getKind (thisentry);
01529
01530
01531 if (uentry_hasRealName (thisentry)) {
01532 if (thisekind != lastekind)
01533 {
01534 if (neednl)
01535 {
01536 check (fputc ('\n', fout) == (int) '\n');
01537 }
01538
01539 neednl = FALSE;
01540 lastentry = uentry_undefined;
01541 fprintf (fout, "*%d (%s)\n", ekind_toInt (thisekind),
01542 cstring_toCharsSafe (ekind_capName (thisekind)));
01543 lastekind = thisekind;
01544 linelen = 0;
01545 }
01546
01547 if (uentry_isInvalid (lastentry) || !uentry_equiv (lastentry, thisentry)
01548 || (linelen > (MAX_DUMP_LINE_LENGTH - (2 * MAX_NAME_LENGTH))))
01549 {
01550 cstring cdump = uentry_dump (thisentry);
01551
01552 lastentry = thisentry;
01553 if (neednl)
01554 {
01555 check (fputc ('\n', fout) == (int) '\n');
01556 linelen = 0;
01557 }
01558
01559 linelen += cstring_length (cdump);
01560
01561 /* no new line here! */
01562 if (cstring_length (cdump) > 0)
01563 {
01564 check (fputs (cstring_toCharsSafe (cdump), fout) != EOF);
01565 }
01566
01567 cstring_free (cdump);
01568 neednl = TRUE;
01569 }
01570 else
01571 {
01572 cstring cdump = uentry_rawName (thisentry);
01573 linelen += cstring_length (cdump);
01574 fprintf (fout, "#%s", cstring_toCharsSafe (cdump));
01575 }
01576 }
01577 }
01578
01579 if (neednl)
01580 {
01581 check (fputc ('\n', fout) == (int) '\n');
01582 }
01583 }
|
|
|
Definition at line 1672 of file usymtab.c. Referenced by context_enterFile(), and context_processAllMacros(). 01675 {
01676 llassert (utab == globtab);
01677
01678 # if 0
01679 /* check globals */
01680
01681 usymtab_entries (globtab, ue)
01682 {
01683 if (sRef_hasDerived (uentry_getSref (ue)))
01684 {
01685 fprintf (g_msgstream, "Derived Global: %s\n", uentry_unparse (ue));
01686 fprintf (g_msgstream, "sRef: %s\n", sRef_unparseFull (ue->sref));
01687 }
01688 } end_usymtab_entries ;
01689
01690 # endif
01691
01692 usymtab_enterScope ();
01693 filetab = utab;
01694 }
|
|
|
Definition at line 1894 of file usymtab.c. Referenced by context_enterFunction(). 01897 {
01898 usymtab t = usymtab_create (US_NORMAL, utab, TRUE);
01899
01900 if (utab->lexlevel != fileScope)
01901 {
01902 if (utab->lexlevel > fileScope)
01903 {
01904 llparseerror (cstring_makeLiteral ("New function scope inside function."));
01905
01906 while (utab->lexlevel > fileScope)
01907 {
01908 /*@i@*/ utab = usymtab_dropEnv (utab);
01909 /*@-branchstate@*/
01910 }
01911 /*@=branchstate@*/
01912 }
01913 else
01914 {
01915 llfatalbug (cstring_makeLiteral ("New function not inside file."));
01916 }
01917 /*@-branchstate@*/ } /*@=branchstate@*/
01918
01919 globSet_allElements (uentry_getGlobs (fcn), el)
01920 {
01921
01922 if (sRef_isUndefGlob (el))
01923 {
01924 int index = sRef_getScopeIndex (el);
01925 sRef sr = sRef_updateSref (el);
01926 fileloc loc = uentry_whereEarliest (fcn);
01927
01928 if (sRef_isFileStatic (el))
01929 {
01930 ctype ct = sRef_getType (el);
01931 uentry ue;
01932
01933 llassert (usymtab_isDefined (filetab));
01934
01935 ue = usymtab_fetchIndex (filetab, index);
01936
01937 if (ctype_isRealArray (ct) || ctype_isRealSU (ct))
01938 {
01939 sRef_setAllocated (sr, loc);
01940 }
01941 else
01942 {
01943 sRef_setUndefined (sr, loc);
01944 }
01945 }
01946 else
01947 {
01948 uentry ue = globtab->entries[index];
01949 ctype ct = uentry_getType (ue);
01950
01951 if (ctype_isArray (ct) || ctype_isSU (ct))
01952 {
01953 sRef_setAllocated (sr, loc);
01954 }
01955 else
01956 {
01957 sRef_setUndefined (sr, loc);
01958 }
01959 }
01960 }
01961 else if (sRef_isAllocated (el))
01962 {
01963 sRef sr = sRef_updateSref (el);
01964 fileloc loc = uentry_whereEarliest (fcn);
01965
01966 sRef_setAllocated (sr, loc);
01967 }
01968 else if (sRef_isPartial (el))
01969 {
01970 sRef sr = sRef_updateSref (el);
01971 fileloc loc = uentry_whereEarliest (fcn);
01972
01973 sRef_setPartial (sr, loc);
01974 }
01975 else
01976 {
01977 /* defined */ ;
01978 }
01979 } end_globSet_allElements;
01980
01981 utab = t;
01982 }
|
|
|
Definition at line 1709 of file usymtab.c. Referenced by context_enterConstantMacro(), context_enterInnerContext(), context_enterStructInnerContext(), enterParamsTemp(), and usymtab_enterFile(). 01712 {
01713 usymtab t = usymtab_create (US_NORMAL, utab, TRUE);
01714
01715 /* unconditional scope: optimize to avoid copy */
01716 t->aliases = aliasTable_copy (utab->aliases);
01717 utab = t;
01718
01719 llassert (usymtab_isDefined (t->env));
01720
01721 if (t->env->lexlevel == paramsScope && context_inFunctionLike ())
01722 {
01723 noshadowerror = TRUE;
01724 usymtab_handleParams ();
01725 noshadowerror = FALSE;
01726 }
01727 }
|
|
|
Definition at line 4406 of file usymtab.c. Referenced by declareUnnamedEnum(). 04408 {
04409 int i;
04410
04411 for (i = 0; i < globtab->nentries; i++)
04412 {
04413 uentry current = globtab->entries[i];
04414
04415 if (uentry_isEnumTag (current))
04416 {
04417 if (isFakeTag (uentry_rawName (current)))
04418 {
04419 ctype ct = uentry_getType (current);
04420
04421 if (ctype_isEnum (ct) && (enumNameList_match (f, ctype_elist (ct))))
04422 {
04423 return uentry_getType (current);
04424 }
04425 }
04426 }
04427 }
04428
04429 return ctype_undefined;
04430 }
|
|
|
Definition at line 4433 of file usymtab.c. Referenced by coerceId(), coerceIterId(), and exprNode_fromUIO(). 04435 {
04436 uentry ce = usymtab_lookupSafe (k);
04437
04438 return (!(uentry_isUndefined (ce)) && !(uentry_isPriv (ce)));
04439 }
|
|
|
Definition at line 4463 of file usymtab.c. Referenced by lclRedeclarationError(), o_fctInfo(), and symtable_enterVar(). 04465 {
04466 uentry ce = usymtab_lookupAux (utab, k);
04467
04468 return (uentry_isValid (ce));
04469 }
|
|
|
Definition at line 4523 of file usymtab.c. Referenced by handleEnum(). 04524 {
04525 cstring ename = makeEnum (k);
04526 uentry ce = usymtab_lookupAux (globtab, ename);
04527
04528 cstring_free (ename);
04529 return (!(uentry_isUndefined (ce)) && !(uentry_isPriv (ce)));
04530 }
|
|
|
Definition at line 4453 of file usymtab.c. Referenced by exprNode_initMod(). 04455 {
04456 uentry ce = usymtab_lookupAux (globtab, k);
04457
04458 return (!(uentry_isUndefined (ce)) && !(uentry_isPriv (ce)));
04459 }
|
|
|
Definition at line 4472 of file usymtab.c. Referenced by o_fctInfo(). 04474 {
04475 uentry ce = usymtab_lookupAux (globtab, k);
04476
04477 return (uentry_isValid (ce));
04478 }
|
|
|
Definition at line 4442 of file usymtab.c. 04444 {
04445 uentry ce = usymtab_lookupSafe (k);
04446
04447 return (!(uentry_isUndefined (ce))
04448 && !(uentry_isPriv (ce))
04449 && !(uentry_isExpandedMacro (ce)));
04450 }
|
|
|
Definition at line 4500 of file usymtab.c. Referenced by handleStruct(). 04501 {
04502 cstring sname = makeStruct (k);
04503 uentry ce = usymtab_lookupAux (globtab, sname);
04504
04505 cstring_free (sname);
04506
04507
04508 return (!(uentry_isUndefined (ce)) && !(uentry_isPriv (ce)));
04509 }
|
|
|
Definition at line 4482 of file usymtab.c. Referenced by exprNode_initMod(), and main(). 04484 {
04485 uentry ce = usymtab_lookupAux (globtab, k);
04486
04487 return (!(uentry_isUndefined (ce)) && !(uentry_isPriv (ce)) && uentry_isDatatype (ce));
04488 }
|
|
|
Definition at line 4491 of file usymtab.c. 04493 {
04494 uentry ce = usymtab_lookupAux (globtab, k);
04495
04496 return (uentry_isValid (ce) && uentry_isDatatype (ce));
04497 }
|
|
|
Definition at line 4512 of file usymtab.c. Referenced by handleUnion(). 04513 {
04514 cstring uname = makeUnion (k);
04515 uentry ce = usymtab_lookupAux (globtab, uname);
04516
04517 cstring_free (uname);
04518
04519 return (!(uentry_isUndefined (ce)) && !(uentry_isPriv (ce)));
04520 }
|
|
|
Definition at line 4533 of file usymtab.c. 04535 {
04536 uentry ce = usymtab_lookupSafe (k);
04537
04538 return (!(uentry_isUndefined (ce)) && !(uentry_isPriv (ce)) && (uentry_isVar (ce)));
04539 }
|
|
|
Definition at line 1697 of file usymtab.c. Referenced by context_exitFile(), and context_processAllMacros(). 01700 {
01701
01702 llassert (utab->lexlevel == 1);
01703
01704 usymtab_exitScope (exprNode_undefined);
01705 filetab = NULL;
01706 }
|
|
|
Definition at line 3681 of file usymtab.c. Referenced by context_exitFunction(), context_exitInner(), context_exitInnerSafe(), context_exitStructInnerContext(), and usymtab_exitFile(). 03684 {
03685 usymtab ctab = usymtab_undefined;
03686 usymtab lctab = usymtab_undefined;
03687 bool mustReturn = exprNode_mustEscape (expr);
03688
03689 if (utab->kind == US_CBRANCH)
03690 {
03691 /*
03692 ** save the case branches, remove the first non-cbranch
03693 */
03694
03695 ctab = utab;
03696
03697 while (utab->kind == US_CBRANCH)
03698 {
03699 lctab = utab;
03700 utab = utab->env;
03701 llassert (utab != GLOBAL_ENV);
03702 }
03703 }
03704
03705 if (utab->kind == US_TBRANCH || utab->kind == US_FBRANCH
03706 || utab->kind == US_CBRANCH || utab->kind == US_SWITCH) {
03707
03708 if (context_inMacro ()) {
03709 /* evs 2000-07-25 */
03710 /* Unparseable macro may end inside nested scope. Deal with it. */
03711
03712 llerror (FLG_SYNTAX, message ("Problem parsing macro body of %s (unbalanced scopes). Attempting to recover, recommend /*@notfunction@*/ before macro definition.",
03713 context_inFunctionName ()));
03714
03715 while (utab->kind == US_TBRANCH
03716 || utab->kind == US_FBRANCH
03717 || utab->kind == US_CBRANCH
03718 || utab->kind == US_SWITCH)
03719 {
03720 utab = utab->env;
03721 llassert (utab != GLOBAL_ENV);
03722 }
03723 } else {
03724 llcontbug (("exitScope: in branch: %s", usymtab_unparseStack ()));
03725 /*@-branchstate@*/
03726 } /*@=branchstate@*/
03727 }
03728
03729 /*
03730 ** check all variables in scope were used
03731 */
03732
03733 /*
03734 ** bogus errors if this is the normal inside a switch,
03735 ** since cases have not been merged yet. Should probably
03736 ** still check this, but I'm too lazy at the moment...
03737 */
03738
03739 llassertfatal (utab->env != GLOBAL_ENV);
03740
03741 if (utab->env->kind != US_SWITCH)
03742 {
03743 usymtab_allUsed ();
03744 }
03745
03746 /*
03747 ** check aliasing: all only params are released (dead)
03748 ** definition: all out params are defined, all modified params
03749 ** are completely defined
03750 **
03751 ** NOTE: note for exiting paramsScope, since checkReturn should be
03752 ** called first.
03753 */
03754
03755 if (!mustReturn && (usymtab_lexicalLevel () > functionScope))
03756 {
03757 /*
03758 ** should only call this is end of scope is reachable...
03759 */
03760
03761 usymtab_checkFinalScope (FALSE);
03762 }
03763
03764 if (usymtab_lexicalLevel () == paramsScope && context_inFunctionLike ())
03765 {
03766 /*
03767 ** leaving a function, need to fix up globals
03768 */
03769
03770 uentryList params = context_getParams ();
03771 globSet globs = context_getUsedGlobs ();
03772
03773
03774 uentryList_elements (params, ue)
03775 {
03776 uentry_fixupSref (ue);
03777 } end_uentryList_elements;
03778
03779 clearFunctionTypes ();
03780
03781
03782 globSet_allElements (globs, el)
03783 {
03784 if (sRef_isCvar (el))
03785 {
03786 uentry current;
03787 int index = sRef_getScopeIndex (el);
03788
03789 if (sRef_isFileStatic (el))
03790 {
03791 llassert (usymtab_isDefined (filetab));
03792 current = usymtab_fetchIndex (filetab, index);
03793 }
03794 else
03795 {
03796 current = usymtab_fetchIndex (globtab, index);
03797 }
03798
03799 if (uentry_isVariable (current))
03800 {
03801 uentry_fixupSref (current);
03802 }
03803 else
03804 {
03805 sRef_clearDerived (uentry_getSref (current));
03806 }
03807 }
03808 } end_globSet_allElements;
03809 }
03810
03811 usymtab_quietExitScope (exprNode_loc (expr));
03812
03813 if (lctab != usymtab_undefined)
03814 {
03815 /*@i@*/ lctab->env = utab;
03816 /*@i@*/ utab = ctab;
03817 /*@-branchstate@*/ } /*@=branchstate@*/
03818 /*@-globstate@*/
03819 }
|
|
|
Definition at line 2262 of file usymtab.c. Referenced by context_exitSwitch(). 02264 {
02265 usymtab ttab = utab;
02266 usymtab stab = ttab;
02267 usymtab ltab = ttab;
02268 bool lastMustReturn = usymtab_mustEscape (utab);
02269 int i;
02270
02271
02272 while (stab->kind == US_CBRANCH)
02273 {
02274 stab = stab->env;
02275 llassert (stab != GLOBAL_ENV);
02276 }
02277
02278 while (stab->kind == US_NORMAL)
02279 {
02280 stab = stab->env;
02281 llassert (stab != GLOBAL_ENV);
02282 }
02283
02284 llassert (stab->kind == US_SWITCH);
02285
02286 /* go to the scope outside the switch (US_SWITCH is just a marker! */
02287 stab = stab->env;
02288 llassert (stab != GLOBAL_ENV);
02289
02290
02291 ttab = ttab->env;
02292 llassert (usymtab_isDefined (ttab));
02293
02294 if (ttab->kind == US_CBRANCH)
02295 {
02296 /* was quietPlainExitScope --- but, can't free it yet! */
02297 utab = utab->env;
02298 llassert (utab != GLOBAL_ENV);
02299
02300 while (ttab->kind == US_CBRANCH)
02301 {
02302 /*
02303 ** (from popTrueBranch)
02304 */
02305
02306 bool mustReturn = usymtab_mustEscape (ttab);
02307 bool mustBreak = usymtab_mustBreak (ttab);
02308
02309 usymtab_entries (ttab, current)
02310 {
02311 uentry old = /*@-compmempass@*/ usymtab_lookupAux (ltab, uentry_rawName (current));
02312 /*@=compmempass@*/
02313
02314 /*
02315 ** note that is this is in a nested branch,
02316 ** it may create a "new" old entry.
02317 */
02318
02319 if (uentry_isValid (old))
02320 {
02321 if (lastMustReturn)
02322 {
02323 uentry_mergeUses (current, old);
02324 uentry_setState (old, current);
02325 }
02326 else
02327 {
02328 uentry_mergeState (old, current, exprNode_loc (sw),
02329 mustReturn, FALSE, TRUE, SWITCHCLAUSE);
02330 }
02331 }
02332 else
02333 {
02334 ;
02335 }
02336 } end_usymtab_entries;
02337
02338 /*
02339 ** if entry is not in symbol table for this case, merge with pre-switch
02340 ** table
02341 */
02342
02343 if (!mustReturn && !mustBreak)
02344 {
02345 usymtab_entries (stab, current)
02346 {
02347 if (usymtab_getIndex (ttab, uentry_rawName (current)) == NOT_FOUND)
02348 {
02349 uentry old = /*@-compmempass@*/
02350 usymtab_lookupAux (ltab, uentry_rawName (current));
02351 /*@=compmempass@*/
02352
02353 llassert (uentry_isValid (old));
02354 uentry_mergeState (old, current, exprNode_loc (sw),
02355 FALSE, FALSE, TRUE, SWITCHCLAUSE);
02356 }
02357 } end_usymtab_entries;
02358 }
02359
02360 ltab->env = ttab->env;
02361 ttab = ltab->env;
02362
02363 /*
02364 ** Suprious error, becuase of environments.
02365 */
02366
02367 /*@i1@*/ utab = ltab;
02368
02369 lastMustReturn = FALSE;
02370 /*@-branchstate@*/
02371 }
02372 }
02373 /*@=branchstate@*/
02374
02375 /*
02376 ** now, there is one US_CBRANCH. Merge this with the stab.
02377 */
02378
02379
02380 for (i = 0; i < ltab->nentries; i++)
02381 {
02382 uentry current = ltab->entries[i];
02383 uentry old = usymtab_lookupAux (stab, uentry_rawName (current));
02384
02385 /* note that is this is in a nested branch,
02386 it may create a "new" old entry. */
02387
02388
02389 if (uentry_isValid (old))
02390 {
02391 if (allpaths)
02392 {
02393 uentry_mergeUses (current, old);
02394 uentry_setState (old, current);
02395 }
02396 else
02397 {
02398 uentry_mergeState (old, current, exprNode_loc (sw),
02399 FALSE, FALSE, TRUE, SWITCHCLAUSE);
02400 }
02401 }
02402 else
02403 {
02404 }
02405 }
02406
02407 /*
02408 ** exit the switch
02409 */
02410
02411
02412 /*
02413 ** switch may or may not be followed by a new scope
02414 */
02415
02416 if (utab->kind == US_SWITCH)
02417 {
02418 usymtab_quietPlainExitScope ();
02419 }
02420 else
02421 {
02422 usymtab_quietPlainExitScope ();
02423 llassert (utab->kind == US_SWITCH);
02424 usymtab_quietPlainExitScope ();
02425 }
02426
02427 }
|
|
|
Definition at line 2809 of file usymtab.c. Referenced by main(). 02811 {
02812 int i;
02813
02814 for (i = 0; i < utab->nentries; i++)
02815 {
02816 uentry ce = utab->entries[i];
02817
02818 if (!uentry_isDatatype (ce)
02819 && !uentry_isAnyTag (ce)
02820 && !uentry_isEitherConstant (ce) && !uentry_isStatic (ce)
02821 && !uentry_isExternal (ce)
02822 && !uentry_isForward (ce))
02823 {
02824 fileloc fwhere = uentry_whereDeclared (ce);
02825
02826 if (fileloc_isUndefined (fwhere)
02827 && uentry_isFunction (ce))
02828 {
02829 fwhere = uentry_whereDefined (ce);
02830 }
02831
02832 if (fileloc_isDefined (fwhere)
02833 && !fileloc_isHeader (fwhere)
02834 && !(fileloc_isSpecialFile (fwhere)
02835 && !context_getFlag (FLG_UNUSEDSPECIAL)))
02836 {
02837 if (uentry_isVariable (ce))
02838 {
02839 if (optgenerror
02840 (FLG_EXPORTHEADERVAR,
02841 message ("%s %q exported but not declared in header file",
02842 ekind_capName (uentry_getKind (ce)),
02843 uentry_getName (ce)),
02844 fwhere))
02845 {
02846 uentry_showDefSpecInfo (ce, fwhere);
02847 }
02848 }
02849 else
02850 {
02851 if (!uentry_isIter (ce)
02852 && !uentry_isEndIter (ce)
02853 && !uentry_isExpandedMacro (ce))
02854 {
02855 if (uentry_isFunction (ce)
02856 && cstring_equalLit (uentry_rawName (ce), "main"))
02857 {
02858 ; /* no error for main */
02859 }
02860 else
02861 {
02862 if (optgenerror
02863 (FLG_EXPORTHEADER,
02864 message ("%s %q exported but not declared "
02865 "in header file",
02866 ekind_capName (uentry_getKind (ce)),
02867 uentry_getName (ce)),
02868 fwhere))
02869 {
02870 uentry_showDefSpecInfo (ce, fwhere);
02871 }
02872 }
02873 }
02874 }
02875 }
02876 }
02877 }
02878 }
|
|
|
Definition at line 2880 of file usymtab.c. Referenced by main(). 02882 {
02883 int i;
02884
02885
02886 for (i = 0; i < utab->nentries; i++)
02887 {
02888 uentry ce = utab->entries[i];
02889
02890
02891 if (!uentry_isDatatype (ce) && !uentry_isAnyTag (ce)
02892 && !uentry_isEitherConstant (ce)
02893 && !uentry_isIter (ce)
02894 && !uentry_isEndIter (ce)
02895 && !uentry_isExpandedMacro (ce)
02896 && uentry_isUsed (ce))
02897 {
02898 /* check static uses */
02899 filelocList fuses = uentry_getUses (ce);
02900 fileloc mod = uentry_whereDefined (ce);
02901 bool ok = filelocList_isEmpty (fuses);
02902 fileloc fwhere = uentry_whereDeclared (ce);
02903
02904 if (fileloc_isSpecialFile (fwhere)
02905 && !context_getFlag (FLG_UNUSEDSPECIAL))
02906 {
02907 ok = TRUE; /* no errors for special files */
02908 }
02909 else
02910 {
02911 filelocList_elements (fuses, uloc)
02912 {
02913 if (fileloc_isUndefined (uloc) || !fileloc_sameModule (uloc, mod))
02914 {
02915 ok = TRUE;
02916 /*@innerbreak@*/ break;
02917 }
02918 } end_filelocList_elements;
02919 }
02920
02921 if (!ok)
02922 {
02923 if (optgenerror
02924 (FLG_EXPORTLOCAL,
02925 message ("%s exported but not used outside %s: %q",
02926 ekind_capName (uentry_getKind (ce)),
02927 fileloc_getBase (mod),
02928 uentry_getName (ce)),
02929 fwhere))
02930 {
02931 uentry_showDefSpecInfo (ce, fwhere);
02932 }
02933 }
02934 }
02935 }
02936 }
|
|
|
Definition at line 4616 of file usymtab.c. Referenced by context_destroyMod(). 04619 {
04620 dbgfree = TRUE;
04621 usymtab_freeAux (utab);
04622 }
|
|
|
Definition at line 1325 of file usymtab.c. Referenced by usymtab_getId(). 01327 {
01328 if (dbgfree) return (uentry_undefined);
01329
01330 if (utab->lexlevel > paramsScope)
01331 {
01332 /* need to do this the awkward way, since it could be in conditional scope */
01333 return (usymtab_lookupSafe (uentry_rawName (globtab->entries[uid])));
01334 }
01335 else
01336 {
01337 return (globtab->entries[uid]);
01338 }
01339 }
|
|
|
Definition at line 1286 of file usymtab.c. 01287 {
01288 usymId uid = usymtab_getIndex (globtab, k);
01289 uentry ue;
01290
01291 if (uid == NOT_FOUND)
01292 {
01293 return USYMIDINVALID;
01294 }
01295
01296 ue = usymtab_getGlobalEntry (uid);
01297
01298 if (uentry_isPriv (ue))
01299 {
01300 return USYMIDINVALID;
01301 }
01302
01303 return uid;
01304 }
|
|
|
Definition at line 3849 of file usymtab.c. 03851 {
03852 /*
03853 ** requires in a function context (checked)
03854 **
03855 ** depends on no nested functions --- the function
03856 ** parameters are ALWAYS one scope inside the global scope
03857 ** and entered in order!
03858 */
03859 usymtab s = utab;
03860
03861 if (!context_inFunctionLike ())
03862 llfatalbug (message ("usymtab_getParam: not in function context: %q",
03863 context_unparse ()));
03864
03865 while (s->lexlevel > paramsScope)
03866 {
03867 s = s->env;
03868 }
03869
03870 llassert (usymtab_isDefined (s));
03871
03872 if (paramno >= s->nentries)
03873 {
03874 /*
03875 ** Parse errors lead to this.
03876 */
03877
03878 uentry err = uentry_makeVariableLoc (cstring_makeLiteralTemp ("<error>"),
03879 ctype_unknown);
03880
03881 uentry_markOwned (err);
03882 return (err);
03883 }
03884
03885 return (s->entries[paramno]);
03886 }
|
|
|
Definition at line 3940 of file usymtab.c. Referenced by sRef_fixOuterRef(), sRef_getBaseUentry(), sRef_getUentry(), sRef_hasName(), sRef_sameName(), and sRef_unparseDebug(). 03942 {
03943 usymtab s = utab;
03944
03945
03946 llassert (s != NULL);
03947 llassert (index >= 0);
03948
03949 if (level > s->lexlevel)
03950 {
03951
03952 return uentry_undefined;
03953 }
03954
03955 llassertprint (level <= s->lexlevel, ("level: %d / lexlevel: %d",
03956 level, s->lexlevel));
03957
03958 while (s->lexlevel > level)
03959 {
03960 if (usymtab_isBranch (s))
03961 {
03962 int eindex = refTable_lookup (s, level, index);
03963
03964 if (eindex != NOT_FOUND)
03965 {
03966 return (s->entries[eindex]);
03967 }
03968 }
03969
03970 s = usymtab_dropEnv (s);
03971 }
03972
03973 while (usymtab_isBranch (s) && s->lexlevel == level)
03974 {
03975 int eindex = refTable_lookup (s, level, index);
03976
03977 if (eindex != NOT_FOUND)
03978 {
03979 return (s->entries[eindex]);
03980 }
03981
03982 s = usymtab_dropEnv (s);
03983 }
03984
03985 if (index >= s->nentries)
03986 {
03987 return uentry_undefined;
03988 }
03989
03990 llassert (!uentry_isUndefined (s->entries[index]));
03991
03992 return s->entries[index];
03993 }
|
|
|
Definition at line 1342 of file usymtab.c. Referenced by ctype_isMutable(), ctype_isRefCounted(), exprNode_checkMacroBody(), sRef_perhapsNull(), sRef_possiblyNull(), sRef_setStateFromType(), uentry_getRealType(), usymtab_getTypeEntryName(), usymtab_matchForwardStruct(), usymtab_supAbstractTypeEntry(), usymtab_supExposedTypeEntry(), and usymtab_supForwardTypeEntry(). 01344 {
01345 if (dbgload)
01346 {
01347 if (uid >= 0 && uid < globtab->nentries)
01348 {
01349 return (globtab->entries[uid]);
01350 }
01351 else
01352 {
01353 return (uentry_undefined);
01354 }
01355 }
01356 else
01357 {
01358 llassert (uid >= 0 && uid < globtab->nentries);
01359
01360 return (globtab->entries[uid]);
01361 }
01362 }
|
|
|
Definition at line 1391 of file usymtab.c. 01393 {
01394 uentry ue;
01395
01396 if (dbgfree)
01397 {
01398 return (cstring_makeLiteral ("<freetype>"));
01399 }
01400
01401 ue = usymtab_getTypeEntry (uid);
01402
01403 if (dbgload && !uentry_isValid (ue))
01404 {
01405 return (message ("<missing type: %d>", uid));
01406 }
01407
01408 llassertprint (uentry_isValid (ue), ("type undefined: %d", uid));
01409
01410 return (uentry_getName (ue));
01411 }
|
|
|
Definition at line 1369 of file usymtab.c. Referenced by sRef_makeConst(), and sRef_makeType(). 01371 {
01372 if (uid < 0 || uid >= globtab->nentries)
01373 {
01374 return uentry_undefined;
01375 }
01376
01377 return (globtab->entries[uid]);
01378 }
|
|
|
Definition at line 1243 of file usymtab.c. Referenced by context_canAccessBool(), ctype_isBool(), exprNode_vaArg(), usymtab_lookupAbstractType(), and usymtab_lookupType(). 01244 {
01245 usymId uid = usymtab_getIndex (globtab, k);
01246
01247 if (uid == NOT_FOUND) return USYMIDINVALID;
01248
01249 if (!(uentry_isDatatype (usymtab_getTypeEntry (uid)))) {
01250 return USYMIDINVALID;
01251 }
01252
01253 return uid;
01254 }
|
|
|
Definition at line 1202 of file usymtab.c. Referenced by context_exitInnerSafe(). 01203 {
01204 return (utab->lexlevel > paramsScope);
01205 }
|
|
|
Definition at line 4634 of file usymtab.c. Referenced by context_exitFile(), context_inGlobalScope(), and usymtab_allUsed(). 04635 {
04636 return (utab->lexlevel == fileScope);
04637 }
|
|
|
Definition at line 4639 of file usymtab.c. Referenced by context_exitFunction(). 04640 {
04641 return (utab->lexlevel == functionScope);
04642 }
|
|
|
Definition at line 4629 of file usymtab.c. Referenced by context_inGlobalScope(). 04630 {
04631 return (utab == globtab);
04632 }
|
|
|
Definition at line 323 of file usymtab.c. Referenced by main(). 00324 {
00325 if (context_getFlag (FLG_NOLIB))
00326 {
00327 ctype boolt = ctype_bool;
00328 /* evs 2000-07-24: bool is now treated as abstract (always) */
00329
00330 uentry boolentry = uentry_makeBoolDatatype (YES);
00331 usymtab_supGlobalEntry (boolentry);
00332 context_addBoolAccess ();
00333
00334 /*
00335 ** We supply values 0 and 1 for the constants, so things like
00336 ** while (TRUE) can be interpreted correctly.
00337 */
00338
00339 usymtab_supGlobalEntry
00340 (uentry_makeConstantAux (context_getFalseName (), boolt,
00341 fileloc_getBuiltin (), FALSE,
00342 multiVal_makeInt (0)));
00343 usymtab_supGlobalEntry
00344 (uentry_makeConstantAux (context_getTrueName (), boolt,
00345 fileloc_getBuiltin (), FALSE,
00346 multiVal_makeInt (1)));
00347 }
00348 }
|
|
|
Definition at line 305 of file usymtab.c. Referenced by context_initMod(). 00308 {
00309 utab = usymtab_createRoot ();
00310 globtab = utab;
00311 filetab = usymtab_undefined;
00312 oldtab = usymtab_undefined;
00313 }
|
|
|
Definition at line 212 of file usymtab.c. 00213 {
00214 return (sRef_deepPred (usymtab_isProbableNullAltBranch, s));
00215 }
|
|
|
Definition at line 1381 of file usymtab.c. Referenced by ctype_isUserBool(). 01383 {
01384 llassert (uid >= 0 && uid < globtab->nentries);
01385
01386 return (cstring_equal (uentry_rawName (globtab->entries[uid]),
01387 context_getBoolName ()));
01388 }
|
|
|
Definition at line 4751 of file usymtab.c. Referenced by checkAssignTransfer(), exprNode_arrayFetch(), exprNode_arrowAccess(), exprNode_functionCall(), and exprNode_preOp(). 04752 {
04753
04754 return (sRef_aliasCompleteSimplePred (usymtab_isGuardedAux, s));
04755 }
|
|
|
Definition at line 4762 of file usymtab.c. 04763 {
04764 return (sRef_deepPred (usymtab_isProbableNull, s));
04765 }
|
|
|
Definition at line 4757 of file usymtab.c. Referenced by usymtab_checkFinalScope(). 04758 {
04759 return (sRef_aliasCheckSimplePred (usymtab_isProbableNullAux, s));
04760 }
|
|
|
Definition at line 1585 of file usymtab.c. Referenced by BUFLEN(). 01588 {
01589 char *s = mstring_create (MAX_DUMP_LINE_LENGTH);
01590 char *os = s;
01591 ekind kind = KINVALID;
01592 fileloc loc = g_currentloc;
01593 char c;
01594 uentry ue;
01595
01596 dbgload = TRUE;
01597
01598 llassert (utab == globtab);
01599 llassert (utab->nentries == 0);
01600
01601 while (fgets (s, MAX_DUMP_LINE_LENGTH, f) != NULL
01602 && *s == ';')
01603 {
01604 ; /* ignore ;-comments */
01605 }
01606
01607 while (s != NULL && *s != ';')
01608 {
01609
01610 if (*s == '*')
01611 {
01612 s++;
01613 kind = ekind_fromInt (getInt (&s));
01614
01615 goto nextiter;
01616 }
01617
01618 if (*s == '$')
01619 {
01620 llfatalerror
01621 (cstring_makeLiteral
01622 ("Library is in obsolete format. Use lclint +whichlib "
01623 "to see which library is being loaded."));
01624 }
01625
01626 ue = uentry_undump (kind, loc, &s);
01627 DPRINTF (("Load: %s", uentry_unparseFull (ue)));
01628
01629 if (uentry_isValid (ue))
01630 {
01631 ue = usymtab_addEntryBase (utab, ue);
01632 /*@-branchstate@*/
01633 }
01634 /*@=branchstate@*/
01635
01636 /*
01637 ** now, any other names are the same uentry
01638 */
01639
01640 while (*(s++) == '#')
01641 {
01642 cstring name = cstring_fromCharsO (getWord (&s));
01643 uentry nue = uentry_nameCopy (name, ue);
01644
01645 DPRINTF (("Name copy: %s", uentry_unparseFull (nue)));
01646 usymtab_addEntryBase (utab, nue);
01647 }
01648
01649 while ((c = *s) != '\0' && (c !='\n'))
01650 {
01651 if (c != ' ' || c != '\t')
01652 {
01653 llbuglit ("Junk in load file");
01654 }
01655
01656 s++;
01657 }
01658
01659 nextiter:
01660 s = fgets (os, MAX_DUMP_LINE_LENGTH, f);
01661 }
01662
01663 dbgload = FALSE;
01664 sfree (os);
01665 }
|
|
|
Definition at line 4341 of file usymtab.c. Referenced by exprNode_initMod(). 04342 {
04343 usymId uid = usymtab_getTypeId (k);
04344
04345 if (uid == USYMIDINVALID)
04346 {
04347 llcontbug (message ("usymtab_lookupType: not found: %s", k));
04348 return ctype_unknown;
04349 }
04350
04351 return (uentry_getAbstractType (usymtab_getTypeEntry (uid)));
04352 }
|
|
|
Definition at line 4312 of file usymtab.c. Referenced by exprNode_fromUIO(), and lclRedeclarationError(). 04314 {
04315 uentry ce = usymtab_lookupSafe (k);
04316
04317 if (uentry_isUndefined (ce))
04318 llfatalerror (message ("usymtab_lookup: not found: %s", k));
04319
04320 return ce;
04321 }
|
|
|
Definition at line 1276 of file usymtab.c. 01277 {
01278 cstring ename = makeEnum (k);
01279 uentry res = usymtab_lookupGlob (ename);
01280
01281 cstring_free (ename);
01282 return res;
01283 }
|
|
|
Definition at line 4266 of file usymtab.c. 04268 {
04269 uentry ce = usymtab_lookupAux (utab, k);
04270
04271 if (uentry_isUndefined (ce))
04272 {
04273 llfatalbug (message ("usymtab_lookup: not found: *%s*", k));
04274 }
04275
04276 if (uentry_isPriv (ce))
04277 {
04278 llfatalbug (message ("usymtab_lookup: private: *%s*", k));
04279 }
04280
04281 return ce;
04282 }
|
|
|
Definition at line 4284 of file usymtab.c. 04285 {
04286 return (usymtab_lookupGlobSafe (k));
04287 }
|
|
|
Definition at line 4289 of file usymtab.c. Referenced by exprNode_initMod(), usymtab_lookupEnumTag(), usymtab_lookupStructTag(), and usymtab_lookupUnionTag(). 04291 {
04292 uentry ce = usymtab_lookupAux (globtab, k);
04293
04294 if (uentry_isUndefined (ce))
04295 llfatalbug (message ("usymtab_lookup: not found: %s", k));
04296
04297 if (uentry_isPriv (ce))
04298 llfatalbug (message ("usymtab_lookup: private: %s", k));
04299
04300 return ce;
04301 }
|
|
|
Definition at line 4304 of file usymtab.c. Referenced by usymtab_lookupExposeGlob(). 04306 {
04307 uentry ce = usymtab_lookupAux (globtab, k);
04308
04309 return ce;
04310 }
|
|
|
Definition at line 4258 of file usymtab.c. Referenced by exprNode_fromIdentifier(), exprNode_getUentry(), fixModifiesId(), fixSpecClausesId(), main(), processNamedDecl(), sRef_isMacroParamRef(), sRef_updateSref(), uentry_mergeState(), usymtab_exists(), usymtab_existsReal(), usymtab_existsVar(), usymtab_getGlobalEntry(), and usymtab_lookupEither(). 04260 {
04261 DPRINTF (("Lookup safe: %s", k));
04262 return (usymtab_lookupAux (utab, k));
04263 }
|
|
|
Definition at line 1257 of file usymtab.c. 01258 {
01259 cstring sname = makeStruct (k);
01260 uentry ue = usymtab_lookupGlob (sname);
01261 cstring_free (sname);
01262 return (ue);
01263 }
|
|
|
Definition at line 4325 of file usymtab.c. 04327 {
04328 usymId uid = usymtab_getTypeId (k);
04329
04330 if (uid == USYMIDINVALID)
04331 {
04332 llcontbug (message ("usymtab_lookupType: not found: %s", k));
04333 return ctype_unknown;
04334 }
04335
04336 return (uentry_getRealType (usymtab_getTypeEntry (uid)));
04337 }
|
|
|
Definition at line 1266 of file usymtab.c. 01267 {
01268 cstring uname = makeUnion (k);
01269 uentry res = usymtab_lookupGlob (uname);
01270
01271 cstring_free (uname);
01272 return res;
01273 }
|
|
|
Definition at line 4655 of file usymtab.c. 04657 {
04658 uentry ue1 = usymtab_getTypeEntry (u1);
04659 uentry ue2 = usymtab_getTypeEntry (u2);
04660
04661 if (uentry_isAnyTag (ue2))
04662 {
04663 ctype reptype = uentry_getType (ue1);
04664
04665 if (ctype_isPointer (reptype))
04666 {
04667 ctype repbase = ctype_getBaseType (reptype);
04668
04669 if (ctype_isUA (repbase))
04670 {
04671 typeId rtuid = ctype_typeId (repbase);
04672
04673 if (u2 == rtuid) return TRUE;
04674
04675 if (usymId_isValid (rtuid))
04676 {
04677 reptype = uentry_getType (usymtab_getTypeEntry (rtuid));
04678
04679 return (ctype_isUA (reptype) && (u2 == (ctype_typeId (reptype))));
04680 }
04681 }
04682 }
04683 }
04684
04685 return FALSE;
04686 }
|
|
|
Definition at line 2126 of file usymtab.c. Referenced by context_enterCaseClause(). 02128 {
02129 bool mustBreak = usymtab_mustBreak (utab);
02130 bool mustReturn = usymtab_mustEscape (utab);
02131 usymtab stab = utab;
02132
02133 /*
02134 ** Find last case (or outer switch)
02135 */
02136
02137 while (stab->kind != US_CBRANCH && stab->kind != US_SWITCH)
02138 {
02139 stab = stab->env;
02140 llassert (stab != GLOBAL_ENV);
02141 }
02142
02143 /* ??? */
02144
02145 while (stab->kind == US_CBRANCH)
02146 {
02147 stab = stab->env;
02148 llassert (stab != GLOBAL_ENV);
02149 }
02150
02151 /*
02152 ** if its a fall through case, merge in outside entries and last case.
02153 **
02154 ** e.g.,
02155 ** ...
02156 ** switch
02157 ** case 1: x = 3; <fall through>
02158 ** case 2: << x may not be defined
02159 **
02160 */
02161
02162 if (!mustBreak && !mustReturn && utab->kind == US_CBRANCH)
02163 {
02164 llassert (stab->kind == US_SWITCH || stab->kind == US_NORMAL);
02165
02166 usymtab_entries (utab, ue) /* but, keep track of used variables */
02167 {
02168 uentry old = usymtab_lookupAux (stab, uentry_rawName (ue));
02169
02170 llassert (uentry_isValid (old));
02171
02172 /* modifies ue, not old */
02173
02174 uentry_mergeState (ue, old, exprNode_loc (last),
02175 FALSE, FALSE, TRUE, CASECLAUSE);
02176 } end_usymtab_entries;
02177
02178 utab->aliases = aliasTable_levelUnion (utab->aliases,
02179 stab->aliases, utab->lexlevel);
02180
02181 /*
02182 ** No need for a new branch.
02183 */
02184
02185 return FALSE;
02186 }
02187 else
02188 {
02189 usymtab_caseBranch ();
02190 /*@-mustfree@*/ /*< utab->aliases >*/
02191 utab->aliases = aliasTable_copy (stab->aliases);
02192 /*@=mustfree@*/
02193
02194 return TRUE;
02195 }
02196 }
|
|
|
Definition at line 2203 of file usymtab.c. Referenced by context_exitAndClause(). 02205 {
02206 usymtab env = utab->env;
02207 usymtab otab= utab;
02208 int i = 0;
02209
02210 llassert (utab->kind == US_TBRANCH);
02211
02212 /*
02213 ** merge each entry in table with its original
02214 ** unless execution cannot continue after this branch
02215 */
02216
02217 for (i = 0; i < utab->nentries; i++)
02218 {
02219 uentry current = utab->entries[i];
02220 sRef tref = uentry_getSref (current);
02221 uentry old = usymtab_lookupAux (env, uentry_rawName (current));
02222 sRef oref = uentry_getSref (old);
02223
02224 /* note that is current is in a nested branch,
02225 it may create a "new" old entry. */
02226
02227 llassert (uentry_isValid (old));
02228 uentry_mergeState (old, current, exprNode_loc (expr),
02229 FALSE, FALSE, TRUE, ANDCLAUSE);
02230
02231 /*
02232 ** if is it defined by the second clause, then it should be defined.
02233 */
02234
02235 if (sRef_isAnyDefined (tref)
02236 && (sRef_isAllocated (oref) || sRef_isStateUndefined (oref)))
02237 {
02238 sRef_setDefined (oref, g_currentloc);
02239 }
02240 }
02241
02242 utab->guards = guardSet_levelUnionFree (utab->guards,
02243 guardSet_invert (exprNode_getGuards (pred)),
02244 utab->lexlevel);
02245 utab->aliases = aliasTable_levelUnion (utab->aliases, otab->aliases, utab->lexlevel);
02246
02247 usymtab_quietPlainExitScope ();
02248
02249 }
|
|
|
Definition at line 2494 of file usymtab.c. Referenced by context_exitClause(), usymtab_popTrueBranch(), and usymtab_popTrueExecBranch(). 02497 {
02498 int i = 0;
02499 usymtab ftab = utab;
02500 usymtab ttab = utab->env;
02501
02502 fileloc loc;
02503 usymtab env;
02504 guardSet guards = exprNode_getGuards (pred);
02505 sRefSet tguards = guardSet_getTrueGuards (guards);
02506 sRefSet fguards = guardSet_getFalseGuards (guards);
02507 bool mustReturnT = exprNode_mustEscape (tbranch);
02508 bool mustReturnF = exprNode_mustEscape (fbranch);
02509
02510 if (exprNode_isDefined (fbranch))
02511 {
02512 loc = exprNode_loc (fbranch);
02513 }
02514 else
02515 {
02516 loc = exprNode_loc (tbranch);
02517 }
02518
02519 llassert (usymtab_isDefined (ttab));
02520
02521 env = ttab->env;
02522
02523 llassert (usymtab_isDefined (env));
02524 llassert (ftab->kind == US_FBRANCH);
02525 llassert (ttab->kind == US_TBRANCH);
02526
02527 /*
02528 ** For each element that is true guarded (i.e., if (x != NULL))
02529 ** make x = null in false branch,
02530 ** and x = notnull in true branch.
02531 ** unless x was set locally in that branch.
02532 ** For each element that is false guarded (x == NULL)
02533 ** make x = null in true, notnull in false.
02534 **
02535 ** For each element that is either guarded (pred(x))
02536 **
02537 */
02538
02539 sRefSet_allElements (tguards, el)
02540 {
02541 updateNullState (el, ttab, ftab, TRUE);
02542 } end_sRefSet_allElements;
02543
02544 sRefSet_allElements (fguards, el)
02545 {
02546 updateNullState (el, ttab, ftab, FALSE);
02547 } end_sRefSet_allElements;
02548
02549 /*
02550 **
02551 ** if an entry is in both true and false, merge the entries,
02552 ** then replace original with new state.
02553 **
02554 ** if an entry is in one table, merge it with the original.
02555 */
02556
02557 for (i = 0; i < ftab->nentries; i++)
02558 {
02559 uentry fthis = ftab->entries[i];
02560 uentry old = usymtab_lookupAux (env, uentry_rawName (fthis));
02561 int tindex = usymtab_getIndex (ttab, uentry_rawName (fthis));
02562
02563 if (uentry_isUndefined (old))
02564 {
02565 /* possible entry was added as an undefined id */
02566 continue;
02567 }
02568
02569 if (tindex != NOT_FOUND)
02570 {
02571 uentry tthis = ttab->entries[tindex];
02572
02573 /* note that is this is in a nested branch,
02574 it may create a "new" old entry. */
02575
02576 if (!mustReturnF)
02577 {
02578 if (!mustReturnT)
02579 {
02580
02581 uentry_mergeState (fthis, tthis, loc,
02582 mustReturnT, FALSE, FALSE, cl);
02583 }
02584 else
02585 {
02586 uentry_mergeUses (fthis, tthis);
02587 }
02588
02589 uentry_setState (old, fthis);
02590
02591 /*@-mustfree@*/
02592 }
02593 /*@=mustfree@*/
02594 else
02595 {
02596 uentry_setState (old, tthis);
02597 uentry_mergeState (old, fthis, loc, mustReturnF,
02598 TRUE, FALSE, cl);
02599 }
02600
02601 ttab->entries[tindex] = uentry_undefined;
02602 uentry_free (tthis);
02603 }
02604 else
02605 {
02606 uentry_mergeState (old, fthis, loc, mustReturnF, TRUE, FALSE, cl);
02607 }
02608 }
02609
02610 for (i = 0; i < ttab->nentries; i++)
02611 {
02612 uentry current = ttab->entries[i];
02613
02614 if (!uentry_isUndefined (current))
02615 {
02616 uentry old = usymtab_lookupAux (env, uentry_rawName (current));
02617
02618 llassertprint (!uentry_isUndefined (old), ("name: <%s>",
02619 uentry_rawName (current)));
02620 if (mustReturnF)
02621 {
02622 uentry_mergeUses (current, old);
02623 uentry_setState (old, current);
02624 }
02625 else
02626 {
02627 /*
02628 ** assumes false branch is a fall-through if
02629 ** fbranch is not defined. This is true, unless
02630 ** where was some greivous error in processing
02631 ** the else branch of an if-then, in which case
02632 ** this is probably the right thing to do anyway.
02633 */
02634
02635 uentry_mergeState (old, current, loc, mustReturnT,
02636 FALSE, isOpt, cl);
02637 }
02638 }
02639 }
02640
02641
02642 /*
02643 ** Plain levelUnion doesn't work, since we need to use the sRef's in env->aliases
02644 ** if they are present.
02645 */
02646
02647 llassert (NOALIAS (env->aliases, ttab->aliases));
02648 llassert (NOALIAS (env->aliases, ftab->aliases));
02649
02650 aliasTable_free (env->aliases);
02651
02652 env->aliases = aliasTable_levelUnionNew (ttab->aliases,
02653 ftab->aliases, env->lexlevel);
02654
02655 aliasTable_fixSrefs (env->aliases);
02656
02657 /* exit true and false scopes */
02658 usymtab_quietPlainExitScope ();
02659 usymtab_quietPlainExitScope ();
02660
02661 if (mustReturnT)
02662 {
02663 utab->guards = guardSet_levelUnionFree
02664 (utab->guards,
02665 guardSet_invert (exprNode_getGuards (pred)),
02666 utab->lexlevel);
02667 }
02668
02669 if (mustReturnF)
02670 {
02671 utab->guards = guardSet_levelUnion (utab->guards,
02672 exprNode_getGuards (pred),
02673 utab->lexlevel);
02674 }
02675
02676 DPRINTF (("Here."));
02677 }
|
|
|
Definition at line 2046 of file usymtab.c. 02047 {
02048 llassert (utab->kind == US_CBRANCH);
02049 usymtab_quietPlainExitScope ();
02050 }
|
|
|
Definition at line 2065 of file usymtab.c. Referenced by context_exitOrClause(). 02067 {
02068 bool mustReturn;
02069 usymtab env = utab->env;
02070 usymtab otab = utab;
02071 int i = 0;
02072
02073 llassert (env != NULL);
02074
02075 if (exprNode_isError (expr))
02076 {
02077 mustReturn = FALSE;
02078 }
02079 else
02080 {
02081 mustReturn = exprNode_mustEscape (expr);
02082 }
02083
02084
02085 llassert (utab->kind == US_TBRANCH);
02086
02087 /*
02088 ** merge each entry in table with its original
02089 ** unless execution cannot continue after this branch
02090 */
02091
02092 for (i = 0; i < utab->nentries; i++)
02093 {
02094 uentry current = utab->entries[i];
02095 uentry old = usymtab_lookupAux (env, uentry_rawName (current));
02096
02097 uentry_mergeState (old, current, exprNode_loc (expr),
02098 mustReturn, FALSE, TRUE, ORCLAUSE);
02099 }
02100
02101
02102 if (mustReturn)
02103 {
02104 env->guards = guardSet_levelUnionFree (env->guards,
02105 guardSet_invert (exprNode_getGuards (pred)),
02106 env->lexlevel);
02107 }
02108 else
02109 {
02110 env->aliases = aliasTable_levelUnion (env->aliases, otab->aliases, env->lexlevel);
02111 }
02112
02113 /* env is now utab */
02114 usymtab_quietPlainExitScope ();
02115 }
|
|
|
Definition at line 2033 of file usymtab.c. Referenced by context_exitForClause(), context_exitIterClause(), context_exitTrueClause(), and context_exitWhileClause(). 02034 {
02035 /*
02036 ** add a false branch
02037 ** (could be done more efficiently as a special case, but
02038 ** it is better to only maintain one version of the code)
02039 */
02040
02041 usymtab_altBranch (guardSet_invert (exprNode_getGuards (pred)));
02042 usymtab_popBranches (pred, expr, exprNode_undefined, TRUE, cl);
02043 }
|
|
|
Definition at line 2053 of file usymtab.c. Referenced by context_exitForClause(), context_exitIterClause(), and context_exitWhileClause(). 02054 {
02055 /*
02056 ** add a false branch that must return --- that is,
02057 ** the true branch is always executed!
02058 */
02059
02060 usymtab_altBranch (guardSet_invert (exprNode_getGuards (pred)));
02061 usymtab_popBranches (pred, expr, exprNode_makeMustExit (), FALSE, cl);
02062 }
|
|
|
Definition at line 1488 of file usymtab.c. Referenced by dumpState(). 01491 {
01492 llassert (usymtab_inGlobalScope ());
01493
01494 llassert (oldtab == usymtab_undefined);
01495
01496 oldtab = usymtab_shallowCopy (utab);
01497
01498 /*
01499 alpha compare - make sure order is same on different platforms
01500 error messages appear in same order
01501 */
01502
01503 qsort (utab->entries, (size_t)utab->nentries,
01504 sizeof (*utab->entries), (int (*)(const void *, const void *)) uentry_xcomparealpha);
01505
01506 usymtab_rehash (utab);
01507 }
|
|
|
Definition at line 5087 of file usymtab.c. Referenced by YY_RULE_SETUP(). 05089 {
05090 usymtab_printAllAux (utab);
05091 }
|
|
|
Definition at line 5145 of file usymtab.c. Referenced by YY_RULE_SETUP(). 05147 {
05148 int i;
05149 int depth = 0;
05150 char *ind = mstring_copy (" ");
05151 usymtab s = utab;
05152
05153 while (s != GLOBAL_ENV)
05154 {
05155 if (depth < 5)
05156 {
05157 ind[depth * 3 + 1] = '\0';
05158 }
05159
05160 if (s->env == GLOBAL_ENV)
05161 {
05162 int looplow;
05163
05164 printf ("level: %d\n", s->lexlevel);
05165
05166 looplow = 0;
05167
05168 for (i = looplow; i < s->nentries; i++)
05169 {
05170 printf ("%s%3d %s\n", ind, i,
05171 cstring_toCharsSafe (uentry_unparse (s->entries[i])));
05172 }
05173 }
05174 else
05175 {
05176 printf ("level: %d\n", s->lexlevel);
05177 for (i = 0; i < s->nentries; i++)
05178 {
05179 printf ("%s%3d %s\n", ind, i,
05180 cstring_toCharsSafe (uentry_unparse (s->entries[i])));
05181 }
05182 }
05183
05184 ind[depth * 3 + 1] = ' ';
05185 depth++;
05186 s = s->env;
05187 }
05188
05189 printf ("----------\n");
05190 mstring_free (ind);
05191 }
|
|
|
Definition at line 4807 of file usymtab.c. Referenced by YY_RULE_SETUP(). 04809 {
04810 usymtab ttab = utab;
04811
04812 while (ttab != globtab)
04813 {
04814 llmsg (message ("Guards [%d]: %q", ttab->lexlevel,
04815 guardSet_unparse (ttab->guards)));
04816 ttab = ttab->env;
04817 }
04818 }
|
|
|
Definition at line 5237 of file usymtab.c. Referenced by YY_RULE_SETUP(). 05239 {
05240 int i;
05241 usymtab s = utab;
05242
05243 printf ("lexlevel: %d\n", s->lexlevel);
05244
05245 for (i = 0; i < s->nentries; i++)
05246 {
05247 printf ("%s\n", cstring_toCharsSafe (uentry_unparseFull (s->entries[i])));
05248 }
05249
05250 while (s->lexlevel > 1)
05251 {
05252 s = s->env;
05253 }
05254
05255 llassert (usymtab_isDefined (s));
05256
05257 printf ("Params:\n");
05258
05259 for (i = 0; i < s->nentries; i++)
05260 {
05261 printf ("%d: %s\n", i,
05262 cstring_toCharsSafe (uentry_unparseFull (s->entries[i])));
05263 }
05264 }
|
|
|
Definition at line 5027 of file usymtab.c. Referenced by YY_RULE_SETUP(). 05029 {
05030 int i;
05031 usymtab s = utab;
05032 int depth = 0;
05033 char *ind = mstring_copy (" ");
05034
05035 fprintf (g_msgstream, "<<< [symbol table] >>>\n");
05036
05037 while (s != GLOBAL_ENV && s->env != GLOBAL_ENV)
05038 {
05039 cstring tname = usymtab_typeName (s);
05040
05041 if (depth < 5)
05042 {
05043 ind[depth * 3 + 1] = '\0';
05044 }
05045
05046 fprintf (g_msgstream, "level: %d (%s)\n", s->lexlevel,
05047 cstring_toCharsSafe (tname));
05048
05049 cstring_free (tname);
05050
05051 for (i = 0; i < s->nentries; i++)
05052 {
05053 cstring us = uentry_unparseFull (s->entries[i]);
05054 fprintf (g_msgstream, "%s\n", cstring_toCharsSafe (us));
05055 cstring_free (us);
05056 }
05057
05058 if (s->reftable != NULL && s->nentries > 0)
05059 {
05060 fprintf (g_msgstream, "\t<< Ref table >>\n");
05061
05062 for (i = 0; i < s->nentries; i++)
05063 {
05064 fprintf (g_msgstream, "\t%s %3d: %d, %d\n", ind, i,
05065 s->reftable[i]->level,
05066 s->reftable[i]->index);
05067 }
05068 }
05069
05070 ind[depth * 3 + 1] = ' ';
05071 depth++;
05072 s = s->env;
05073 }
05074 fprintf (g_msgstream, "<<< end usymtab >>>\n");
05075 mstring_free (ind);
05076 return;
05077 }
|
|
|
Definition at line 5080 of file usymtab.c. Referenced by YY_RULE_SETUP(). 05082 {
05083 usymtab_printAllAux (globtab);
05084 }
|
|
|
Definition at line 3627 of file usymtab.c. Referenced by context_exitAllClauses(), context_exitFile(), context_quietExitFunction(), and usymtab_exitScope(). 03630 {
03631 usymtab t = utab->env;
03632
03633 if (utab->reftable != NULL)
03634 {
03635 int i;
03636
03637 for (i = 0; i < utab->nentries; i++)
03638 {
03639 uentry current = utab->entries[i];
03640 uentry old = usymtab_lookupAux (t, uentry_rawName (current));
03641
03642 uentry_mergeState (old, current, loc, FALSE, FALSE, FALSE, NOCLAUSE);
03643 }
03644 }
03645
03646 llassert (t != NULL);
03647
03648 if (t->lexlevel > paramsScope)
03649 {
03650 t->guards = guardSet_levelUnion (t->guards, utab->guards, t->lexlevel);
03651 t->aliases = aliasTable_levelUnionSeq (t->aliases, utab->aliases,
03652 t->lexlevel);
03653 utab->aliases = aliasTable_undefined;
03654 }
03655
03656 t->mustBreak = utab->mustBreak;
03657 t->exitCode = utab->exitCode;
03658
03659 usymtab_freeLevel (utab);
03660
03661 utab = t;
03662 }
|
|
|
Definition at line 3669 of file usymtab.c. Referenced by exitParamsTemp(), usymtab_exitSwitch(), usymtab_popAndBranch(), usymtab_popBranches(), usymtab_popCaseBranch(), and usymtab_popOrBranch(). 03672 {
03673 usymtab t = utab->env;
03674
03675 llassert (t != NULL);
03676 llassert (NOALIAS (utab->aliases, t->aliases));
03677 usymtab_freeLevel (utab);
03678 utab = t;
03679 }
|
|
|
Definition at line 4646 of file usymtab.c. Referenced by doDeclareVar(). 04649 {
04650 usymtab_replaceEntryAux (utab, s);
04651 }
|
|
|
Definition at line 199 of file usymtab.c. Referenced by exprNode_caseMarker(), and exprNode_concat(). 00201 {
00202 llassert (utab != GLOBAL_ENV);
00203
00204 utab->exitCode = ex;
00205
00206 if (exitkind_mustEscape (ex))
00207 {
00208 utab->mustBreak = TRUE;
00209 }
00210 }
|
|
|
Definition at line 192 of file usymtab.c. Referenced by exprNode_caseMarker(), and exprNode_concat(). 00194 {
00195 llassert (utab != GLOBAL_ENV);
00196 utab->mustBreak = TRUE;
00197 }
|
|
|
Definition at line 4361 of file usymtab.c. Referenced by ctype_createUnnamedStruct(). 04363 {
04364 return (usymtab_suFieldsType (f, TRUE));
04365 }
|
|
|
Definition at line 1069 of file usymtab.c. Referenced by usymtab_supReturnTypeEntry(), and usymtab_supTypeEntry(). 01072 {
01073 usymId uid;
01074 uid = usymtab_supEntryAux (globtab, e, FALSE);
01075
01076 if (dodef)
01077 {
01078 uentry ue = usymtab_getTypeEntry (uid);
01079 uentry_setDatatype (ue, uid);
01080 }
01081
01082 if (context_getFlag (FLG_ACCESSMODULE))
01083 {
01084 context_addFileAccessType (uid);
01085 }
01086
01087 if (sRef_modInFunction ())
01088 {
01089 recordFunctionType (globtab->entries[uid]);
01090 }
01091
01092 return (uid);
01093 }
|
|
|
Definition at line 942 of file usymtab.c. Referenced by declareCIter(), declareIter(), and usymtab_supEntrySref(). 00945 {
00946 (void) usymtab_supEntryAux (utab, e, FALSE);
00947 }
|
|
|
Definition at line 985 of file usymtab.c. Referenced by declareFunction(), and declareStaticFunction(). 00988 {
00989 return (usymtab_supEntryReturnAux (utab, e, FALSE));
00990 }
|
|
|
Definition at line 1140 of file usymtab.c. Referenced by doVaDcl(), exprNode_iterId(), and processNamedDecl(). 01143 {
01144 sRef old = uentry_getSref (e);
01145
01146
01147 if (sRef_isType (old))
01148 {
01149 uentry ue = usymtab_supEntryReturnAux (utab, e, TRUE);
01150
01151 /*@access uentry@*/
01152 if (uentry_isValid (ue))
01153 {
01154 sRef uref = uentry_getSref (ue);
01155
01156 sRef_mergeStateQuiet (uref, old);
01157 sRef_clearDerived (uref);
01158 }
01159 /*@noaccess uentry@*/
01160 }
01161 else if (sRef_isKnown (old))
01162 {
01163 usymtab_supEntry (e);
01164 }
01165 else
01166 {
01167 (void) usymtab_supEntryAux (utab, e, TRUE);
01168 }
01169 }
|
|
|
Definition at line 993 of file usymtab.c. Referenced by doDeclareVar(), exprNode_iterNewId(), and processNamedDecl(). 00996 {
00997 return (usymtab_supEntryReturnAux (utab, e, TRUE));
00998 }
|
|
|
Definition at line 1097 of file usymtab.c. 01100 {
01101 usymId uid;
01102
01103 uid = usymtab_supEntryAux (globtab, e, FALSE);
01104
01105 if (dodef)
01106 {
01107 uentry ue = usymtab_getTypeEntry (uid);
01108
01109 uentry_setDatatype (ue, uid);
01110 }
01111
01112 if (sRef_modInFunction ())
01113 {
01114 recordFunctionType (globtab->entries[uid]);
01115 }
01116
01117 return (uid);
01118 }
|
|
|
Definition at line 1122 of file usymtab.c. Referenced by ctype_createForwardStruct(), and ctype_createForwardUnion(). 01125 {
01126 usymId uid = usymtab_supEntryAux (globtab, e, FALSE);
01127 uentry ue = usymtab_getTypeEntry (uid);
01128
01129 uentry_setDatatype (ue, uid);
01130
01131 if (sRef_modInFunction ())
01132 {
01133 recordFunctionType (globtab->entries[uid]);
01134 }
01135
01136 return (uentry_getAbstractType (ue));
01137 }
|
|
|
Definition at line 1171 of file usymtab.c. Referenced by checkConstant(), checkValueConstant(), ctype_createUnnamedStruct(), ctype_createUnnamedUnion(), declareUnnamedEnum(), doDeclareConstant(), exprNode_iterNewId(), and usymtab_initBool(). 01174 {
01175 usymId uid;
01176
01177 DPRINTF (("Sup global entry: %s", uentry_unparse (e)));
01178
01179 uid = usymtab_supEntryAux (globtab, e, FALSE);
01180
01181 if (sRef_modInFunction ())
01182 {
01183 recordFunctionType (globtab->entries[uid]);
01184 }
01185 }
|
|
|
Definition at line 1001 of file usymtab.c. Referenced by declareCIter(), declareEnum(), declareFunction(), declareStaticFunction(), declareUnnamedEnum(), and exprNode_initMod(). 01004 {
01005 uentry ret;
01006
01007 ret = usymtab_supEntryReturnAux (globtab, e, FALSE);
01008
01009 if (sRef_modInFunction ())
01010 {
01011 recordFunctionType (ret);
01012 }
01013
01014 return (ret);
01015 }
|
|
|
Definition at line 1188 of file usymtab.c. Referenced by uentry_makeUnrecognized(). 01191 {
01192 llassert (filetab != usymtab_undefined);
01193 DPRINTF (("File entry: %s", uentry_unparse (e)));
01194 return (usymtab_supEntryReturnAux (filetab, e, FALSE));
01195 }
|
|
|
Definition at line 1045 of file usymtab.c. Referenced by processNamedDecl(). 01048 {
01049 usymId uid;
01050
01051 if (uentry_isAbstractDatatype (e))
01052 {
01053 uid = usymtab_supAbstractTypeEntry (e, FALSE);
01054 }
01055 else
01056 {
01057 uid = usymtab_supEntryAux (globtab, e, FALSE);
01058 }
01059
01060 if (sRef_modInFunction ())
01061 {
01062 recordFunctionType (globtab->entries[uid]);
01063 }
01064
01065 return (globtab->entries[uid]);
01066 }
|
|
|
Definition at line 1018 of file usymtab.c. Referenced by declareStruct(), and declareUnion(). 01021 {
01022 usymId uid;
01023 ctype ret;
01024
01025 if (uentry_isAbstractDatatype (e))
01026 {
01027 uid = usymtab_supAbstractTypeEntry (e, FALSE);
01028 ret = ctype_createAbstract (uid);
01029 }
01030 else
01031 {
01032 uid = usymtab_supEntryAux (globtab, e, FALSE);
01033 ret = ctype_createUser (uid);
01034 }
01035
01036 if (sRef_modInFunction ())
01037 {
01038 recordFunctionType (globtab->entries[uid]);
01039 }
01040
01041 return ret;
01042 }
|
|
|
Definition at line 1993 of file usymtab.c. Referenced by context_enterSwitch(). 01995 {
01996 usymtab t = usymtab_create (US_SWITCH, utab, FALSE);
01997
01998 t->aliases = aliasTable_copy (utab->aliases);
01999 utab = t;
02000 }
|
|
|
Definition at line 2003 of file usymtab.c. Referenced by context_enterAndClause(), and context_enterOrClause(). 02005 {
02006 usymtab t = usymtab_create (US_TBRANCH, utab, FALSE);
02007
02008 /*
02009 ** not true! (could be in a macro)
02010 **
02011 ** llassertprint (utab->lexlevel > paramsScope,
02012 ** ("not in scope: %s", usymtab_unparseLocal ()));
02013 **
02014 */
02015
02016 guardSet_free (t->guards);
02017 t->guards = guards;
02018
02019 aliasTable_free (t->aliases);
02020 t->aliases = aliasTable_copy (utab->aliases);
02021
02022 utab = t;
02023 }
|
|
|
Definition at line 4727 of file usymtab.c. 04728 {
04729 usymtab tab = utab;
04730 sRef base = sRef_getRootBase (s);
04731 int lowlevel = paramsScope;
04732 int baselevel = sRef_lexLevel (base);
04733
04734 if (sRef_isCvar (base))
04735 {
04736 lowlevel = baselevel;
04737 if (lowlevel < paramsScope) lowlevel = paramsScope;
04738 }
04739
04740 while (tab->lexlevel >= lowlevel)
04741 {
04742 if (guardSet_isGuarded (tab->guards, s))
04743 {
04744 guardSet_delete (tab->guards, s);
04745 }
04746
04747 tab = usymtab_dropEnv (tab);
04748 }
04749 }
|
|
|
Definition at line 4368 of file usymtab.c. Referenced by ctype_createUnnamedUnion(). 04370 {
04371 return (usymtab_suFieldsType (f, FALSE));
04372 }
|
|
|
Definition at line 5013 of file usymtab.c. 05015 {
05016 return (aliasTable_unparse (utab->aliases));
05017 }
|
|
|
Definition at line 4867 of file usymtab.c. 04869 {
04870 return (usymtab_unparseStackTab (utab));
04871 }
|
1.2.3 written by Dimitri van Heesch,
© 1997-2000