Program: 29463
Project: 29463
Buggy source:
/** 
 * Visits a control flow structure like an if, switch or a loop. <p>The main thing this is responsible for is calculating what state to enter after the control flow is complete.
 * @param parent The parent node, each child will be a block representing one of the branches
 * @param children The child blocks. We don't use {@code parent.getChildren()} directly to makeit possible to handle ForNodes using this method.
 * @param overallName The name, for error reporting purposes, to assign to the control flowstructure
 * @param blockNamer A function to provide a name for each child block, the key is the index ofthe block
 * @param willExactlyOneBranchExecuteOnce Whether or not it is guaranteed that exactly onebranch of the structure will execute exactly one time.
 * @param willAtLeastOneBranchExecute Whether or not it is guaranteed that at least one of thebranches will execute (as opposed to no branches executing).
 */
void visitControlFlowStructure(StandaloneNode parent,List<? extends BlockNode> children,String overallName,Function<? super BlockNode,String> blockNamer,boolean willExactlyOneBranchExecuteOnce,boolean willAtLeastOneBranchExecute){
  if (children.isEmpty()) {
    return;
  }
  State startingState=context.getState();
  State endingState=visitBranches(children,blockNamer);
  SourceLocation.Point endPoint=parent.getSourceLocation().getEndPoint();
switch (startingState) {
case AFTER_TAG_NAME_OR_ATTRIBUTE:
case BEFORE_ATTRIBUTE_NAME:
case AFTER_ATTRIBUTE_NAME:
    context.addTagChild(parent);
  if (willAtLeastOneBranchExecute && endingState == State.BEFORE_ATTRIBUTE_NAME) {
    context.setState(State.BEFORE_ATTRIBUTE_NAME,endPoint);
  }
break;
case HTML_TAG_NAME:
errorReporter.report(parent.getSourceLocation(),INVALID_LOCATION_FOR_CONTROL_FLOW,overallName,"String_Node_Str");
context.reset();
context.setState(State.PCDATA,parent.getSourceLocation().getBeginPoint());
break;
case BEFORE_ATTRIBUTE_VALUE:
if (!willExactlyOneBranchExecuteOnce) {
errorReporter.report(parent.getSourceLocation(),CONDITIONAL_BLOCK_ISNT_GUARANTEED_TO_PRODUCE_ONE_ATTRIBUTE_VALUE,overallName);
}
if (willAtLeastOneBranchExecute && endingState == State.UNQUOTED_ATTRIBUTE_VALUE) {
context.addAttributeValuePart(parent);
context.setState(State.UNQUOTED_ATTRIBUTE_VALUE,endPoint);
}
 else {
context.setAttributeValue(parent);
if (willAtLeastOneBranchExecute && endingState == State.BEFORE_ATTRIBUTE_NAME) {
context.setState(State.BEFORE_ATTRIBUTE_NAME,endPoint);
}
}
break;
case UNQUOTED_ATTRIBUTE_VALUE:
case DOUBLE_QUOTED_ATTRIBUTE_VALUE:
case SINGLE_QUOTED_ATTRIBUTE_VALUE:
context.addAttributeValuePart(parent);
break;
case HTML_COMMENT:
case NONE:
case PCDATA:
case RCDATA_SCRIPT:
case RCDATA_STYLE:
case RCDATA_TEXTAREA:
case RCDATA_TITLE:
case XML_DECLARATION:
case CDATA:
case DOUBLE_QUOTED_XML_ATTRIBUTE_VALUE:
case SINGLE_QUOTED_XML_ATTRIBUTE_VALUE:
break;
default :
throw new AssertionError("String_Node_Str" + startingState);
}
}

Fixed version (ground truth):
/** 
 * Visits a control flow structure like an if, switch or a loop. <p>The main thing this is responsible for is calculating what state to enter after the control flow is complete.
 * @param parent The parent node, each child will be a block representing one of the branches
 * @param children The child blocks. We don't use {@code parent.getChildren()} directly to makeit possible to handle ForNodes using this method.
 * @param overallName The name, for error reporting purposes, to assign to the control flowstructure
 * @param blockNamer A function to provide a name for each child block, the key is the index ofthe block
 * @param willExactlyOneBranchExecuteOnce Whether or not it is guaranteed that exactly onebranch of the structure will execute exactly one time.
 * @param willAtLeastOneBranchExecute Whether or not it is guaranteed that at least one of thebranches will execute (as opposed to no branches executing).
 */
void visitControlFlowStructure(StandaloneNode parent,List<? extends BlockNode> children,String overallName,Function<? super BlockNode,String> blockNamer,boolean willExactlyOneBranchExecuteOnce,boolean willAtLeastOneBranchExecute){
  if (children.isEmpty()) {
    return;
  }
  State startingState=context.getState();
  State endingState=visitBranches(children,blockNamer);
  SourceLocation.Point endPoint=parent.getSourceLocation().getEndPoint();
switch (startingState) {
case AFTER_TAG_NAME_OR_ATTRIBUTE:
case BEFORE_ATTRIBUTE_NAME:
case AFTER_ATTRIBUTE_NAME:
    context.addTagChild(parent);
  if (willAtLeastOneBranchExecute && endingState == State.BEFORE_ATTRIBUTE_NAME) {
    context.setState(State.BEFORE_ATTRIBUTE_NAME,endPoint);
  }
break;
case HTML_TAG_NAME:
errorReporter.report(parent.getSourceLocation(),INVALID_LOCATION_FOR_CONTROL_FLOW,overallName,"String_Node_Str");
throw new AbortParsingBlockError();
case BEFORE_ATTRIBUTE_VALUE:
if (!willExactlyOneBranchExecuteOnce) {
errorReporter.report(parent.getSourceLocation(),CONDITIONAL_BLOCK_ISNT_GUARANTEED_TO_PRODUCE_ONE_ATTRIBUTE_VALUE,overallName);
}
if (willAtLeastOneBranchExecute && endingState == State.UNQUOTED_ATTRIBUTE_VALUE) {
context.addAttributeValuePart(parent);
context.setState(State.UNQUOTED_ATTRIBUTE_VALUE,endPoint);
}
 else {
context.setAttributeValue(parent);
if (willAtLeastOneBranchExecute && endingState == State.BEFORE_ATTRIBUTE_NAME) {
context.setState(State.BEFORE_ATTRIBUTE_NAME,endPoint);
}
}
break;
case UNQUOTED_ATTRIBUTE_VALUE:
case DOUBLE_QUOTED_ATTRIBUTE_VALUE:
case SINGLE_QUOTED_ATTRIBUTE_VALUE:
context.addAttributeValuePart(parent);
break;
case HTML_COMMENT:
case NONE:
case PCDATA:
case RCDATA_SCRIPT:
case RCDATA_STYLE:
case RCDATA_TEXTAREA:
case RCDATA_TITLE:
case XML_DECLARATION:
case CDATA:
case DOUBLE_QUOTED_XML_ATTRIBUTE_VALUE:
case SINGLE_QUOTED_XML_ATTRIBUTE_VALUE:
break;
default :
throw new AssertionError("String_Node_Str" + startingState);
}
}