[Prev][Next][Index]

Re: Bug in SgExpression::IsSymbolInExpression()?



> 	I've been trying to use
> SgExpression::IsSymbolInExpression() with  no
> success. Maybe I'm doing something wrong, but I don't
> know what it is. 

> 


Diego, 

sorry that you had to wait so long. I've been _very_ busy.
Here is the fix:

in lib/newsrc/low_level.c there is a definition of function:
PTR_LLND LibIsSymbolInExpression(exprold, symb)

add the two lines (marked below with /* BW */), recompile and try  
your code again. The IsSymbolInExpression method should work  
correctly. The only problem is that I am not sure if something else  
is not going to break as a result of the fix. I've done some testing  
but probably not enough. If you notice some funny changes in the  
behavior of the rest of your code, take the "fix" out (and let me  
know). I'll do some more testing soon and I'll let you know if I find  
any problems.    

                           --Beata


PTR_LLND LibIsSymbolInExpression(exprold, symb)
     PTR_SYMB symb;
     PTR_LLND exprold;
{
  PTR_LLND pt =NULL;
  if (!exprold)
    return NULL;

  if(IsRefToSymb(exprold,symb)) /* BW */
    return exprold;     /* BW */

  if (IsRefToSymb(NODE_OPERAND0(exprold),symb))
    return NODE_OPERAND0(exprold);
  else
    pt = LibIsSymbolInExpression(NODE_OPERAND0(exprold), symb);
  if (pt)
    return pt;

  if (IsRefToSymb(NODE_OPERAND1(exprold),symb))
    return NODE_OPERAND1(exprold) ;
  else
    pt = LibIsSymbolInExpression(NODE_OPERAND1(exprold), symb);

  return pt;
}