Program: 50107
Project: 50107
Buggy source:
/** 
 * Attempts to evaluate the given declaration specifier
 */
private TypeDeclaration evalDeclSpecifier(IASTDeclSpecifier declSpecifier) throws DOMException {
  if (declSpecifier instanceof IASTCompositeTypeSpecifier) {
    IASTCompositeTypeSpecifier compositeTypeSpecifier=(IASTCompositeTypeSpecifier)declSpecifier;
    print("String_Node_Str");
    TypeDeclaration tyd=ast.newTypeDeclaration();
    CompositeInfo info=compositeMap.get(getQualifiedPart(compositeTypeSpecifier.getName()));
    if (info != null) {
      tyd.modifiers().add(ast.newModifier(ModifierKeyword.STATIC_KEYWORD));
      info.tyd.bodyDeclarations().add(tyd);
    }
 else {
      unit.types().add(tyd);
    }
    info=new CompositeInfo(tyd);
    if (compositeTypeSpecifier.getKey() == IASTCompositeTypeSpecifier.k_union) {
      Javadoc jd=ast.newJavadoc();
      TagElement tg=ast.newTagElement();
      tg.setTagName("String_Node_Str");
      jd.tags().add(tg);
      tyd.setJavadoc(jd);
    }
    String finalName;
    if (getSimpleName(compositeTypeSpecifier.getName()).equals("String_Node_Str")) {
      finalName="String_Node_Str" + m_anonClassCount;
      compositeMap.put(getCompleteName(compositeTypeSpecifier.getName()),info);
      m_anonClassCount++;
    }
 else {
      finalName=getSimpleName(compositeTypeSpecifier.getName());
      compositeMap.put(getCompleteName(compositeTypeSpecifier.getName()),info);
    }
    info.declSpecifier=declSpecifier;
    findSpecialMethods(declSpecifier,info);
    tyd.setName(ast.newSimpleName(finalName));
    tyd.typeParameters().addAll(templateParamsQueue);
    templateParamsQueue.clear();
    ParameterizedType type=ast.newParameterizedType(jast.newType("String_Node_Str"));
    type.typeArguments().add(jast.newType(finalName));
    tyd.superInterfaceTypes().add(type);
    if (compositeTypeSpecifier instanceof ICPPASTCompositeTypeSpecifier) {
      ICPPASTCompositeTypeSpecifier cppCompositeTypeSpecifier=(ICPPASTCompositeTypeSpecifier)compositeTypeSpecifier;
      if (cppCompositeTypeSpecifier.getBaseSpecifiers() != null && cppCompositeTypeSpecifier.getBaseSpecifiers().length != 0) {
        tyd.setSuperclassType(jast.newType(getSimpleName(cppCompositeTypeSpecifier.getBaseSpecifiers()[0].getName())));
      }
    }
    for (    IASTDeclaration decl : compositeTypeSpecifier.getMembers()) {
      evalDeclaration(decl);
    }
    if (!info.hasCtor) {
      MethodDeclaration meth=jast.newMethodDecl().returnType(null).name(finalName).setCtor(true).toAST();
      Block blk=ast.newBlock();
      meth.setBody(blk);
      List<FieldInfo> fields=collectFieldsForClass(declSpecifier);
      generateCtorStatements(fields,meth);
      tyd.bodyDeclarations().add(meth);
    }
    if (!info.hasDtor) {
      MethodDeclaration meth=jast.newMethodDecl().returnType(ast.newPrimitiveType(PrimitiveType.VOID)).name("String_Node_Str").toAST();
      meth.modifiers().add(ast.newModifier(ModifierKeyword.PUBLIC_KEYWORD));
      Block blk=ast.newBlock();
      meth.setBody(blk);
      List<FieldInfo> fields=collectFieldsForClass(declSpecifier);
      generateDtorStatements(fields,meth);
      tyd.bodyDeclarations().add(meth);
    }
    if (!info.hasAssign) {
      MethodDeclaration meth=jast.newMethodDecl().returnType(jast.newType(finalName)).name("String_Node_Str").toAST();
      meth.modifiers().add(ast.newModifier(ModifierKeyword.PUBLIC_KEYWORD));
      SingleVariableDeclaration var=ast.newSingleVariableDeclaration();
      var.setType(jast.newType(finalName));
      var.setName(ast.newSimpleName("String_Node_Str"));
      meth.parameters().add(var);
      Block blk=ast.newBlock();
      meth.setBody(blk);
      List<FieldInfo> fields=collectFieldsForClass(declSpecifier);
      if (!fields.isEmpty()) {
        IfStatement ifStmt=ast.newIfStatement();
        InfixExpression condition=ast.newInfixExpression();
        condition.setLeftOperand(ast.newSimpleName("String_Node_Str"));
        condition.setRightOperand(ast.newThisExpression());
        condition.setOperator(InfixExpression.Operator.NOT_EQUALS);
        ifStmt.setExpression(condition);
        Block ifBlock=ast.newBlock();
        ifStmt.setThenStatement(ifBlock);
        blk.statements().add(ifStmt);
        for (        FieldInfo fieldInfo : fields) {
          print(fieldInfo.field.getName());
          if (fieldInfo.init != null && getTypeEnum(fieldInfo.field.getType()) != TypeEnum.ARRAY) {
            QualifiedName qual=ast.newQualifiedName(ast.newSimpleName("String_Node_Str"),ast.newSimpleName(fieldInfo.field.getName()));
            MethodInvocation meth2=jast.newMethod().on(ast.newSimpleName(fieldInfo.field.getName())).call("String_Node_Str").with(qual).toAST();
            ifBlock.statements().add(ast.newExpressionStatement(meth2));
          }
 else           if (getTypeEnum(fieldInfo.field.getType()) == TypeEnum.ARRAY && getTypeEnum(getArrayBaseType(fieldInfo.field.getType())) == TypeEnum.OTHER) {
            QualifiedName qual=ast.newQualifiedName(ast.newSimpleName("String_Node_Str"),ast.newSimpleName(fieldInfo.field.getName()));
            MethodInvocation meth3=jast.newMethod().on("String_Node_Str").call("String_Node_Str").with(qual).toAST();
            CastExpression cast=ast.newCastExpression();
            cast.setExpression(meth3);
            cast.setType(cppToJavaType(fieldInfo.field.getType()));
            Assignment assign=jast.newAssign().left(ast.newSimpleName(fieldInfo.field.getName())).right(cast).op(Assignment.Operator.ASSIGN).toAST();
            ifBlock.statements().add(ast.newExpressionStatement(assign));
          }
 else           if (getTypeEnum(fieldInfo.field.getType()) == TypeEnum.ARRAY) {
            QualifiedName qual=ast.newQualifiedName(ast.newSimpleName("String_Node_Str"),ast.newSimpleName(fieldInfo.field.getName()));
            MethodInvocation meth3=jast.newMethod().on(qual).call("String_Node_Str").toAST();
            CastExpression cast=ast.newCastExpression();
            cast.setExpression(meth3);
            cast.setType(cppToJavaType(fieldInfo.field.getType()));
            Assignment assign=jast.newAssign().left(ast.newSimpleName(fieldInfo.field.getName())).right(cast).op(Assignment.Operator.ASSIGN).toAST();
            ifBlock.statements().add(ast.newExpressionStatement(assign));
          }
 else {
            QualifiedName qual=ast.newQualifiedName(ast.newSimpleName("String_Node_Str"),ast.newSimpleName(fieldInfo.field.getName()));
            Assignment assign=jast.newAssign().left(ast.newSimpleName(fieldInfo.field.getName())).right(qual).op(Assignment.Operator.ASSIGN).toAST();
            ifBlock.statements().add(ast.newExpressionStatement(assign));
          }
        }
      }
      blk.statements().add(jast.newReturn(ast.newThisExpression()));
      tyd.bodyDeclarations().add(meth);
    }
    MethodDeclaration meth=jast.newMethodDecl().returnType(jast.newType(finalName)).name("String_Node_Str").toAST();
    meth.modifiers().add(ast.newModifier(ModifierKeyword.PUBLIC_KEYWORD));
    ClassInstanceCreation create=ast.newClassInstanceCreation();
    create.setType(jast.newType(finalName));
    create.arguments().add(ast.newThisExpression());
    ReturnStatement stmt=jast.newReturn(create);
    Block blk=ast.newBlock();
    blk.statements().add(stmt);
    meth.setBody(blk);
    tyd.bodyDeclarations().add(meth);
  }
 else   if (declSpecifier instanceof IASTElaboratedTypeSpecifier) {
    IASTElaboratedTypeSpecifier elaboratedTypeSpecifier=(IASTElaboratedTypeSpecifier)declSpecifier;
    print("String_Node_Str" + elaboratedTypeSpecifier.getRawSignature());
    getSimpleName(elaboratedTypeSpecifier.getName());
    if (declSpecifier instanceof ICPPASTElaboratedTypeSpecifier) {
      print("String_Node_Str");
    }
  }
 else   if (declSpecifier instanceof IASTEnumerationSpecifier) {
    IASTEnumerationSpecifier enumerationSpecifier=(IASTEnumerationSpecifier)declSpecifier;
    generateEnumeration(enumerationSpecifier);
  }
 else   if (declSpecifier instanceof IASTNamedTypeSpecifier) {
    IASTNamedTypeSpecifier namedTypeSpecifier=(IASTNamedTypeSpecifier)declSpecifier;
    print("String_Node_Str");
    getSimpleName(namedTypeSpecifier.getName());
    if (declSpecifier instanceof ICPPASTNamedTypeSpecifier) {
      print("String_Node_Str");
    }
  }
 else   if (declSpecifier instanceof IASTSimpleDeclSpecifier) {
    IASTSimpleDeclSpecifier simple=(IASTSimpleDeclSpecifier)declSpecifier;
    print("String_Node_Str");
    if (declSpecifier instanceof ICPPASTSimpleDeclSpecifier) {
      print("String_Node_Str");
    }
    evaluateSimpleType(simple.getType(),simple.isShort(),simple.isLong(),simple.isUnsigned());
  }
 else   if (declSpecifier instanceof ICASTDeclSpecifier) {
    print("String_Node_Str");
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Attempts to evaluate the given declaration specifier
 */
private TypeDeclaration evalDeclSpecifier(IASTDeclSpecifier declSpecifier) throws DOMException {
  if (declSpecifier instanceof IASTCompositeTypeSpecifier) {
    IASTCompositeTypeSpecifier compositeTypeSpecifier=(IASTCompositeTypeSpecifier)declSpecifier;
    print("String_Node_Str");
    TypeDeclaration tyd=ast.newTypeDeclaration();
    CompositeInfo info=compositeMap.get(getQualifiedPart(compositeTypeSpecifier.getName()));
    if (info != null) {
      tyd.modifiers().add(ast.newModifier(ModifierKeyword.STATIC_KEYWORD));
      info.tyd.bodyDeclarations().add(tyd);
    }
 else {
      unit.types().add(tyd);
    }
    info=new CompositeInfo(tyd);
    if (compositeTypeSpecifier.getKey() == IASTCompositeTypeSpecifier.k_union) {
      Javadoc jd=ast.newJavadoc();
      TagElement tg=ast.newTagElement();
      tg.setTagName("String_Node_Str");
      jd.tags().add(tg);
      tyd.setJavadoc(jd);
    }
    String finalName;
    if (getSimpleName(compositeTypeSpecifier.getName()).equals("String_Node_Str")) {
      finalName="String_Node_Str" + m_anonClassCount;
      compositeMap.put(getCompleteName(compositeTypeSpecifier.getName()),info);
      m_anonClassCount++;
    }
 else {
      finalName=getSimpleName(compositeTypeSpecifier.getName());
      compositeMap.put(getCompleteName(compositeTypeSpecifier.getName()),info);
    }
    info.declSpecifier=declSpecifier;
    findSpecialMethods(declSpecifier,info);
    tyd.setName(ast.newSimpleName(finalName));
    tyd.typeParameters().addAll(templateParamsQueue);
    templateParamsQueue.clear();
    ParameterizedType type=ast.newParameterizedType(jast.newType("String_Node_Str"));
    type.typeArguments().add(jast.newType(finalName));
    tyd.superInterfaceTypes().add(type);
    if (compositeTypeSpecifier instanceof ICPPASTCompositeTypeSpecifier) {
      ICPPASTCompositeTypeSpecifier cppCompositeTypeSpecifier=(ICPPASTCompositeTypeSpecifier)compositeTypeSpecifier;
      if (cppCompositeTypeSpecifier.getBaseSpecifiers() != null && cppCompositeTypeSpecifier.getBaseSpecifiers().length != 0) {
        tyd.setSuperclassType(jast.newType(getSimpleName(cppCompositeTypeSpecifier.getBaseSpecifiers()[0].getName())));
      }
    }
    for (    IASTDeclaration decl : compositeTypeSpecifier.getMembers()) {
      evalDeclaration(decl);
    }
    if (!info.hasCtor) {
      MethodDeclaration meth=jast.newMethodDecl().returnType(null).name(finalName).setCtor(true).toAST();
      Block blk=ast.newBlock();
      meth.setBody(blk);
      List<FieldInfo> fields=collectFieldsForClass(declSpecifier);
      generateCtorStatements(fields,meth);
      tyd.bodyDeclarations().add(meth);
    }
    if (!info.hasDtor) {
      MethodDeclaration meth=jast.newMethodDecl().returnType(ast.newPrimitiveType(PrimitiveType.VOID)).name("String_Node_Str").toAST();
      meth.modifiers().add(ast.newModifier(ModifierKeyword.PUBLIC_KEYWORD));
      Block blk=ast.newBlock();
      meth.setBody(blk);
      List<FieldInfo> fields=collectFieldsForClass(declSpecifier);
      generateDtorStatements(fields,meth);
      tyd.bodyDeclarations().add(meth);
    }
    if (!info.hasAssign) {
      MethodDeclaration meth=jast.newMethodDecl().returnType(jast.newType(finalName)).name("String_Node_Str").toAST();
      meth.modifiers().add(ast.newModifier(ModifierKeyword.PUBLIC_KEYWORD));
      SingleVariableDeclaration var=ast.newSingleVariableDeclaration();
      var.setType(jast.newType(finalName));
      var.setName(ast.newSimpleName("String_Node_Str"));
      meth.parameters().add(var);
      Block blk=ast.newBlock();
      meth.setBody(blk);
      List<FieldInfo> fields=collectFieldsForClass(declSpecifier);
      if (!fields.isEmpty()) {
        IfStatement ifStmt=ast.newIfStatement();
        InfixExpression condition=ast.newInfixExpression();
        condition.setLeftOperand(ast.newSimpleName("String_Node_Str"));
        condition.setRightOperand(ast.newThisExpression());
        condition.setOperator(InfixExpression.Operator.NOT_EQUALS);
        ifStmt.setExpression(condition);
        Block ifBlock=ast.newBlock();
        ifStmt.setThenStatement(ifBlock);
        blk.statements().add(ifStmt);
        for (        FieldInfo fieldInfo : fields) {
          print(fieldInfo.field.getName());
          if (fieldInfo.init != null && getTypeEnum(fieldInfo.field.getType()) != TypeEnum.ARRAY) {
            QualifiedName qual=ast.newQualifiedName(ast.newSimpleName("String_Node_Str"),ast.newSimpleName(fieldInfo.field.getName()));
            MethodInvocation meth2=jast.newMethod().on(ast.newSimpleName(fieldInfo.field.getName())).call("String_Node_Str").with(qual).toAST();
            ifBlock.statements().add(ast.newExpressionStatement(meth2));
          }
 else           if (getTypeEnum(fieldInfo.field.getType()) == TypeEnum.ARRAY && getTypeEnum(getArrayBaseType(fieldInfo.field.getType())) == TypeEnum.OTHER) {
            QualifiedName qual=ast.newQualifiedName(ast.newSimpleName("String_Node_Str"),ast.newSimpleName(fieldInfo.field.getName()));
            MethodInvocation meth3=jast.newMethod().on("String_Node_Str").call("String_Node_Str").with(ast.newSimpleName(fieldInfo.field.getName())).with(qual).toAST();
            ifBlock.statements().add(ast.newExpressionStatement(meth3));
          }
 else           if (getTypeEnum(fieldInfo.field.getType()) == TypeEnum.ARRAY) {
            QualifiedName qual=ast.newQualifiedName(ast.newSimpleName("String_Node_Str"),ast.newSimpleName(fieldInfo.field.getName()));
            String methodName="String_Node_Str";
            if (getArraySizeExpressions(fieldInfo.field.getType()).size() > 1)             methodName="String_Node_Str";
            MethodInvocation meth3=jast.newMethod().on("String_Node_Str").call(methodName).with(ast.newSimpleName(fieldInfo.field.getName())).with(qual).toAST();
            ifBlock.statements().add(ast.newExpressionStatement(meth3));
          }
 else {
            QualifiedName qual=ast.newQualifiedName(ast.newSimpleName("String_Node_Str"),ast.newSimpleName(fieldInfo.field.getName()));
            Assignment assign=jast.newAssign().left(ast.newSimpleName(fieldInfo.field.getName())).right(qual).op(Assignment.Operator.ASSIGN).toAST();
            ifBlock.statements().add(ast.newExpressionStatement(assign));
          }
        }
      }
      blk.statements().add(jast.newReturn(ast.newThisExpression()));
      tyd.bodyDeclarations().add(meth);
    }
    MethodDeclaration meth=jast.newMethodDecl().returnType(jast.newType(finalName)).name("String_Node_Str").toAST();
    meth.modifiers().add(ast.newModifier(ModifierKeyword.PUBLIC_KEYWORD));
    ClassInstanceCreation create=ast.newClassInstanceCreation();
    create.setType(jast.newType(finalName));
    create.arguments().add(ast.newThisExpression());
    ReturnStatement stmt=jast.newReturn(create);
    Block blk=ast.newBlock();
    blk.statements().add(stmt);
    meth.setBody(blk);
    tyd.bodyDeclarations().add(meth);
  }
 else   if (declSpecifier instanceof IASTElaboratedTypeSpecifier) {
    IASTElaboratedTypeSpecifier elaboratedTypeSpecifier=(IASTElaboratedTypeSpecifier)declSpecifier;
    print("String_Node_Str" + elaboratedTypeSpecifier.getRawSignature());
    getSimpleName(elaboratedTypeSpecifier.getName());
    if (declSpecifier instanceof ICPPASTElaboratedTypeSpecifier) {
      print("String_Node_Str");
    }
  }
 else   if (declSpecifier instanceof IASTEnumerationSpecifier) {
    IASTEnumerationSpecifier enumerationSpecifier=(IASTEnumerationSpecifier)declSpecifier;
    generateEnumeration(enumerationSpecifier);
  }
 else   if (declSpecifier instanceof IASTNamedTypeSpecifier) {
    IASTNamedTypeSpecifier namedTypeSpecifier=(IASTNamedTypeSpecifier)declSpecifier;
    print("String_Node_Str");
    getSimpleName(namedTypeSpecifier.getName());
    if (declSpecifier instanceof ICPPASTNamedTypeSpecifier) {
      print("String_Node_Str");
    }
  }
 else   if (declSpecifier instanceof IASTSimpleDeclSpecifier) {
    IASTSimpleDeclSpecifier simple=(IASTSimpleDeclSpecifier)declSpecifier;
    print("String_Node_Str");
    if (declSpecifier instanceof ICPPASTSimpleDeclSpecifier) {
      print("String_Node_Str");
    }
    evaluateSimpleType(simple.getType(),simple.isShort(),simple.isLong(),simple.isUnsigned());
  }
 else   if (declSpecifier instanceof ICASTDeclSpecifier) {
    print("String_Node_Str");
  }
  return null;
}