{"action":"created","comment":{"url":"https://api.github.com/repos/SonarSource/sonar-java/pulls/comments/40534802","id":40534802,"diff_hunk":"@@ -0,0 +1,767 @@\n+/*\n+ * SonarQube Java\n+ * Copyright (C) 2012 SonarSource\n+ * sonarqube@googlegroups.com\n+ *\n+ * This program is free software; you can redistribute it and/or\n+ * modify it under the terms of the GNU Lesser General Public\n+ * License as published by the Free Software Foundation; either\n+ * version 3 of the License, or (at your option) any later version.\n+ *\n+ * This program is distributed in the hope that it will be useful,\n+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\n+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n+ * Lesser General Public License for more details.\n+ *\n+ * You should have received a copy of the GNU Lesser General Public\n+ * License along with this program; if not, write to the Free Software\n+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02\n+ */\n+package org.sonar.java.cfg;\n+\n+import com.google.common.base.Preconditions;\n+import com.google.common.collect.Lists;\n+import com.google.common.collect.Maps;\n+import org.sonar.java.model.JavaTree;\n+import org.sonar.plugins.java.api.semantic.Symbol;\n+import org.sonar.plugins.java.api.tree.ArrayAccessExpressionTree;\n+import org.sonar.plugins.java.api.tree.ArrayDimensionTree;\n+import org.sonar.plugins.java.api.tree.AssignmentExpressionTree;\n+import org.sonar.plugins.java.api.tree.BinaryExpressionTree;\n+import org.sonar.plugins.java.api.tree.BlockTree;\n+import org.sonar.plugins.java.api.tree.BreakStatementTree;\n+import org.sonar.plugins.java.api.tree.CaseGroupTree;\n+import org.sonar.plugins.java.api.tree.ConditionalExpressionTree;\n+import org.sonar.plugins.java.api.tree.ContinueStatementTree;\n+import org.sonar.plugins.java.api.tree.DoWhileStatementTree;\n+import org.sonar.plugins.java.api.tree.ExpressionStatementTree;\n+import org.sonar.plugins.java.api.tree.ExpressionTree;\n+import org.sonar.plugins.java.api.tree.ForEachStatement;\n+import org.sonar.plugins.java.api.tree.ForStatementTree;\n+import org.sonar.plugins.java.api.tree.IdentifierTree;\n+import org.sonar.plugins.java.api.tree.IfStatementTree;\n+import org.sonar.plugins.java.api.tree.InstanceOfTree;\n+import org.sonar.plugins.java.api.tree.LabeledStatementTree;\n+import org.sonar.plugins.java.api.tree.LiteralTree;\n+import org.sonar.plugins.java.api.tree.MemberSelectExpressionTree;\n+import org.sonar.plugins.java.api.tree.MethodInvocationTree;\n+import org.sonar.plugins.java.api.tree.MethodTree;\n+import org.sonar.plugins.java.api.tree.NewArrayTree;\n+import org.sonar.plugins.java.api.tree.NewClassTree;\n+import org.sonar.plugins.java.api.tree.ParenthesizedTree;\n+import org.sonar.plugins.java.api.tree.ReturnStatementTree;\n+import org.sonar.plugins.java.api.tree.StatementTree;\n+import org.sonar.plugins.java.api.tree.SwitchStatementTree;\n+import org.sonar.plugins.java.api.tree.SynchronizedStatementTree;\n+import org.sonar.plugins.java.api.tree.ThrowStatementTree;\n+import org.sonar.plugins.java.api.tree.Tree;\n+import org.sonar.plugins.java.api.tree.TryStatementTree;\n+import org.sonar.plugins.java.api.tree.TypeCastTree;\n+import org.sonar.plugins.java.api.tree.UnaryExpressionTree;\n+import org.sonar.plugins.java.api.tree.VariableTree;\n+import org.sonar.plugins.java.api.tree.WhileStatementTree;\n+\n+import javax.annotation.Nullable;\n+\n+import java.io.PrintStream;\n+import java.util.ArrayList;\n+import java.util.Deque;\n+import java.util.LinkedList;\n+import java.util.List;\n+import java.util.Map;\n+\n+public class CFG {\n+\n+  private final Block exitBlock;\n+  private final Symbol.MethodSymbol methodSymbol;\n+  private Block currentBlock;\n+\n+  /**\n+   * List of all blocks in order they were created.\n+   */\n+  final List<Block> blocks = new ArrayList<>();\n+\n+  private final Deque<Block> breakTargets = new LinkedList<>();\n+  private final Deque<Block> continueTargets = new LinkedList<>();\n+\n+  private final Deque<Block> switches = new LinkedList<>();\n+  private Map<String, Block> labels = Maps.newHashMap();\n+  private final List<Block> gotos = new LinkedList<>();\n+\n+  public Symbol.MethodSymbol methodSymbol() {\n+    return methodSymbol;\n+  }\n+\n+  public Block entry() {\n+    return currentBlock;\n+  }\n+\n+  public List<Block> blocks() {\n+    return Lists.reverse(blocks);\n+  }\n+\n+  public static class Block {\n+    public final int id;\n+    final List<Tree> elements = new ArrayList<>();\n+    final List<Block> successors = new ArrayList<>();\n+    final List<Block> predecessors = new ArrayList<>();\n+    Tree terminator;\n+\n+    public Block(int id) {\n+      this.id = id;\n+    }\n+\n+    public List<Tree> elements() {\n+      return Lists.reverse(elements);\n+    }\n+\n+    public List<Block> predecessors() {\n+      return predecessors;\n+    }\n+\n+    public List<Block> successors() {\n+      return successors;\n+    }\n+  }\n+\n+  private CFG(BlockTree tree, Symbol.MethodSymbol symbol) {\n+    methodSymbol = symbol;\n+    exitBlock = createBlock();\n+    currentBlock = createBlock(exitBlock);\n+    for (StatementTree statementTree : Lists.reverse(tree.body())) {\n+      build(statementTree);\n+    }\n+\n+    for (Block b : gotos) {\n+      assert b.successors.isEmpty();\n+      Tree s = b.terminator;\n+      assert s != null;\n+      String label;\n+      if (s instanceof BreakStatementTree) {\n+        label = ((BreakStatementTree) s).label().name();\n+      } else {\n+        label = ((ContinueStatementTree) s).label().name();\n+      }\n+      Block target = labels.get(label);\n+      if (target == null) {\n+        throw new IllegalStateException(\"Undeclared label: \" + label);\n+      }\n+      b.successors.add(target);\n+    }\n+\n+    for (Block b : blocks) {\n+      for (Block successor : b.successors) {\n+        successor.predecessors.add(b);\n+      }\n+    }\n+  }\n+\n+  private Block createBlock(Block successor) {\n+    Block result = createBlock();\n+    result.successors.add(successor);\n+    return result;\n+  }\n+\n+  private Block createBlock() {\n+    Block result = new Block(blocks.size());\n+    blocks.add(result);\n+    return result;\n+  }\n+\n+  public static CFG build(MethodTree tree) {\n+    Preconditions.checkArgument(tree.block() != null, \"Cannot build CFG for method with no body.\");\n+    return new CFG(tree.block(), tree.symbol());\n+  }\n+\n+  private void build(List<? extends Tree> trees) {\n+    for (Tree tree : Lists.reverse(trees)) {\n+      build(tree);\n+    }\n+  }\n+\n+  private void build(Tree tree) {\n+    switch (tree.kind()) {\n+      case BLOCK:\n+        for (StatementTree statementTree : Lists.reverse(((BlockTree) tree).body())) {\n+          build(statementTree);\n+        }\n+        break;\n+      case RETURN_STATEMENT:\n+        buildReturnStatement((ReturnStatementTree) tree);\n+        break;\n+      case EXPRESSION_STATEMENT:\n+        build(((ExpressionStatementTree) tree).expression());\n+        break;\n+      case METHOD_INVOCATION:\n+        buildMethodInvocation((MethodInvocationTree) tree);\n+        break;\n+      case IF_STATEMENT:\n+        buildIfStatement((IfStatementTree) tree);\n+        break;\n+      case CONDITIONAL_EXPRESSION:\n+        buildConditionalExpression((ConditionalExpressionTree) tree);\n+        break;\n+      case VARIABLE:\n+        buildVariable((VariableTree) tree);\n+        break;\n+      case MULTIPLY:\n+      case DIVIDE:\n+      case REMAINDER:\n+      case PLUS:\n+      case MINUS:\n+      case LEFT_SHIFT:\n+      case RIGHT_SHIFT:\n+      case UNSIGNED_RIGHT_SHIFT:\n+      case AND:\n+      case XOR:\n+      case OR:\n+      case GREATER_THAN:\n+      case GREATER_THAN_OR_EQUAL_TO:\n+      case LESS_THAN:\n+      case LESS_THAN_OR_EQUAL_TO:\n+      case EQUAL_TO:\n+      case NOT_EQUAL_TO:\n+        buildBinaryExpression(tree);\n+        break;\n+      case ASSIGNMENT:\n+      case LEFT_SHIFT_ASSIGNMENT:\n+      case RIGHT_SHIFT_ASSIGNMENT:\n+      case AND_ASSIGNMENT:\n+      case REMAINDER_ASSIGNMENT:\n+      case UNSIGNED_RIGHT_SHIFT_ASSIGNMENT:\n+      case OR_ASSIGNMENT:\n+      case XOR_ASSIGNMENT:\n+      case DIVIDE_ASSIGNMENT:\n+      case MULTIPLY_ASSIGNMENT:\n+      case PLUS_ASSIGNMENT:\n+      case MINUS_ASSIGNMENT:\n+        buildAssignment((AssignmentExpressionTree) tree);\n+        break;\n+      case MEMBER_SELECT:\n+        buildMemberSelect((MemberSelectExpressionTree) tree);\n+        break;\n+      case CONDITIONAL_AND:\n+        buildConditionalAnd((BinaryExpressionTree) tree);\n+        break;\n+      case CONDITIONAL_OR:\n+        buildConditionalOr((BinaryExpressionTree) tree);\n+        break;\n+      case LABELED_STATEMENT:\n+        buildLabeledStatement((LabeledStatementTree) tree);\n+        break;\n+      case SWITCH_STATEMENT:\n+        buildSwitchStatement((SwitchStatementTree) tree);\n+        break;\n+      case BREAK_STATEMENT:\n+        buildBreakStatement((BreakStatementTree) tree);\n+        break;\n+      case CONTINUE_STATEMENT:\n+        buildContinueStatement((ContinueStatementTree) tree);\n+        break;\n+      case WHILE_STATEMENT:\n+        buildWhileStatement((WhileStatementTree) tree);\n+        break;\n+      case DO_STATEMENT:\n+        buildDoWhileStatement((DoWhileStatementTree) tree);\n+        break;\n+      case FOR_EACH_STATEMENT:\n+        buildForEachStatement((ForEachStatement) tree);\n+        break;\n+      case FOR_STATEMENT:\n+        buildForStatement((ForStatementTree) tree);\n+        break;\n+      case TRY_STATEMENT:\n+        buildTryStatement((TryStatementTree) tree);\n+        break;\n+      case THROW_STATEMENT:\n+        buildThrowStatement((ThrowStatementTree) tree);\n+        break;\n+      case SYNCHRONIZED_STATEMENT:\n+        buildSynchronizedStatement((SynchronizedStatementTree) tree);\n+        break;\n+      case POSTFIX_INCREMENT:\n+      case POSTFIX_DECREMENT:\n+      case PREFIX_INCREMENT:\n+      case PREFIX_DECREMENT:\n+      case UNARY_MINUS:\n+      case UNARY_PLUS:\n+      case BITWISE_COMPLEMENT:\n+      case LOGICAL_COMPLEMENT:\n+        buildUnaryExpression((UnaryExpressionTree) tree);\n+        break;\n+      case PARENTHESIZED_EXPRESSION:\n+        build(((ParenthesizedTree) tree).expression());\n+        break;\n+      case ARRAY_ACCESS_EXPRESSION:\n+        buildArrayAccessExpression((ArrayAccessExpressionTree) tree);\n+        break;\n+      case ARRAY_DIMENSION:\n+        buildArrayDimension((ArrayDimensionTree) tree);\n+        break;\n+      case NEW_CLASS:\n+        buildNewClass((NewClassTree) tree);\n+        break;\n+      case IDENTIFIER:\n+      case INT_LITERAL:\n+      case LONG_LITERAL:\n+      case DOUBLE_LITERAL:\n+      case CHAR_LITERAL:\n+      case FLOAT_LITERAL:\n+      case STRING_LITERAL:\n+      case BOOLEAN_LITERAL:\n+      case NULL_LITERAL:\n+        currentBlock.elements.add(tree);\n+        break;\n+      case TYPE_CAST:\n+        buildTypeCast(tree);\n+        break;\n+      case INSTANCE_OF:\n+        buildInstanceOf((InstanceOfTree) tree);\n+        break;\n+      case NEW_ARRAY:\n+        buildNewArray((NewArrayTree) tree);\n+        break;\n+      case METHOD_REFERENCE:\n+        // Java 8 constructions : ignored for now.\n+        break;\n+      case EMPTY_STATEMENT:\n+      case CLASS:\n+      case ENUM:\n+      case ANNOTATION_TYPE:\n+      case INTERFACE:\n+      case LAMBDA_EXPRESSION:\n+        // store declarations as complete blocks.\n+        currentBlock.elements.add(tree);\n+        break;\n+      default:\n+        throw new UnsupportedOperationException(tree.kind().name() + \" \" + ((JavaTree) tree).getLine());\n+    }\n+  }\n+\n+  private void buildReturnStatement(ReturnStatementTree tree) {\n+    ReturnStatementTree s = tree;\n+    currentBlock = createUnconditionalJump(s, exitBlock);\n+    ExpressionTree expression = s.expression();\n+    if (expression != null) {\n+      build(expression);\n+    }\n+  }\n+\n+  private void buildMethodInvocation(MethodInvocationTree tree) {\n+    MethodInvocationTree mit = tree;\n+    currentBlock.elements.add(mit);\n+    build(mit.methodSelect());\n+    for (ExpressionTree arg : Lists.reverse(mit.arguments())) {\n+      build(arg);\n+    }\n+  }\n+\n+  private void buildIfStatement(IfStatementTree tree) {\n+    IfStatementTree ifStatementTree = tree;\n+    Block next = currentBlock;\n+    // process else-branch\n+    Block elseBlock = next;\n+    StatementTree elseStatement = ifStatementTree.elseStatement();\n+    if (elseStatement != null) {\n+      // if statement will create the required block.\n+      if (!elseStatement.is(Tree.Kind.IF_STATEMENT)) {\n+        currentBlock = createBlock(next);\n+      }\n+      build(elseStatement);\n+      elseBlock = currentBlock;\n+    }\n+    // process then-branch\n+    currentBlock = createBlock(next);\n+    build(ifStatementTree.thenStatement());\n+    Block thenBlock = currentBlock;\n+    // process condition\n+    currentBlock = createBranch(ifStatementTree, thenBlock, elseBlock);\n+    buildCondition(ifStatementTree.condition(), thenBlock, elseBlock);\n+  }\n+\n+  private void buildConditionalExpression(ConditionalExpressionTree tree) {\n+    ConditionalExpressionTree cond = tree;\n+    Block next = currentBlock;\n+    // process else-branch\n+    ExpressionTree elseStatement = cond.falseExpression();\n+    currentBlock = createBlock(next);\n+    build(elseStatement);\n+    Block elseBlock = currentBlock;\n+    // process then-branch\n+    currentBlock = createBlock(next);\n+    build(cond.trueExpression());\n+    Block thenBlock = currentBlock;\n+    // process condition\n+    currentBlock = createBranch(cond, thenBlock, elseBlock);\n+    buildCondition(cond.condition(), thenBlock, elseBlock);\n+  }\n+\n+  private void buildVariable(VariableTree tree) {\n+    currentBlock.elements.add(tree);\n+    ExpressionTree initializer = tree.initializer();\n+    if (initializer != null) {\n+      build(initializer);\n+    }\n+  }\n+\n+  private void buildBinaryExpression(Tree tree) {\n+    BinaryExpressionTree binaryExpressionTree = (BinaryExpressionTree) tree;\n+    currentBlock.elements.add(tree);\n+    build(binaryExpressionTree.rightOperand());\n+    build(binaryExpressionTree.leftOperand());\n+  }\n+\n+  private void buildAssignment(AssignmentExpressionTree tree) {\n+    currentBlock.elements.add(tree);\n+    build(tree.variable());\n+    build(tree.expression());\n+  }\n+\n+  private void buildMemberSelect(MemberSelectExpressionTree tree) {\n+    MemberSelectExpressionTree mse = tree;\n+    currentBlock.elements.add(mse);\n+    // int.class or String[].class are memberSelectExpression which expression part is not an expression.\n+    if (!\"class\".equals(mse.identifier().name())) {\n+      build(mse.expression());\n+    }\n+  }\n+\n+  private void buildConditionalAnd(BinaryExpressionTree tree) {\n+    // process RHS\n+    Block falseBlock = currentBlock;\n+    currentBlock = createBlock(falseBlock);\n+    build(tree.rightOperand());\n+    Block trueBlock = currentBlock;\n+    // process LHS\n+    currentBlock = createBranch(tree, trueBlock, falseBlock);\n+    build(tree.leftOperand());\n+  }\n+\n+  private void buildConditionalOr(BinaryExpressionTree tree) {\n+    // process RHS\n+    Block trueBlock = currentBlock;\n+    currentBlock = createBlock(trueBlock);\n+    build(tree.rightOperand());\n+    Block falseBlock = currentBlock;\n+    // process LHS\n+    currentBlock = createBranch(tree, trueBlock, falseBlock);\n+    build(tree.leftOperand());\n+  }\n+\n+  private void buildLabeledStatement(LabeledStatementTree tree) {\n+    LabeledStatementTree s = tree;\n+    build(s.statement());\n+    currentBlock = createBlock(currentBlock);\n+    labels.put(s.label().name(), currentBlock);\n+    return;\n+  }\n+\n+  private void buildSwitchStatement(SwitchStatementTree tree) {\n+    // FIXME useless node created for default cases.\n+    SwitchStatementTree switchStatementTree = tree;\n+    Block switchSuccessor = currentBlock;\n+    // process condition\n+    currentBlock = createBlock();\n+    currentBlock.terminator = switchStatementTree;\n+    switches.addLast(currentBlock);\n+    build(switchStatementTree.expression());\n+    // process body\n+    currentBlock = createBlock(switchSuccessor);\n+    breakTargets.addLast(switchSuccessor);\n+    if (!switchStatementTree.cases().isEmpty()) {\n+      CaseGroupTree firstCase = switchStatementTree.cases().get(0);\n+      for (CaseGroupTree caseGroupTree : Lists.reverse(switchStatementTree.cases())) {\n+        build(caseGroupTree.body());\n+        switches.getLast().successors.add(currentBlock);\n+        if (caseGroupTree != firstCase) {\n+          // No block predecessing the first case group.\n+          currentBlock = createBlock(currentBlock);\n+        }\n+      }\n+    }\n+    breakTargets.removeLast();\n+    // process condition\n+    currentBlock = switches.removeLast();\n+  }\n+\n+  private void buildBreakStatement(BreakStatementTree tree) {\n+    if (tree.label() == null) {\n+      if (breakTargets.isEmpty()) {\n+        throw new IllegalStateException(\"'break' statement not in loop or switch statement\");\n+      }\n+      currentBlock = createUnconditionalJump(tree, breakTargets.getLast());\n+    } else {\n+      currentBlock = createUnconditionalJump(tree, null);\n+      gotos.add(currentBlock);\n+    }\n+  }\n+\n+  private void buildContinueStatement(ContinueStatementTree tree) {\n+    if (tree.label() == null) {\n+      if (continueTargets.isEmpty()) {\n+        throw new IllegalStateException(\"'continue' statement not in loop or switch statement\");\n+      }\n+      currentBlock = createUnconditionalJump(tree, continueTargets.getLast());\n+    } else {\n+      currentBlock = createUnconditionalJump(tree, null);\n+      gotos.add(currentBlock);\n+    }\n+  }\n+\n+  private void buildWhileStatement(WhileStatementTree tree) {\n+    WhileStatementTree s = tree;\n+    Block falseBranch = currentBlock;\n+    Block loopback = createBlock();\n+    // process body\n+    currentBlock = createBlock(loopback);\n+    continueTargets.addLast(loopback);\n+    breakTargets.addLast(falseBranch);\n+    build(s.statement());\n+    breakTargets.removeLast();\n+    continueTargets.removeLast();\n+    Block bodyBlock = currentBlock;\n+    // process condition\n+    currentBlock = createBranch(s, bodyBlock, falseBranch);\n+    buildCondition(s.condition(), bodyBlock, falseBranch);\n+    loopback.successors.add(currentBlock);\n+    currentBlock = createBlock(currentBlock);\n+  }\n+\n+  private void buildDoWhileStatement(DoWhileStatementTree tree) {\n+    DoWhileStatementTree s = tree;\n+    Block falseBranch = currentBlock;\n+    Block loopback = createBlock();\n+    // process condition\n+    currentBlock = createBranch(s, loopback, falseBranch);\n+    buildCondition(s.condition(), loopback, falseBranch);\n+    // process body\n+    currentBlock = createBlock(currentBlock);\n+    continueTargets.addLast(loopback);\n+    breakTargets.addLast(falseBranch);\n+    build(s.statement());\n+    breakTargets.removeLast();\n+    continueTargets.removeLast();\n+    loopback.successors.add(currentBlock);\n+    currentBlock = createBlock(currentBlock);\n+  }\n+\n+  private void buildForEachStatement(ForEachStatement tree) {\n+    // TODO(npe) One solution is to create a forstatement node depending on type of expression (iterable or array) and build CFG from it.\n+    Block afterLoop = currentBlock;\n+    currentBlock = createBlock();\n+    Block loopback = currentBlock;\n+    continueTargets.addLast(loopback);\n+    breakTargets.addLast(afterLoop);\n+    build(tree.statement());\n+    breakTargets.removeLast();\n+    continueTargets.removeLast();\n+    currentBlock = createBranch(tree, currentBlock, afterLoop);\n+    loopback.successors.add(currentBlock);\n+    build(tree.variable());\n+    build(tree.expression());\n+    currentBlock = createBlock(currentBlock);\n+  }\n+\n+  private void buildForStatement(ForStatementTree tree) {\n+    Block falseBranch = currentBlock;\n+    // process step\n+    currentBlock = createBlock();\n+    Block updateBlock = currentBlock;\n+    for (StatementTree updateTree : Lists.reverse(tree.update())) {\n+      build(updateTree);\n+    }\n+    continueTargets.addLast(currentBlock);\n+    // process body\n+    currentBlock = createBlock(currentBlock);\n+    breakTargets.addLast(falseBranch);\n+    build(tree.statement());\n+    breakTargets.removeLast();\n+    continueTargets.removeLast();\n+    Block body = currentBlock;\n+    // process condition\n+    ExpressionTree condition = tree.condition();\n+    if (condition != null) {\n+      currentBlock = createBranch(tree, body, falseBranch);\n+      buildCondition(condition, body, falseBranch);\n+    } else {\n+      currentBlock = createUnconditionalJump(tree, body);\n+    }\n+    updateBlock.successors.add(currentBlock);\n+    // process init\n+    currentBlock = createBlock(currentBlock);\n+    for (StatementTree init : Lists.reverse(tree.initializer())) {\n+      build(init);\n+    }\n+  }\n+\n+  private void buildTryStatement(TryStatementTree tree) {\n+    // FIXME only path with no failure constructed for now, (not taking try with resources into consideration).\n+    TryStatementTree tryStatementTree = tree;\n+    currentBlock = createBlock(currentBlock);\n+    BlockTree finallyBlock = tryStatementTree.finallyBlock();\n+    if (finallyBlock != null) {\n+      build(finallyBlock);\n+    }\n+    currentBlock = createBlock(currentBlock);\n+    build(tryStatementTree.block());\n+    currentBlock = createBlock(currentBlock);\n+    currentBlock.elements.add(tree);\n+  }\n+\n+  private void buildThrowStatement(ThrowStatementTree tree) {\n+    // FIXME this won't work if it is intended to be caught by a try statement.\n+    ThrowStatementTree throwStatementTree = tree;\n+    currentBlock = createUnconditionalJump(throwStatementTree, exitBlock);\n+    build(throwStatementTree.expression());\n+  }\n+\n+  private void buildSynchronizedStatement(SynchronizedStatementTree tree) {\n+    SynchronizedStatementTree sst = tree;\n+    // Naively build synchronized statement.\n+    build(sst.block());\n+    build(sst.expression());\n+  }\n+\n+  private void buildUnaryExpression(UnaryExpressionTree tree) {\n+    if(tree.is(Tree.Kind.PREFIX_DECREMENT, Tree.Kind.PREFIX_INCREMENT)) {","path":"java-squid/src/main/java/org/sonar/java/cfg/CFG.java","position":626,"original_position":626,"commit_id":"6553dcfbee5cfb0acb48856efe9a6c52811b056e","original_commit_id":"6553dcfbee5cfb0acb48856efe9a6c52811b056e","user":{"login":"Godin","id":138671,"avatar_url":"https://avatars.githubusercontent.com/u/138671?v=3","gravatar_id":"","url":"https://api.github.com/users/Godin","html_url":"https://github.com/Godin","followers_url":"https://api.github.com/users/Godin/followers","following_url":"https://api.github.com/users/Godin/following{/other_user}","gists_url":"https://api.github.com/users/Godin/gists{/gist_id}","starred_url":"https://api.github.com/users/Godin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Godin/subscriptions","organizations_url":"https://api.github.com/users/Godin/orgs","repos_url":"https://api.github.com/users/Godin/repos","events_url":"https://api.github.com/users/Godin/events{/privacy}","received_events_url":"https://api.github.com/users/Godin/received_events","type":"User","site_admin":false},"body":"@benzonico The fact that postfix operators return value before modification shouldn't change order in CFG, because loading of value should anyway happen before operation, i.e. order should be the same.","created_at":"2015-09-28T09:51:09Z","updated_at":"2015-09-28T09:51:09Z","html_url":"https://github.com/SonarSource/sonar-java/pull/402#discussion_r40534802","pull_request_url":"https://api.github.com/repos/SonarSource/sonar-java/pulls/402","_links":{"self":{"href":"https://api.github.com/repos/SonarSource/sonar-java/pulls/comments/40534802"},"html":{"href":"https://github.com/SonarSource/sonar-java/pull/402#discussion_r40534802"},"pull_request":{"href":"https://api.github.com/repos/SonarSource/sonar-java/pulls/402"}}},"pull_request":{"url":"https://api.github.com/repos/SonarSource/sonar-java/pulls/402","id":45066244,"html_url":"https://github.com/SonarSource/sonar-java/pull/402","diff_url":"https://github.com/SonarSource/sonar-java/pull/402.diff","patch_url":"https://github.com/SonarSource/sonar-java/pull/402.patch","issue_url":"https://api.github.com/repos/SonarSource/sonar-java/issues/402","number":402,"state":"open","locked":false,"title":"SONARJAVA-578 Dead store ","user":{"login":"benzonico","id":1199708,"avatar_url":"https://avatars.githubusercontent.com/u/1199708?v=3","gravatar_id":"","url":"https://api.github.com/users/benzonico","html_url":"https://github.com/benzonico","followers_url":"https://api.github.com/users/benzonico/followers","following_url":"https://api.github.com/users/benzonico/following{/other_user}","gists_url":"https://api.github.com/users/benzonico/gists{/gist_id}","starred_url":"https://api.github.com/users/benzonico/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benzonico/subscriptions","organizations_url":"https://api.github.com/users/benzonico/orgs","repos_url":"https://api.github.com/users/benzonico/repos","events_url":"https://api.github.com/users/benzonico/events{/privacy}","received_events_url":"https://api.github.com/users/benzonico/received_events","type":"User","site_admin":false},"body":"including completing CFG and LiveVariable analysis","created_at":"2015-09-15T15:46:17Z","updated_at":"2015-09-28T09:51:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"57bb40d2023e96a863dbed1da28ce5af00ad3b23","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/SonarSource/sonar-java/pulls/402/commits","review_comments_url":"https://api.github.com/repos/SonarSource/sonar-java/pulls/402/comments","review_comment_url":"https://api.github.com/repos/SonarSource/sonar-java/pulls/comments{/number}","comments_url":"https://api.github.com/repos/SonarSource/sonar-java/issues/402/comments","statuses_url":"https://api.github.com/repos/SonarSource/sonar-java/statuses/6553dcfbee5cfb0acb48856efe9a6c52811b056e","head":{"label":"SonarSource:SONARJAVA-578","ref":"SONARJAVA-578","sha":"6553dcfbee5cfb0acb48856efe9a6c52811b056e","user":{"login":"SonarSource","id":545988,"avatar_url":"https://avatars.githubusercontent.com/u/545988?v=3","gravatar_id":"","url":"https://api.github.com/users/SonarSource","html_url":"https://github.com/SonarSource","followers_url":"https://api.github.com/users/SonarSource/followers","following_url":"https://api.github.com/users/SonarSource/following{/other_user}","gists_url":"https://api.github.com/users/SonarSource/gists{/gist_id}","starred_url":"https://api.github.com/users/SonarSource/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SonarSource/subscriptions","organizations_url":"https://api.github.com/users/SonarSource/orgs","repos_url":"https://api.github.com/users/SonarSource/repos","events_url":"https://api.github.com/users/SonarSource/events{/privacy}","received_events_url":"https://api.github.com/users/SonarSource/received_events","type":"Organization","site_admin":false},"repo":{"id":5674787,"name":"sonar-java","full_name":"SonarSource/sonar-java","owner":{"login":"SonarSource","id":545988,"avatar_url":"https://avatars.githubusercontent.com/u/545988?v=3","gravatar_id":"","url":"https://api.github.com/users/SonarSource","html_url":"https://github.com/SonarSource","followers_url":"https://api.github.com/users/SonarSource/followers","following_url":"https://api.github.com/users/SonarSource/following{/other_user}","gists_url":"https://api.github.com/users/SonarSource/gists{/gist_id}","starred_url":"https://api.github.com/users/SonarSource/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SonarSource/subscriptions","organizations_url":"https://api.github.com/users/SonarSource/orgs","repos_url":"https://api.github.com/users/SonarSource/repos","events_url":"https://api.github.com/users/SonarSource/events{/privacy}","received_events_url":"https://api.github.com/users/SonarSource/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/SonarSource/sonar-java","description":"","fork":false,"url":"https://api.github.com/repos/SonarSource/sonar-java","forks_url":"https://api.github.com/repos/SonarSource/sonar-java/forks","keys_url":"https://api.github.com/repos/SonarSource/sonar-java/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SonarSource/sonar-java/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SonarSource/sonar-java/teams","hooks_url":"https://api.github.com/repos/SonarSource/sonar-java/hooks","issue_events_url":"https://api.github.com/repos/SonarSource/sonar-java/issues/events{/number}","events_url":"https://api.github.com/repos/SonarSource/sonar-java/events","assignees_url":"https://api.github.com/repos/SonarSource/sonar-java/assignees{/user}","branches_url":"https://api.github.com/repos/SonarSource/sonar-java/branches{/branch}","tags_url":"https://api.github.com/repos/SonarSource/sonar-java/tags","blobs_url":"https://api.github.com/repos/SonarSource/sonar-java/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SonarSource/sonar-java/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SonarSource/sonar-java/git/refs{/sha}","trees_url":"https://api.github.com/repos/SonarSource/sonar-java/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SonarSource/sonar-java/statuses/{sha}","languages_url":"https://api.github.com/repos/SonarSource/sonar-java/languages","stargazers_url":"https://api.github.com/repos/SonarSource/sonar-java/stargazers","contributors_url":"https://api.github.com/repos/SonarSource/sonar-java/contributors","subscribers_url":"https://api.github.com/repos/SonarSource/sonar-java/subscribers","subscription_url":"https://api.github.com/repos/SonarSource/sonar-java/subscription","commits_url":"https://api.github.com/repos/SonarSource/sonar-java/commits{/sha}","git_commits_url":"https://api.github.com/repos/SonarSource/sonar-java/git/commits{/sha}","comments_url":"https://api.github.com/repos/SonarSource/sonar-java/comments{/number}","issue_comment_url":"https://api.github.com/repos/SonarSource/sonar-java/issues/comments{/number}","contents_url":"https://api.github.com/repos/SonarSource/sonar-java/contents/{+path}","compare_url":"https://api.github.com/repos/SonarSource/sonar-java/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SonarSource/sonar-java/merges","archive_url":"https://api.github.com/repos/SonarSource/sonar-java/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SonarSource/sonar-java/downloads","issues_url":"https://api.github.com/repos/SonarSource/sonar-java/issues{/number}","pulls_url":"https://api.github.com/repos/SonarSource/sonar-java/pulls{/number}","milestones_url":"https://api.github.com/repos/SonarSource/sonar-java/milestones{/number}","notifications_url":"https://api.github.com/repos/SonarSource/sonar-java/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SonarSource/sonar-java/labels{/name}","releases_url":"https://api.github.com/repos/SonarSource/sonar-java/releases{/id}","created_at":"2012-09-04T15:53:13Z","updated_at":"2015-09-17T02:30:52Z","pushed_at":"2015-09-28T09:38:54Z","git_url":"git://github.com/SonarSource/sonar-java.git","ssh_url":"git@github.com:SonarSource/sonar-java.git","clone_url":"https://github.com/SonarSource/sonar-java.git","svn_url":"https://github.com/SonarSource/sonar-java","homepage":"","size":44515,"stargazers_count":64,"watchers_count":64,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":97,"mirror_url":null,"open_issues_count":5,"forks":97,"open_issues":5,"watchers":64,"default_branch":"master"}},"base":{"label":"SonarSource:master","ref":"master","sha":"3e89098d7c04d5f69d4a3f7406b9c9b94d376bb9","user":{"login":"SonarSource","id":545988,"avatar_url":"https://avatars.githubusercontent.com/u/545988?v=3","gravatar_id":"","url":"https://api.github.com/users/SonarSource","html_url":"https://github.com/SonarSource","followers_url":"https://api.github.com/users/SonarSource/followers","following_url":"https://api.github.com/users/SonarSource/following{/other_user}","gists_url":"https://api.github.com/users/SonarSource/gists{/gist_id}","starred_url":"https://api.github.com/users/SonarSource/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SonarSource/subscriptions","organizations_url":"https://api.github.com/users/SonarSource/orgs","repos_url":"https://api.github.com/users/SonarSource/repos","events_url":"https://api.github.com/users/SonarSource/events{/privacy}","received_events_url":"https://api.github.com/users/SonarSource/received_events","type":"Organization","site_admin":false},"repo":{"id":5674787,"name":"sonar-java","full_name":"SonarSource/sonar-java","owner":{"login":"SonarSource","id":545988,"avatar_url":"https://avatars.githubusercontent.com/u/545988?v=3","gravatar_id":"","url":"https://api.github.com/users/SonarSource","html_url":"https://github.com/SonarSource","followers_url":"https://api.github.com/users/SonarSource/followers","following_url":"https://api.github.com/users/SonarSource/following{/other_user}","gists_url":"https://api.github.com/users/SonarSource/gists{/gist_id}","starred_url":"https://api.github.com/users/SonarSource/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SonarSource/subscriptions","organizations_url":"https://api.github.com/users/SonarSource/orgs","repos_url":"https://api.github.com/users/SonarSource/repos","events_url":"https://api.github.com/users/SonarSource/events{/privacy}","received_events_url":"https://api.github.com/users/SonarSource/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/SonarSource/sonar-java","description":"","fork":false,"url":"https://api.github.com/repos/SonarSource/sonar-java","forks_url":"https://api.github.com/repos/SonarSource/sonar-java/forks","keys_url":"https://api.github.com/repos/SonarSource/sonar-java/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SonarSource/sonar-java/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SonarSource/sonar-java/teams","hooks_url":"https://api.github.com/repos/SonarSource/sonar-java/hooks","issue_events_url":"https://api.github.com/repos/SonarSource/sonar-java/issues/events{/number}","events_url":"https://api.github.com/repos/SonarSource/sonar-java/events","assignees_url":"https://api.github.com/repos/SonarSource/sonar-java/assignees{/user}","branches_url":"https://api.github.com/repos/SonarSource/sonar-java/branches{/branch}","tags_url":"https://api.github.com/repos/SonarSource/sonar-java/tags","blobs_url":"https://api.github.com/repos/SonarSource/sonar-java/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SonarSource/sonar-java/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SonarSource/sonar-java/git/refs{/sha}","trees_url":"https://api.github.com/repos/SonarSource/sonar-java/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SonarSource/sonar-java/statuses/{sha}","languages_url":"https://api.github.com/repos/SonarSource/sonar-java/languages","stargazers_url":"https://api.github.com/repos/SonarSource/sonar-java/stargazers","contributors_url":"https://api.github.com/repos/SonarSource/sonar-java/contributors","subscribers_url":"https://api.github.com/repos/SonarSource/sonar-java/subscribers","subscription_url":"https://api.github.com/repos/SonarSource/sonar-java/subscription","commits_url":"https://api.github.com/repos/SonarSource/sonar-java/commits{/sha}","git_commits_url":"https://api.github.com/repos/SonarSource/sonar-java/git/commits{/sha}","comments_url":"https://api.github.com/repos/SonarSource/sonar-java/comments{/number}","issue_comment_url":"https://api.github.com/repos/SonarSource/sonar-java/issues/comments{/number}","contents_url":"https://api.github.com/repos/SonarSource/sonar-java/contents/{+path}","compare_url":"https://api.github.com/repos/SonarSource/sonar-java/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SonarSource/sonar-java/merges","archive_url":"https://api.github.com/repos/SonarSource/sonar-java/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SonarSource/sonar-java/downloads","issues_url":"https://api.github.com/repos/SonarSource/sonar-java/issues{/number}","pulls_url":"https://api.github.com/repos/SonarSource/sonar-java/pulls{/number}","milestones_url":"https://api.github.com/repos/SonarSource/sonar-java/milestones{/number}","notifications_url":"https://api.github.com/repos/SonarSource/sonar-java/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SonarSource/sonar-java/labels{/name}","releases_url":"https://api.github.com/repos/SonarSource/sonar-java/releases{/id}","created_at":"2012-09-04T15:53:13Z","updated_at":"2015-09-17T02:30:52Z","pushed_at":"2015-09-28T09:38:54Z","git_url":"git://github.com/SonarSource/sonar-java.git","ssh_url":"git@github.com:SonarSource/sonar-java.git","clone_url":"https://github.com/SonarSource/sonar-java.git","svn_url":"https://github.com/SonarSource/sonar-java","homepage":"","size":44515,"stargazers_count":64,"watchers_count":64,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":97,"mirror_url":null,"open_issues_count":5,"forks":97,"open_issues":5,"watchers":64,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/SonarSource/sonar-java/pulls/402"},"html":{"href":"https://github.com/SonarSource/sonar-java/pull/402"},"issue":{"href":"https://api.github.com/repos/SonarSource/sonar-java/issues/402"},"comments":{"href":"https://api.github.com/repos/SonarSource/sonar-java/issues/402/comments"},"review_comments":{"href":"https://api.github.com/repos/SonarSource/sonar-java/pulls/402/comments"},"review_comment":{"href":"https://api.github.com/repos/SonarSource/sonar-java/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/SonarSource/sonar-java/pulls/402/commits"},"statuses":{"href":"https://api.github.com/repos/SonarSource/sonar-java/statuses/6553dcfbee5cfb0acb48856efe9a6c52811b056e"}}}}