Program: 75511
Project: 75511
Buggy source:
private void _analyzeAllVariables(Entity model) throws IllegalActionException {
  Set notTestedSet=new HashSet();
  Set testedSet=new HashSet();
  Set notConstants=new HashSet();
  List variableList=model.attributeList(Variable.class);
  notTestedSet.addAll(variableList);
  PtParser parser=new PtParser();
  ParseTreeFreeVariableCollector collector=new ParseTreeFreeVariableCollector();
  boolean doneSomething=true;
  while (doneSomething) {
    doneSomething=false;
    while (!notTestedSet.isEmpty()) {
      Variable variable=(Variable)notTestedSet.iterator().next();
      notTestedSet.remove(variable);
      boolean isNotConstant=false;
      if (_notConstantVariableSet.contains(variable)) {
        isNotConstant=true;
      }
 else {
        String expression=variable.getExpression();
        try {
          ASTPtRootNode root=parser.generateParseTree(expression);
          Set freeVarNames=new HashSet(collector.collectFreeVariables(root));
          for (Iterator names=freeVarNames.iterator(); names.hasNext() && !isNotConstant; ) {
            String name=(String)names.next();
            Variable scopeVariable=ModelScope.getScopedVariable(variable,variable,name);
            if (scopeVariable == null || _notConstantVariableSet.contains(scopeVariable)) {
              isNotConstant=true;
            }
          }
        }
 catch (        IllegalActionException ex) {
          isNotConstant=true;
        }
      }
      if (isNotConstant) {
        notConstants.add(variable.getName());
        _notConstantVariableSet.add(variable);
        doneSomething=true;
        isNotConstant=true;
      }
 else {
        testedSet.add(variable);
      }
    }
    notTestedSet.addAll(testedSet);
    testedSet.clear();
  }
  _entityToNotConstVariableSet.put(model,notConstants);
  Set constants=new HashSet();
  for (Iterator variables=variableList.iterator(); variables.hasNext(); ) {
    constants.add(((Variable)variables.next()).getName());
    constants.removeAll(notConstants);
  }
  _entityToConstVariableSet.put(model,constants);
  if (model instanceof CompositeEntity) {
    for (Iterator entities=((CompositeEntity)model).entityList().iterator(); entities.hasNext(); ) {
      Entity entity=(Entity)entities.next();
      _analyzeAllVariables(entity);
    }
  }
}

Fixed version (ground truth):
private void _analyzeAllVariables(Entity model) throws IllegalActionException {
  Set notTestedSet=new HashSet();
  Set testedSet=new HashSet();
  Set notConstants=new HashSet();
  List variableList=model.attributeList(Variable.class);
  notTestedSet.addAll(variableList);
  PtParser parser=new PtParser();
  ParseTreeFreeVariableCollector collector=new ParseTreeFreeVariableCollector();
  boolean doneSomething=true;
  while (doneSomething) {
    doneSomething=false;
    while (!notTestedSet.isEmpty()) {
      Variable variable=(Variable)notTestedSet.iterator().next();
      notTestedSet.remove(variable);
      boolean isNotConstant=false;
      if (_notConstantVariableSet.contains(variable)) {
        isNotConstant=true;
      }
 else {
        String expression=variable.getExpression();
        try {
          ASTPtRootNode root=parser.generateParseTree(expression);
          Set freeVarNames=new HashSet(collector.collectFreeVariables(root));
          for (Iterator names=freeVarNames.iterator(); names.hasNext() && !isNotConstant; ) {
            String name=(String)names.next();
            Variable scopeVariable=ModelScope.getScopedVariable(variable,variable,name);
            if (scopeVariable != null && _notConstantVariableSet.contains(scopeVariable)) {
              isNotConstant=true;
            }
          }
        }
 catch (        IllegalActionException ex) {
          isNotConstant=true;
        }
      }
      if (isNotConstant) {
        notConstants.add(variable.getName());
        _notConstantVariableSet.add(variable);
        doneSomething=true;
        isNotConstant=true;
      }
 else {
        testedSet.add(variable);
      }
    }
    notTestedSet.addAll(testedSet);
    testedSet.clear();
  }
  _entityToNotConstVariableSet.put(model,notConstants);
  Set constants=new HashSet();
  for (Iterator variables=variableList.iterator(); variables.hasNext(); ) {
    constants.add(((Variable)variables.next()).getName());
    constants.removeAll(notConstants);
  }
  _entityToConstVariableSet.put(model,constants);
  if (model instanceof CompositeEntity) {
    for (Iterator entities=((CompositeEntity)model).entityList().iterator(); entities.hasNext(); ) {
      Entity entity=(Entity)entities.next();
      _analyzeAllVariables(entity);
    }
  }
}