]> andersk Git - splint.git/blob - src/constraintResolve.c
Fixed previously ignored splintme errors in constraintResolve.c
[splint.git] / src / constraintResolve.c
1 /*
2 ** Splint - annotation-assisted static program checker
3 ** Copyright (C) 1994-2003 University of Virginia,
4 **         Massachusetts Institute of Technology
5 **
6 ** This program is free software; you can redistribute it and/or modify it
7 ** under the terms of the GNU General Public License as published by the
8 ** Free Software Foundation; either version 2 of the License, or (at your
9 ** option) any later version.
10 ** 
11 ** This program is distributed in the hope that it will be useful, but
12 ** WITHOUT ANY WARRANTY; without even the implied warranty of
13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 ** General Public License for more details.
15 ** 
16 ** The GNU General Public License is available from http://www.gnu.org/ or
17 ** the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
18 ** MA 02111-1307, USA.
19 **
20 ** For information on splint: info@splint.org
21 ** To report a bug: splint-bug@splint.org
22 ** For more information: http://www.splint.org
23 */
24
25 /*
26 *
27 ** constraintResolve.c
28 */
29
30 /* #define DEBUGPRINT 1 */
31
32 # include <ctype.h> /* for isdigit */
33 # include "splintMacros.nf"
34 # include "basic.h"
35 # include "cgrammar.h"
36 # include "cgrammar_tokens.h"
37
38 # include "exprChecks.h"
39 # include "exprNodeSList.h"
40
41
42 /*@access constraint, exprNode @*/ /*!!! NO! Don't do this so recklessly - design your code more carefully so you don't need to! */
43
44 static constraint  inequalitySubstitute  (/*@returned@*/ constraint p_c, constraintList p_p);
45
46
47 static bool rangeCheck (arithType p_ar1, /*@observer@*/ constraintExpr p_expr1, arithType p_ar2, /*@observer@*/ constraintExpr p_expr2);
48
49 static constraint  inequalitySubstituteUnsound  (/*@returned@*/ constraint p_c, constraintList p_p);
50
51 static constraint  inequalitySubstituteStrong  (/*@returned@*/ constraint p_c, constraintList p_p);
52
53 static constraint constraint_searchandreplace (/*@returned@*/ constraint p_c, constraintExpr p_old, constraintExpr p_newExpr);
54
55
56 static constraint constraint_addOr (/*@returned@*/ constraint p_orig, /*@observer@*/ constraint p_orConstr);
57
58 static bool resolveOr (/*@temp@*/constraint p_c, /*@observer@*/ /*@temp@*/ constraintList p_list);
59
60 static /*@only@*/ constraintList reflectChangesEnsuresFree1 (/*@only@*/ constraintList p_pre2, constraintList p_post1);
61
62
63 /*@only@*/ constraintList constraintList_mergeEnsuresFreeFirst (constraintList list1, constraintList list2)
64 {
65   constraintList ret;
66
67   ret = constraintList_mergeEnsures (list1, list2);
68
69   constraintList_free(list1);
70   return ret;
71 }
72                                             
73 /*@only@*/ constraintList constraintList_mergeEnsures (constraintList list1, constraintList list2)
74 {
75   constraintList ret;
76   constraintList temp;
77
78   llassert(constraintList_isDefined(list1) );
79   llassert(constraintList_isDefined(list2) );
80
81   DPRINTF(( message ("constraintList_mergeEnsures: list1 %s list2 %s",
82                      constraintList_print(list1), constraintList_print(list2)
83                      )));
84   
85   ret = constraintList_fixConflicts (list1, list2);
86   ret = reflectChangesEnsuresFree1 (ret, list2);
87   temp = constraintList_subsumeEnsures (ret, list2);
88   constraintList_free(ret);
89   ret = temp;
90
91   temp = constraintList_subsumeEnsures (list2, ret);
92
93   temp = constraintList_addList (temp, ret);
94   constraintList_free(ret);
95   
96   DPRINTF(( message ("constraintList_mergeEnsures: returning %s ",
97                      constraintList_print(temp) )
98                      ));
99   
100
101   return temp;
102 }
103
104
105 /*@only@*/ constraintList constraintList_mergeRequiresFreeFirst (/*@only@*/ constraintList list1, constraintList list2)
106 {
107   constraintList ret;
108
109   ret = constraintList_mergeRequires(list1, list2);
110
111   constraintList_free(list1);
112
113   return ret;
114 }
115
116 /*@only@*/ constraintList constraintList_mergeRequires (constraintList list1, constraintList list2)
117 {
118   constraintList ret;
119   constraintList temp;
120
121   DPRINTF((message ("constraintList_mergeRequires: merging  %s and %s ", constraintList_print (list1), constraintList_print(list2) ) ) );
122
123   if (context_getFlag (FLG_REDUNDANTCONSTRAINTS) )
124     {
125       ret = constraintList_copy(list1);
126       ret = constraintList_addList(ret, list2); 
127       return ret;
128     }
129     
130   /* get constraints in list1 not satified by list2 */
131   temp = constraintList_reflectChanges(list1, list2);
132   DPRINTF((message ("constraintList_mergeRequires: temp = %s", constraintList_print(temp) ) ) );
133
134 /*get constraints in list2 not satified by temp*/
135   ret = constraintList_reflectChanges(list2, temp);
136  
137   DPRINTF((message ("constraintList_mergeRequires: ret =  %s", constraintList_print(ret) ) ) );
138   
139   ret = constraintList_addListFree (ret, temp);
140   
141   DPRINTF((message ("constraintList_mergeRequires: returning  %s", constraintList_print(ret) ) ) );
142
143   return ret;
144 }
145
146 /* old name mergeResolve renamed for czech naming convention */
147 void exprNode_mergeResolve (exprNode parent, exprNode child1, exprNode child2)
148 {
149   constraintList temp, temp2;
150
151   DPRINTF((message ("magically merging constraint into parent:%s for", exprNode_unparse (parent) )) );
152
153   DPRINTF((message (" children:  %s and %s", exprNode_unparse (child1), exprNode_unparse(child2) ) ) );
154
155   
156   if (exprNode_isUndefined(parent) )
157     {
158       llassert (exprNode_isDefined(parent) );
159       return;
160     }
161   
162   
163   if (exprNode_isError (child1)  || exprNode_isError(child2) )
164     {
165       if (exprNode_isError (child1) && !exprNode_isError(child2) )
166          {
167            constraintList_free(parent->requiresConstraints);
168
169            parent->requiresConstraints = constraintList_copy (child2->requiresConstraints);
170            constraintList_free(parent->ensuresConstraints);
171
172            parent->ensuresConstraints = constraintList_copy (child2->ensuresConstraints);
173            DPRINTF((message ("Copied child constraints: pre: %s and post: %s",
174                              constraintList_print( child2->requiresConstraints),
175                              constraintList_print (child2->ensuresConstraints)
176                              )
177                     ));
178            return;
179          }
180        else
181          {
182            llassert(exprNode_isError(child2) );
183            return;
184          }
185      }
186
187    llassert(!exprNode_isError (child1)  && ! exprNode_isError(child2) );
188    
189    DPRINTF((message ("Child constraints are %s %s and %s %s",
190                      constraintList_print (child1->requiresConstraints),
191                      constraintList_print (child1->ensuresConstraints),
192                      constraintList_print (child2->requiresConstraints),
193                      constraintList_print (child2->ensuresConstraints)
194                      ) ) );
195  
196  
197    constraintList_free(parent->requiresConstraints);
198
199   parent->requiresConstraints = constraintList_copy (child1->requiresConstraints);
200
201   if ( context_getFlag (FLG_ORCONSTRAINT) )
202     temp = constraintList_reflectChangesOr (child2->requiresConstraints, child1->ensuresConstraints);
203   else
204     temp = constraintList_reflectChanges(child2->requiresConstraints, child1->ensuresConstraints);
205
206   temp2 = constraintList_mergeRequires (parent->requiresConstraints, temp);
207   constraintList_free(parent->requiresConstraints);
208   constraintList_free(temp);
209   
210   parent->requiresConstraints = temp2;
211
212   DPRINTF((message ("Parent requires constraints are %s  ",
213                      constraintList_print (parent->requiresConstraints)
214                      ) ) );
215
216    constraintList_free(parent->ensuresConstraints);
217
218   parent->ensuresConstraints = constraintList_mergeEnsures(child1->ensuresConstraints,
219                                                            child2->ensuresConstraints);
220
221   
222   DPRINTF((message ("Parent constraints are %s and %s ",
223                      constraintList_print (parent->requiresConstraints),
224                      constraintList_print (parent->ensuresConstraints)
225                      ) ) );
226  
227 }
228
229
230   
231   
232 /*@only@*/ constraintList constraintList_subsumeEnsures (constraintList list1, constraintList list2)
233 {
234   constraintList ret;
235   ret = constraintList_makeNew();
236   constraintList_elements (list1, el)
237     {
238       
239       DPRINTF ((message ("Examining %s", constraint_print (el) ) ) );
240       if (!constraintList_resolve (el, list2) )
241         {
242           constraint temp;
243           temp = constraint_copy(el);
244           ret = constraintList_add (ret, temp);
245         }
246       else
247         {
248           DPRINTF ((message ("Subsuming %s", constraint_print (el) ) ) );
249         }
250     } end_constraintList_elements;
251
252     return ret;
253 }
254
255
256
257 /*used to be reflectChangesFreePre  renamed for Czech naming conventino*/
258 /* tries to resolve constraints in list pre2 using post1 */
259 /*@only@*/ constraintList constraintList_reflectChangesFreePre (/*@only@*/ constraintList pre2, /*@observer@*/ constraintList post1)
260 {
261   constraintList ret;
262   
263   ret = constraintList_reflectChanges(pre2, post1);
264
265   constraintList_free (pre2);
266   
267   return ret;
268 }
269
270
271
272 /* tries to resolve constraints in list pre2 using post1 */
273
274 static /*@only@*/ constraintList reflectChangesNoOr (/*@observer@*/ /*@temp@*/ constraintList pre2, /*@observer@*/ /*@temp@*/ constraintList post1)
275 {
276   
277   constraintList ret;
278   constraint temp;
279   constraint temp2;
280
281   llassert  (! context_getFlag (FLG_ORCONSTRAINT) );
282
283   ret = constraintList_makeNew();
284   DPRINTF((message ("reflectChanges: lists %s and %s", constraintList_print(pre2), constraintList_print(post1) )));
285   
286   constraintList_elements (pre2, el)
287     {
288       if (!constraintList_resolve (el, post1) )
289         {
290           temp = constraint_substitute (el, post1);
291           if (!constraintList_resolve (temp, post1) )
292             {
293               /* try inequality substitution
294                  the inequality substitution may cause us to lose information
295                  so we don't want to store the result but we do it anyway
296               */
297               temp2 = constraint_copy (temp);
298               temp2 = inequalitySubstitute (temp2, post1); 
299               if (!constraintList_resolve (temp2, post1) )
300                 {
301                   temp2 = inequalitySubstituteUnsound (temp2, post1); 
302                   if (!constraintList_resolve (temp2, post1) )
303                     ret = constraintList_add (ret, temp2);
304                   else
305                     constraint_free(temp2);
306                 }
307               else
308                 {
309                   constraint_free(temp2);
310                 }
311             }
312           constraint_free(temp);
313         }
314     } end_constraintList_elements;
315
316     DPRINTF((message ("reflectChanges: returning %s", constraintList_print(ret) ) ) );
317     return ret;
318 }
319
320 /* tries to resolve constraints in list pre2 using post1 */
321 /*@only@*/ constraintList constraintList_reflectChanges(/*@observer@*/ constraintList pre2, /*@observer@*/ constraintList post1)
322 {
323   constraintList temp;
324   
325   if ( context_getFlag (FLG_ORCONSTRAINT) )
326     
327     temp = constraintList_reflectChangesOr (pre2, post1);
328   else
329     temp = reflectChangesNoOr(pre2, post1);
330
331   return temp;                           
332 }
333
334 static constraint constraint_addOr (/*@returned@*/ constraint orig, /*@observer@*/ constraint orConstr)
335 {
336   constraint c;
337
338   llassert(constraint_isDefined(orig) );
339   
340   c = orig;
341
342   DPRINTF((message("constraint_addor: oring %s onto %s", constraint_printOr(orConstr), constraint_printOr(orig) ) ));
343   
344   while (c->or != NULL)
345     {
346       c = c->or;
347     }
348   
349   c->or = constraint_copy(orConstr);
350
351   DPRINTF((message("constraint_addor: returning %s",constraint_printOr(orig) ) ));
352   
353   return orig;
354 }
355
356
357 static bool resolveOr ( /*@temp@*/ constraint c, /*@observer@*/ /*@temp@*/ constraintList list)
358 {
359   constraint temp;
360
361   int numberOr;
362
363   numberOr = 0;
364
365     llassert(constraint_isDefined(c) );
366
367   DPRINTF(( message("resolveOr: constraint %s and list %s", constraint_printOr(c), constraintList_print(list) ) ));
368   
369   temp = c;
370
371   do
372     {
373       if (constraintList_resolve (temp, list) )
374         return TRUE;
375       temp = temp->or;
376       numberOr++;
377       llassert(numberOr <= 10);
378     }
379   while (constraint_isDefined(temp));
380
381   return FALSE;
382 }
383
384 /*This is a "helper" function for doResolveOr */
385
386 static /*@only@*/ constraint doResolve (/*@only@*/ constraint c, constraintList post1, bool * resolved)
387 {
388   constraint temp;
389
390   llassert(constraint_isDefined (c ) );
391
392   DPRINTF((message("doResolve:: call on constraint c = : %q and constraintList %q",
393                    constraint_printOr(c), constraintList_print(post1)
394                    )
395            ));
396   
397   if (!resolveOr (c, post1) )
398     {
399       
400       temp = constraint_substitute (c, post1);
401       
402       DPRINTF((message("doResolve:: after substitute temp is %q",
403                    constraint_printOr(temp)
404                        )
405                ));
406   
407       if (!resolveOr (temp, post1) )
408         {
409           /* try inequality substitution */
410           constraint temp2;
411           
412           /* the inequality substitution may cause us to lose information
413              so we don't want to store the result but we do  anyway
414           */
415           temp2 = constraint_copy (c);
416           temp2 = inequalitySubstitute (temp2, post1);
417
418           if (!resolveOr (temp2, post1) )
419             {
420               constraint temp3;
421               temp3 = constraint_copy(temp2);
422               
423               temp3 = inequalitySubstituteStrong (temp3, post1);
424               if (!resolveOr (temp3, post1) )
425                 {
426                   temp2 = inequalitySubstituteUnsound (temp2, post1); 
427                   if (!resolveOr (temp2, post1) )
428                     {
429                       if (!constraint_same (temp, temp2) )
430                         {
431                           /* drl added 8/28/2002*/
432                           /*make sure that the information from
433                             a post condition like i = i + 1 is transfered
434                           */
435                           constraint tempSub;
436                           tempSub = constraint_substitute (temp2, post1);
437
438                           DPRINTF((
439                                    message("doResolve: adding %s ",
440                                            constraint_printOr(tempSub)
441                                            )
442                                    ));
443                           
444                           DPRINTF((
445                                    message("doResolve: not adding %s ",
446                                            constraint_printOr(temp2)
447                                            )
448                                    ));
449                           
450                           temp = constraint_addOr (temp, tempSub);
451                           constraint_free(tempSub);
452                           
453                         }
454                       if (!constraint_same (temp, temp3) && !constraint_same (temp3, temp2) )
455                         {
456                          /* drl added 8/28/2002*/
457                           /*make sure that the information from
458                             a post condition like i = i + 1 is transfered
459                           */
460                           constraint tempSub;
461                           
462                           tempSub = constraint_substitute (temp3, post1);
463
464                           DPRINTF((
465                                    message("doResolve: adding %s ",
466                                            constraint_printOr(tempSub)
467                                            )
468                                    ));
469
470                           
471                           DPRINTF((
472                                    message("doResolve: not adding %s ",
473                                            constraint_printOr(temp3)
474                                            )
475                                    ));
476
477                           temp = constraint_addOr (temp, tempSub);
478
479                           constraint_free(tempSub);
480                         }
481                       *resolved = FALSE;
482                       
483                       constraint_free(temp2);
484                       constraint_free(temp3);
485                       constraint_free(c);
486                       
487                       return temp;
488                     }
489                   constraint_free(temp2);
490                   constraint_free(temp3);
491                 }
492               else
493                 {
494                   constraint_free(temp2);
495                   constraint_free(temp3);
496                 }
497             }
498           else
499             {
500               constraint_free(temp2);
501             }             
502           
503         }
504       constraint_free(temp);
505     }
506   constraint_free(c);
507   
508   /*drl bee: pbr*/ *resolved = TRUE;
509   return NULL;
510 }
511
512 static /*@only@*/ constraint doResolveOr (/*@observer@*/ /*@temp@*/ constraint c, constraintList post1, /*@out@*/bool * resolved)
513 {
514   constraint ret;
515   constraint next;
516   constraint curr;
517
518   
519   DPRINTF(( message("doResolveOr: constraint %s and list %s", constraint_printOr(c), constraintList_print(post1) ) ));
520
521
522   
523    /*drl bee: pbr*/ *resolved = FALSE;
524
525   llassert(constraint_isDefined(c) );
526
527   ret = constraint_copy(c);
528
529   llassert(constraint_isDefined(ret) );
530
531   if (constraintList_isEmpty(post1) )
532     {
533       return ret;
534     }
535   
536   next = ret->or;
537   ret->or = NULL;
538
539   ret = doResolve (ret, post1, resolved);
540
541   if (*resolved)
542     {
543       if (next != NULL)
544         constraint_free(next);
545       
546       /*we don't need to free ret when resolved is false because ret is null*/
547       llassert(ret == NULL);
548       
549       return NULL;
550     }
551   
552   while (next != NULL)
553     {
554       curr = next;
555       next = curr->or;
556       curr->or = NULL;
557
558       curr = doResolve (curr, post1, resolved);
559       
560     /*drl bee: pbr*/    if (*resolved)
561         {
562           /* curr is null so we don't try to free it*/
563           llassert(curr == NULL);
564           
565           if (next != NULL)
566             constraint_free(next);
567
568           constraint_free(ret);
569           return NULL;
570         }
571       ret = constraint_addOr (ret, curr);
572       constraint_free(curr);
573     }
574   return ret;
575 }
576
577 /* tries to resolve constraints in list pr2 using post1 */
578 /*@only@*/ constraintList constraintList_reflectChangesOr (constraintList pre2, constraintList post1)
579 {
580   bool resolved;
581   constraintList ret;
582   constraint temp;
583   ret = constraintList_makeNew();
584   DPRINTF((message ("constraintList_reflectChangesOr: lists %s and %s", constraintList_print(pre2), constraintList_print(post1) )));
585   
586   constraintList_elements (pre2, el)
587     {
588       temp = doResolveOr (el, post1, &resolved);
589
590       if (!resolved)
591         {
592           ret = constraintList_add(ret, temp);
593         }
594       else
595         {
596      /* we don't need to free temp when
597         resolved is false because temp is null */
598           llassert(temp == NULL);
599         }
600       
601     } end_constraintList_elements;
602
603   DPRINTF((message ("constraintList_reflectChangesOr: returning %s", constraintList_print(ret) ) ) );
604     return ret;
605 }
606
607 static /*@only@*/ constraintList reflectChangesEnsures (/*@observer@*/ constraintList pre2, constraintList post1)
608 {  
609   constraintList ret;
610   constraint temp;
611   ret = constraintList_makeNew();
612   constraintList_elements (pre2, el)
613     {
614       if (!constraintList_resolve (el, post1) )
615         {
616           temp = constraint_substitute (el, post1);
617           llassert (temp != NULL);
618
619           if (!constraintList_resolve (temp, post1) )
620             ret = constraintList_add (ret, temp);
621           else
622             constraint_free(temp);  
623         }
624       else
625         {
626           DPRINTF ((message ("Resolved away %s ", constraint_print(el) ) ) );
627         }
628     } end_constraintList_elements;
629
630     return ret;
631 }
632
633
634 static /*@only@*/ constraintList reflectChangesEnsuresFree1 (/*@only@*/ constraintList pre2, constraintList post1)
635 {
636   constraintList ret;
637
638   ret = reflectChangesEnsures (pre2, post1);
639   
640   constraintList_free(pre2);
641
642   return ret;
643 }
644
645
646 static bool constraint_conflict (constraint c1, constraint c2)
647 {
648
649   llassert(constraint_isDefined(c1) );
650   llassert(constraint_isDefined(c2) );
651
652   if (constraintExpr_similar(c1->lexpr, c2->lexpr) )
653     {
654       if (c1->ar == EQ)
655         if (c1->ar == c2->ar)
656           {
657             DPRINTF ((message ("%s conflicts with %s ", constraint_print (c1), constraint_print(c2) ) ) );
658             return TRUE;
659           }
660     }  
661
662   /* This is a slight kludg to prevent circular constraints like
663      strlen(str) == maxRead(s) + strlen(str);
664   */
665
666   /*@i324234*/ /* clean this up */
667   
668   if (c1->ar == EQ)
669     if (c1->ar == c2->ar)
670       {
671         if (constraintExpr_search (c1->lexpr, c2->expr) )
672           if (constraintExpr_isTerm(c1->lexpr) )
673             {
674               constraintTerm term;
675               
676               term = constraintExpr_getTerm(c1->lexpr);
677
678               if (constraintTerm_isExprNode(term) )
679                 {
680                   DPRINTF ((message ("%s conflicts with %s ", constraint_print (c1), constraint_print(c2) ) ) );
681                   return TRUE;
682                 }
683             }
684       }
685
686   if (constraint_tooDeep(c1) || constraint_tooDeep(c2) )
687         {
688           DPRINTF ((message ("%s conflicts with %s (constraint is too deep", constraint_print (c1), constraint_print(c2) ) ) );
689           return TRUE;
690         }
691   
692   DPRINTF ((message ("%s doesn't conflict with %s ", constraint_print (c1), constraint_print(c2) ) ) );
693
694   return FALSE; 
695
696 }
697
698 static void constraint_fixConflict (/*@temp@*/ constraint good, /*@temp@*/ /*@observer@*/ constraint conflicting) /*@modifies good@*/
699 {
700   llassert(constraint_isDefined(conflicting) );
701   
702   if (conflicting->ar ==EQ )
703     {
704       llassert(constraint_isDefined(good) );
705       good->expr = constraintExpr_searchandreplace (good->expr, conflicting->lexpr, conflicting->expr);
706       good = constraint_simplify (good);
707     }
708
709
710 }
711
712 static bool conflict (constraint c, constraintList list)
713 {
714
715   constraintList_elements (list, el)
716     {
717       if ( constraint_conflict(el, c) )
718         {
719           constraint_fixConflict (el, c);
720           return TRUE;
721         }
722     } end_constraintList_elements;
723
724     return FALSE;
725
726 }
727
728 /*
729   check if constraint in list1 conflicts with constraints in List2.  If so we
730   remove form list1 and change list2.
731 */
732
733 constraintList constraintList_fixConflicts (constraintList list1, constraintList list2)
734 {
735   constraintList ret;
736   ret = constraintList_makeNew();
737   llassert(constraintList_isDefined(list1) );
738   constraintList_elements (list1, el)
739     {
740       if (! conflict (el, list2) )
741         {
742           constraint temp;
743           temp = constraint_copy(el);
744           ret = constraintList_add (ret, temp);
745         }
746     } end_constraintList_elements;
747
748     return ret;
749 }
750
751 /*returns true if constraint post satifies cosntriant pre */
752 static bool satifies (constraint pre, constraint post)
753 {
754   llassert(constraint_isDefined(pre) );
755   llassert(constraint_isDefined(post) );
756
757   if (constraint_isAlwaysTrue (pre)  )
758     return TRUE;
759   
760   if (!constraintExpr_similar (pre->lexpr, post->lexpr) )
761     {
762       return FALSE;
763     }
764   if (constraintExpr_isUndefined(post->expr))
765     {
766       llassert(FALSE);
767       return FALSE;
768     }
769
770   return rangeCheck (pre->ar, pre->expr, post->ar, post->expr);
771 }
772
773
774 bool constraintList_resolve (/*@temp@*/ /*@observer@*/ constraint c, /*@temp@*/ /*@observer@*/ constraintList p)
775 {
776   constraintList_elements (p, el)
777     {
778       if ( satifies (c, el) )
779         {
780           DPRINTF ((message ("\n%s Satifies %s\n ", constraint_print(el), constraint_print(c) ) ) );
781           return TRUE;
782         }
783         DPRINTF ((message ("\n%s does not satify %s\n ", constraint_print(el), constraint_print(c) ) ) );
784     }
785   end_constraintList_elements;
786   DPRINTF ((message ("no constraints satify %s", constraint_print(c) ) ));
787   return FALSE;
788 }
789
790 static bool arithType_canResolve (arithType ar1, arithType ar2)
791 {
792   switch (ar1)
793     {
794     case GTE:
795     case GT:
796       if ((ar2 == GT) || (ar2 == GTE) || (ar2 == EQ) )
797         {
798           return TRUE;
799         }
800       break;
801
802     case EQ:
803       if (ar2 == EQ)
804         return TRUE;
805       break;
806
807     case LT:
808     case LTE:
809       if ((ar2 == LT) || (ar2 == LTE) || (ar2 == EQ) )
810         return TRUE;
811       break;
812     default:
813       return FALSE;
814     }
815   return FALSE;   
816 }
817
818 /*checks for the case expr2 == sizeof buf1  and buf1 is a fixed array*/
819 static bool  sizeofBufComp(constraintExpr buf1, constraintExpr expr2)
820 {
821   constraintTerm ct;
822   exprNode e, t;
823   sRef s1, s2;
824
825   llassert(constraintExpr_isDefined(buf1) && constraintExpr_isDefined(expr2) );
826
827   /*@access constraintExpr@*/
828   
829   if ((expr2->kind != term) && (buf1->kind != term) )
830     return FALSE;
831
832   
833   ct = constraintExprData_termGetTerm(expr2->data);
834
835   if (!constraintTerm_isExprNode(ct) )
836     return FALSE;
837
838   e = constraintTerm_getExprNode(ct);
839
840   llassert(exprNode_isDefined(e) );
841
842   if (! (exprNode_isDefined(e) ) )
843     return FALSE;
844   
845   if (e->kind != XPR_SIZEOF)
846     return FALSE;
847   
848   t = exprData_getSingle (e->edata);
849   s1 = exprNode_getSref (t);
850
851   s2 = constraintTerm_getsRef(constraintExprData_termGetTerm(buf1->data) );
852
853   /*@i223@*/ /*this may be the wronge thing to test for */
854   if (sRef_similarRelaxed(s1, s2)   || sRef_sameName (s1, s2) )
855     {
856       /*@i22*/ /* get rid of this test of now */
857       /* if (ctype_isFixedArray (sRef_getType (s2) ) ) */
858         return TRUE;
859     }
860   return FALSE;
861 }
862
863 /* look for the special case of
864    maxSet(buf) >= sizeof(buf) - 1
865 */
866
867 /*@i223@*/ /*need to add some type checking */
868 static bool sizeOfMaxSet( /*@observer@*/ /*@temp@*/ constraint c)
869 {
870   constraintExpr l, r, buf1, buf2, con;
871
872   DPRINTF(( message("sizeOfMaxSet: checking %s ", constraint_print(c) )
873             ));
874
875   llassert (constraint_isDefined(c) );
876     
877   l = c->lexpr;
878   r = c->expr;
879
880   if (!((c->ar == EQ) || (c->ar == GTE) || (c->ar == LTE) ) )
881     return FALSE;
882
883   llassert (constraintExpr_isDefined(l)  );
884   llassert (constraintExpr_isDefined(r)  );
885
886   /*check if the constraintExpr is MaxSet(buf) */
887   if (l->kind == unaryExpr)
888     {
889       if (constraintExprData_unaryExprGetOp(l->data) == MAXSET)
890         {
891           buf1 = constraintExprData_unaryExprGetExpr(l->data);
892         }
893       else
894         return FALSE;
895     }
896   else
897     return FALSE;
898
899   
900   if (r->kind != binaryexpr)
901     return FALSE;
902   
903   buf2 = constraintExprData_binaryExprGetExpr1(r->data);
904   con = constraintExprData_binaryExprGetExpr2(r->data);
905   
906   if (constraintExprData_binaryExprGetOp(r->data) == BINARYOP_MINUS)
907     {
908       if (constraintExpr_canGetValue(con) )
909         {
910           long i;
911           
912           i = constraintExpr_getValue(con);
913           if (i != 1)
914             {
915               return FALSE;
916             }
917         }
918       else
919         return FALSE;
920     }
921
922   if (constraintExprData_binaryExprGetOp(r->data) == BINARYOP_PLUS)
923     {
924       if (constraintExpr_canGetValue(con) )
925         {
926           long i;
927           
928           i = constraintExpr_getValue(con);
929           if (i != -1)
930             {
931               return FALSE;
932             }
933         }
934       else
935         return FALSE;
936     }
937
938   if (sizeofBufComp(buf1, buf2))
939     {
940       return TRUE;
941     }
942   else
943     {
944      return FALSE;
945     } 
946     
947
948 }
949 /*@noaccess constraintExpr@*/
950
951 /* We look for constraint which are tautologies */
952
953 bool constraint_isAlwaysTrue (/*@observer@*/ /*@temp@*/ constraint c)
954 {
955   constraintExpr l, r;
956   bool rHasConstant;
957   int rConstant;
958
959   
960   llassert (constraint_isDefined(c) );  
961   
962   l = c->lexpr;
963   r = c->expr;
964
965   DPRINTF(( message("constraint_IsAlwaysTrue:examining %s", constraint_print(c) ) ));
966
967   if (sizeOfMaxSet(c) )
968     return TRUE;
969   
970   if (constraintExpr_canGetValue(l) && constraintExpr_canGetValue(r) )
971     {
972       int cmp;
973       cmp = constraintExpr_compare (l, r);
974       switch (c->ar)
975         {
976         case EQ:
977           return (cmp == 0);
978         case GT:
979           return (cmp > 0);
980         case GTE:
981           return (cmp >= 0);
982         case LTE:
983           return (cmp <= 0);
984         case LT:
985           return (cmp < 0);
986
987         default:
988           BADEXIT;
989           /*@notreached@*/
990           break;
991         }
992     }
993
994   if (constraintExpr_similar (l,r) )
995     {
996       switch (c->ar)
997         {
998         case EQ:
999         case GTE:
1000         case LTE:
1001           return TRUE;
1002           
1003         case GT:
1004         case LT:
1005           break;
1006         default:
1007           BADEXIT;
1008           /*@notreached@*/
1009           break;
1010         }
1011     }
1012
1013   l = constraintExpr_copy (c->lexpr);
1014   r = constraintExpr_copy (c->expr);
1015
1016   r = constraintExpr_propagateConstants (r, &rHasConstant, &rConstant);
1017
1018   if (constraintExpr_similar (l,r) && (rHasConstant ) )
1019     {
1020       DPRINTF(( message("constraint_IsAlwaysTrue: after removing constants  %s and %s are similar", constraintExpr_unparse(l), constraintExpr_unparse(r) ) ));
1021       DPRINTF(( message("constraint_IsAlwaysTrue: rconstant is  %d", rConstant ) ));
1022       
1023       constraintExpr_free(l);
1024       constraintExpr_free(r);
1025       
1026       switch (c->ar)
1027         {
1028         case EQ:
1029           return (rConstant == 0);
1030         case LT:
1031           return (rConstant > 0);
1032         case LTE:
1033           return (rConstant >= 0);
1034         case GTE:
1035           return (rConstant <= 0);
1036         case GT:
1037           return (rConstant < 0);
1038           
1039         default:
1040           BADEXIT;
1041           /*@notreached@*/
1042           break;
1043         }
1044     }  
1045       else
1046       {
1047         constraintExpr_free(l);
1048         constraintExpr_free(r);
1049         DPRINTF(( message("Constraint %s is not always true", constraint_print(c) ) ));
1050         return FALSE;
1051       }
1052   
1053   BADEXIT;
1054 }
1055
1056 static bool rangeCheck (arithType ar1, /*@observer@*/ constraintExpr expr1, arithType ar2, /*@observer@*/ constraintExpr expr2)
1057
1058 {
1059   DPRINTF ((message ("Doing Range CHECK %s and %s", constraintExpr_unparse(expr1), constraintExpr_unparse(expr2) ) ));
1060
1061   if (! arithType_canResolve (ar1, ar2) )
1062     return FALSE;
1063   
1064   switch (ar1)
1065  {
1066  case GTE:
1067        if (constraintExpr_similar (expr1, expr2) )
1068           return TRUE;
1069        /*@fallthrough@*/
1070   case GT:
1071     if (!  (constraintExpr_canGetValue (expr1) &&
1072                constraintExpr_canGetValue (expr2) ) )
1073            {
1074                   constraintExpr e1, e2;
1075                   bool p1, p2;
1076                   int const1, const2;
1077
1078                   e1 = constraintExpr_copy(expr1);
1079                   e2 = constraintExpr_copy(expr2);
1080
1081                   e1 = constraintExpr_propagateConstants (e1, &p1, &const1);
1082
1083                   e2 = constraintExpr_propagateConstants (e2, &p2, &const2);
1084
1085                   if (p1 || p2)
1086                      {
1087                       if (!p1)
1088                            const1 = 0;
1089
1090                       if (!p2)
1091                            const2 = 0;
1092
1093                       if (const1 <= const2)
1094                            if (constraintExpr_similar (e1, e2) )
1095                                   {
1096                                          constraintExpr_free(e1);
1097                                          constraintExpr_free(e2);
1098                                          return TRUE;
1099                                        }
1100                       }
1101                   DPRINTF(("Can't Get value"));
1102
1103                   constraintExpr_free(e1);
1104                   constraintExpr_free(e2);
1105                   return FALSE;
1106                 }
1107
1108     if (constraintExpr_compare (expr2, expr1) >= 0)
1109            return TRUE;
1110
1111    return FALSE;
1112   case EQ:
1113     if (constraintExpr_similar (expr1, expr2) )
1114        return TRUE;
1115
1116     return FALSE;
1117   case LTE:
1118     if (constraintExpr_similar (expr1, expr2) )
1119        return TRUE;
1120     /*@fallthrough@*/
1121   case LT:
1122      if (!  (constraintExpr_canGetValue (expr1) &&
1123                 constraintExpr_canGetValue (expr2) ) )
1124             {
1125                   constraintExpr e1, e2;
1126                    bool p1, p2;
1127                    int const1, const2;
1128
1129                    e1 = constraintExpr_copy(expr1);
1130                    e2 = constraintExpr_copy(expr2);
1131
1132                    e1 = constraintExpr_propagateConstants (e1, &p1, &const1);
1133
1134                    e2 = constraintExpr_propagateConstants (e2, &p2, &const2);
1135
1136                    if (p1 || p2)
1137                       {
1138                        if (!p1)
1139                             const1 = 0;
1140
1141                        if (!p2)
1142                             const2 = 0;
1143
1144                        if (const1 >= const2)
1145                             if (constraintExpr_similar (e1, e2) )
1146                                    {
1147                                           constraintExpr_free(e1);
1148                                           constraintExpr_free(e2);
1149                                           return TRUE;
1150                                         }
1151                        }
1152                    constraintExpr_free(e1);
1153                    constraintExpr_free(e2);
1154
1155                    DPRINTF(("Can't Get value"));
1156                    return FALSE;
1157                  }
1158
1159     if (constraintExpr_compare (expr2, expr1) <= 0)
1160            return TRUE;
1161
1162     return FALSE;
1163
1164   default:
1165       llcontbug((message("Unhandled case in switch: %q", arithType_print(ar1) ) ) );
1166   }
1167   BADEXIT;
1168 }
1169
1170 static constraint constraint_searchandreplace (/*@returned@*/ constraint c, constraintExpr old, constraintExpr newExpr)
1171 {
1172    llassert (constraint_isDefined(c)  );
1173
1174   DPRINTF (("Doing replace for lexpr") );
1175   
1176   c->lexpr = constraintExpr_searchandreplace (c->lexpr, old, newExpr);
1177   DPRINTF (("Doing replace for expr") );
1178   c->expr = constraintExpr_searchandreplace (c->expr, old, newExpr);
1179   return c;
1180 }
1181
1182 bool constraint_search (constraint c, constraintExpr old) /*@*/
1183 {
1184   bool ret;
1185   ret = FALSE;
1186   
1187   llassert (constraint_isDefined(c)  );
1188   
1189   ret  = constraintExpr_search (c->lexpr, old);
1190   ret = ret || constraintExpr_search (c->expr, old);
1191   return ret;
1192 }
1193
1194 /* adjust file locs and stuff */
1195 static constraint constraint_adjust (/*@returned@*/ constraint substitute, /*@observer@*/ constraint old)
1196 {
1197   fileloc loc1, loc2, loc3;
1198
1199   DPRINTF ((message("Start adjust on %s and %s", constraint_print(substitute),
1200                      constraint_print(old))
1201                    ));
1202
1203   llassert(constraint_isDefined(substitute));
1204   llassert(constraint_isDefined(old));
1205            
1206   loc1 = constraint_getFileloc (old);
1207   loc2 = constraintExpr_getFileloc (substitute->lexpr);
1208   loc3 = constraintExpr_getFileloc (substitute->expr);
1209   
1210   /* special case of an equality that "contains itself" */
1211   if (constraintExpr_search (substitute->expr, substitute->lexpr) )
1212       if (fileloc_closer (loc1, loc3, loc2))
1213       {
1214         constraintExpr temp;
1215         DPRINTF ((message("Doing adjust on %s", constraint_print(substitute) )
1216                    ));
1217         temp = substitute->lexpr;
1218         substitute->lexpr = substitute->expr;
1219         substitute->expr  = temp;
1220         substitute = constraint_simplify(substitute);
1221       }
1222
1223   fileloc_free (loc1);
1224   fileloc_free (loc2);
1225   fileloc_free (loc3);
1226
1227   return substitute;
1228   
1229 }
1230
1231 /* If function preforms substitutes based on inequality
1232
1233    It uses the rule x >= y && b < y  ===> x >= b + 1
1234
1235    Warning this is sound but throws out information
1236  */
1237
1238 constraint  inequalitySubstitute  (/*@returned@*/ constraint c, constraintList p)
1239 {
1240   llassert(constraint_isDefined(c) );
1241
1242   if (c->ar != GTE)
1243     return c;
1244   
1245   constraintList_elements (p, el)
1246     {
1247       
1248       llassert(constraint_isDefined(el) );
1249       
1250       if ((el->ar == LT )  )
1251         /* if (!constraint_conflict (c, el) ) */ /*@i523 explain this! */
1252            {
1253              constraintExpr  temp2;
1254              
1255              /*@i22*/
1256
1257              if (constraintExpr_same (el->expr, c->expr) )
1258                {
1259                  DPRINTF((message ("inequalitySubstitute Replacing %q in %q with  %q",
1260                                    constraintExpr_print (c->expr),
1261                                    constraint_print (c),
1262                                    constraintExpr_print (el->expr) )
1263                           ));
1264                  temp2   = constraintExpr_copy (el->lexpr);
1265                  constraintExpr_free(c->expr);
1266                  c->expr =  constraintExpr_makeIncConstraintExpr (temp2);
1267
1268                }
1269              
1270            }
1271     }
1272   end_constraintList_elements;
1273
1274   c = constraint_simplify(c);
1275   return c;
1276 }
1277
1278
1279 /* drl7x 7/26/001
1280
1281    THis function is like inequalitySubstitute but it adds the rule
1282    added the rules x >= y &&  y <= b  ===> x >= b
1283     x >= y &&  y < b  ===> x >= b + 1
1284
1285    This is sound but sonce it throws out additional information it should only one used
1286    if we're oring constraints.
1287  */
1288
1289 static constraint  inequalitySubstituteStrong  (/*@returned@*/ constraint c, constraintList p)
1290 {
1291   DPRINTF (( message ("inequalitySubstituteStrong examining substituting for %q", constraint_print(c) ) ));      
1292
1293   llassert(constraint_isDefined(c) );
1294
1295   if (! (constraint_isDefined(c) ) )
1296   {
1297     return c;
1298   }
1299   
1300   if (c->ar != GTE)
1301     return c;
1302   
1303   DPRINTF (( message ("inequalitySubstituteStrong examining substituting for %q with %q",
1304                       constraint_print(c), constraintList_print(p) ) ));      
1305   constraintList_elements (p, el)
1306     {
1307       
1308       DPRINTF (( message ("inequalitySubstituteStrong examining substituting %s on %s", constraint_print(el), constraint_print(c) ) ));      
1309
1310       llassert(constraint_isDefined(el) );
1311       if ((el->ar == LT ) ||  (el->ar == LTE )  )
1312         /* if (!constraint_conflict (c, el) ) */ /*@i523@*/
1313            {
1314              constraintExpr  temp2;
1315              
1316              /*@i22*/
1317
1318              if (constraintExpr_same (el->lexpr, c->expr) )
1319                {
1320                  DPRINTF((message ("inequalitySubstitute Replacing %s in %s with  %s",
1321                                    constraintExpr_print (c->expr),
1322                                    constraint_print (c),
1323                                    constraintExpr_print (el->expr) )
1324                           ));
1325                  temp2   = constraintExpr_copy (el->expr);
1326                  constraintExpr_free(c->expr);
1327                  if ((el->ar == LTE ) )
1328                    {
1329                      c->expr = temp2;
1330                    }
1331                  else
1332                    {
1333                      c->expr =  constraintExpr_makeIncConstraintExpr (temp2);
1334                    }
1335                }
1336              
1337            }
1338     }
1339   end_constraintList_elements;
1340
1341   c = constraint_simplify(c);
1342   return c;
1343 }
1344
1345
1346 /* This function performs substitutions based on the rule:
1347    for a constraint of the form expr1 >= expr2;   a < b =>
1348    a = b -1 for all a in expr1.  This will work in most cases.
1349
1350    Like inequalitySubstitute we're throwing away some information
1351 */
1352
1353 static constraint  inequalitySubstituteUnsound  (/*@returned@*/ constraint c, constraintList p)
1354 {
1355   DPRINTF (( message ("Doing inequalitySubstituteUnsound " ) ));
1356
1357     llassert(constraint_isDefined(c) );
1358   
1359   if (c->ar != GTE)
1360     return c;
1361   
1362   constraintList_elements (p, el)
1363     {
1364
1365       llassert(constraint_isDefined(el) );
1366
1367       DPRINTF (( message ("inequalitySubstituteUnsound examining substituting %s on %s", constraint_print(el), constraint_print(c) ) ));      
1368        if (( el->ar == LTE) || (el->ar == LT) )
1369          /* if (!constraint_conflict (c, el) ) */ /*@i532@*/
1370            {
1371              constraintExpr  temp2;
1372
1373              temp2   = constraintExpr_copy (el->expr);
1374              
1375              if (el->ar == LT)
1376                temp2  =  constraintExpr_makeDecConstraintExpr (temp2);
1377              
1378              DPRINTF((message ("Replacing %s in %s with  %s",
1379                                constraintExpr_print (el->lexpr),
1380                                constraintExpr_print (c->lexpr),
1381                                constraintExpr_print (temp2) ) ));
1382              
1383              c->lexpr = constraintExpr_searchandreplace (c->lexpr, el->lexpr, temp2);
1384              constraintExpr_free(temp2);
1385            }
1386     }
1387   end_constraintList_elements;
1388
1389   c = constraint_simplify(c);
1390   return c;
1391 }
1392
1393 /*@only@*/ constraint constraint_substitute (/*@observer@*/ /*@temp@*/ constraint c, constraintList p)
1394 {
1395   constraint ret;
1396
1397   ret = constraint_copy(c);
1398   constraintList_elements (p, el)
1399     {
1400       llassert(constraint_isDefined(el) );
1401        if ( el->ar == EQ)
1402          if (!constraint_conflict (ret, el) )
1403
1404            {
1405              constraint temp;
1406              
1407              temp = constraint_copy(el);
1408              
1409              temp = constraint_adjust(temp, ret);
1410
1411              llassert(constraint_isDefined(temp) );
1412
1413              
1414              DPRINTF((message ("constraint_substitute :: Substituting in %s using %s",
1415                                constraint_print (ret), constraint_print (temp)
1416                                ) ) );
1417                                
1418           
1419              ret = constraint_searchandreplace (ret, temp->lexpr, temp->expr);
1420              DPRINTF(( message (" constraint_substitute :: The new constraint is %s", constraint_print (ret) ) ));
1421              constraint_free(temp);
1422            }
1423     }
1424   end_constraintList_elements;
1425
1426   ret = constraint_simplify(ret);
1427
1428   DPRINTF(( message (" constraint_substitute :: The final new constraint is %s", constraint_print (ret) ) ));
1429
1430   return ret;
1431 }
1432
1433
1434 /*@only@*/ constraintList constraintList_substituteFreeTarget (/*@only@*/ constraintList target, /*@observer@*/ constraintList subList)
1435 {
1436 constraintList ret;
1437
1438 ret = constraintList_substitute (target, subList);
1439
1440 constraintList_free(target);
1441
1442 return ret;
1443 }
1444
1445 /* we try to do substitutions on each constraint in target using the constraint in sublist*/
1446
1447 /*@only@*/ constraintList constraintList_substitute (constraintList target,/*2observer@*/  constraintList subList)
1448 {
1449
1450   constraintList ret;
1451
1452   ret = constraintList_makeNew();
1453   
1454   constraintList_elements(target, el)
1455   { 
1456     constraint temp;
1457     /* drl possible problem : warning make sure that a side effect is not expected */
1458
1459     temp = constraint_substitute(el, subList);
1460     ret = constraintList_add (ret, temp);
1461   }
1462   end_constraintList_elements;
1463
1464   return ret;
1465 }
1466
1467 static constraint constraint_solve (/*@returned@*/ constraint c)
1468 {
1469
1470   llassert(constraint_isDefined(c) );
1471
1472   DPRINTF((message ("Solving %s\n", constraint_print(c) ) ) );
1473   c->expr = constraintExpr_solveBinaryExpr (c->lexpr, c->expr);
1474   DPRINTF((message ("Solved and got %s\n", constraint_print(c) ) ) );
1475
1476   return c;
1477 }
1478
1479 static arithType flipAr (arithType ar)
1480 {
1481   switch (ar)
1482     {
1483     case LT:
1484       return GT;
1485     case LTE:
1486       return GTE;
1487     case EQ:
1488       return EQ;
1489     case GT:
1490       return LT;
1491     case GTE:
1492       return LTE;
1493     default:
1494       llcontbug (message("unexpected value: case not handled"));
1495     }
1496   BADEXIT;
1497 }
1498
1499 static constraint  constraint_swapLeftRight (/*@returned@*/ constraint c)
1500 {
1501   constraintExpr temp;
1502
1503   llassert(constraint_isDefined(c) );
1504
1505   c->ar = flipAr (c->ar);
1506   temp = c->lexpr;
1507   c->lexpr = c->expr;
1508   c->expr = temp;
1509   DPRINTF(("Swaped left and right sides of constraint"));
1510   return c;
1511 }
1512
1513
1514
1515 constraint constraint_simplify ( /*@returned@*/ constraint c)
1516 {
1517   
1518   llassert(constraint_isDefined(c) );
1519         
1520   DPRINTF(( message("constraint_simplify on %q ", constraint_print(c) ) ));
1521
1522   if (constraint_tooDeep(c))
1523     {
1524         DPRINTF(( message("constraint_simplify: constraint to complex aborting %q ", constraint_print(c) ) ));
1525       return c;
1526
1527     }
1528   
1529   c->lexpr = constraintExpr_simplify (c->lexpr);
1530   c->expr  = constraintExpr_simplify (c->expr);
1531
1532   if (constraintExpr_isBinaryExpr (c->lexpr) )
1533     {
1534       c = constraint_solve (c);
1535       
1536       c->lexpr = constraintExpr_simplify (c->lexpr);
1537       c->expr  = constraintExpr_simplify (c->expr);
1538     }
1539   
1540   if (constraintExpr_isLit(c->lexpr) && (!constraintExpr_isLit(c->expr) ) )
1541     {
1542       c = constraint_swapLeftRight(c);
1543       /*I don't think this will be an infinate loop*/
1544       c = constraint_simplify(c);
1545     }
1546
1547   DPRINTF(( message("constraint_simplify returning  %q ", constraint_print(c) ) ));
1548
1549   return c;
1550 }
1551
1552
1553
1554
1555 /* returns true  if fileloc for term1 is closer to file for term2 than term3*/
1556
1557 bool fileloc_closer (fileloc  loc1, fileloc  loc2, fileloc  loc3)
1558 {
1559
1560   if  (!fileloc_isDefined (loc1) )
1561     return FALSE;
1562
1563   if  (!fileloc_isDefined (loc2) )
1564     return FALSE;
1565
1566   if  (!fileloc_isDefined (loc3) )
1567     return TRUE;
1568
1569   
1570   
1571   
1572   if (fileloc_equal (loc2, loc3) )
1573     return FALSE;
1574
1575   if (fileloc_equal (loc1, loc2) )
1576     return TRUE;
1577
1578     if (fileloc_equal (loc1, loc3) )
1579     return FALSE;
1580
1581    if ( fileloc_lessthan (loc1, loc2) )
1582      {
1583        if (fileloc_lessthan (loc2, loc3) )
1584          {
1585            llassert (fileloc_lessthan (loc1, loc3) );
1586            return TRUE;
1587          }
1588        else
1589          {
1590            return FALSE;
1591          }
1592      }
1593
1594    if ( !fileloc_lessthan (loc1, loc2) )
1595      {
1596        if (!fileloc_lessthan (loc2, loc3) )
1597          {
1598            llassert (!fileloc_lessthan (loc1, loc3) );
1599            return TRUE;
1600          }
1601        else
1602          {
1603            return FALSE;
1604          }
1605      }
1606
1607    llassert(FALSE);
1608    return FALSE;
1609 }
1610
1611
This page took 0.172746 seconds and 5 git commands to generate.