Program: 74165
Project: 74165
Buggy source:
/** 
 * Generate variable declarations for inputs and outputs and parameters. Append the declarations to the given string buffer.
 * @return code The generated code.
 * @exception IllegalActionException If the adapter class for the modeldirector cannot be found.
 */
public String generateVariableDeclaration() throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  String name=CodeGeneratorAdapterStrategy.generateName(getComponent());
  String referencedParameterDeclaration=_generateReferencedParameterDeclaration();
  if (referencedParameterDeclaration.length() > 1) {
    code.append(_eol + _codeGenerator.comment(name + "String_Node_Str"));
    code.append(referencedParameterDeclaration);
  }
  Director director=getDirectorAdapter();
  String inputVariableDeclaration=director.generateInputVariableDeclaration();
  if (inputVariableDeclaration.length() > 1) {
    code.append(_eol + _codeGenerator.comment(name + "String_Node_Str"));
    code.append(inputVariableDeclaration);
  }
  String outputVariableDeclaration=director.generateOutputVariableDeclaration();
  if (outputVariableDeclaration.length() > 1) {
    code.append(_eol + _codeGenerator.comment(name + "String_Node_Str"));
    code.append(outputVariableDeclaration);
  }
  String typeConvertVariableDeclaration=_generateTypeConvertVariableDeclaration();
  if (typeConvertVariableDeclaration.length() > 1) {
    code.append(_eol + _codeGenerator.comment(name + "String_Node_Str"));
    code.append(typeConvertVariableDeclaration);
  }
  return processCode(code.toString());
}

Fixed version (ground truth):
/** 
 * Generate variable declarations for inputs and outputs and parameters. Append the declarations to the given string buffer.
 * @return code The generated code.
 * @exception IllegalActionException If the adapter class for the modeldirector cannot be found.
 */
public String generateVariableDeclaration() throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  String name=CodeGeneratorAdapterStrategy.generateName(getComponent());
  String referencedParameterDeclaration=_generateReferencedParameterDeclaration();
  if (referencedParameterDeclaration.length() > 1) {
    code.append(_eol + _codeGenerator.comment(name + "String_Node_Str"));
    code.append(referencedParameterDeclaration);
  }
  Director director=getDirectorAdapter();
  String inputVariableDeclaration=director.generateInputVariableDeclaration(_adapter);
  if (inputVariableDeclaration.length() > 1) {
    code.append(_eol + _codeGenerator.comment(name + "String_Node_Str"));
    code.append(inputVariableDeclaration);
  }
  String outputVariableDeclaration=director.generateOutputVariableDeclaration(_adapter);
  if (outputVariableDeclaration.length() > 1) {
    code.append(_eol + _codeGenerator.comment(name + "String_Node_Str"));
    code.append(outputVariableDeclaration);
  }
  String typeConvertVariableDeclaration=_generateTypeConvertVariableDeclaration();
  if (typeConvertVariableDeclaration.length() > 1) {
    code.append(_eol + _codeGenerator.comment(name + "String_Node_Str"));
    code.append(typeConvertVariableDeclaration);
  }
  return processCode(code.toString());
}