[kernel] Offset on IfStatement

Bug:
Change-Id: I40acad4d9f66da0324dcf7da95aab05c0784faac
Reviewed-on: https://dart-review.googlesource.com/5661
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
diff --git a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
index 4fb67d5..c72ea21 100644
--- a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
@@ -1349,7 +1349,8 @@
     Statement thenPart = popStatement();
     Expression condition = popForValue();
     typePromoter.exitConditional();
-    push(new ShadowIfStatement(condition, thenPart, elsePart));
+    push(new ShadowIfStatement(condition, thenPart, elsePart)
+      ..fileOffset = ifToken.charOffset);
   }
 
   @override
diff --git a/pkg/kernel/binary.md b/pkg/kernel/binary.md
index 2f8e0ee..a03e855 100644
--- a/pkg/kernel/binary.md
+++ b/pkg/kernel/binary.md
@@ -887,6 +887,7 @@
 
 type IfStatement extends Statement {
   Byte tag = 73;
+  FileOffset fileOffset;
   Expression condition;
   Statement then;
   Statement otherwise; // Empty statement if there was no else part.
diff --git a/pkg/kernel/lib/binary/ast_from_binary.dart b/pkg/kernel/lib/binary/ast_from_binary.dart
index eb30a9b..9e5583b 100644
--- a/pkg/kernel/lib/binary/ast_from_binary.dart
+++ b/pkg/kernel/lib/binary/ast_from_binary.dart
@@ -1178,8 +1178,10 @@
         return new ContinueSwitchStatement(switchCaseStack[index])
           ..fileOffset = offset;
       case Tag.IfStatement:
+        int offset = readOffset();
         return new IfStatement(
-            readExpression(), readStatement(), readStatementOrNullIfEmpty());
+            readExpression(), readStatement(), readStatementOrNullIfEmpty())
+          ..fileOffset = offset;
       case Tag.ReturnStatement:
         int offset = readOffset();
         return new ReturnStatement(readExpressionOption())..fileOffset = offset;
diff --git a/pkg/kernel/lib/binary/ast_to_binary.dart b/pkg/kernel/lib/binary/ast_to_binary.dart
index 44b9ad2..c7b2f2e 100644
--- a/pkg/kernel/lib/binary/ast_to_binary.dart
+++ b/pkg/kernel/lib/binary/ast_to_binary.dart
@@ -1040,6 +1040,7 @@
 
   visitIfStatement(IfStatement node) {
     writeByte(Tag.IfStatement);
+    writeOffset(node.fileOffset);
     writeNode(node.condition);
     writeNode(node.then);
     writeStatementOrEmpty(node.otherwise);
diff --git a/runtime/vm/compiler/frontend/kernel_binary_flowgraph.cc b/runtime/vm/compiler/frontend/kernel_binary_flowgraph.cc
index ca5b676..b8b4ee9 100644
--- a/runtime/vm/compiler/frontend/kernel_binary_flowgraph.cc
+++ b/runtime/vm/compiler/frontend/kernel_binary_flowgraph.cc
@@ -1346,9 +1346,10 @@
       builder_->ReadUInt();      // read target_index.
       return;
     case kIfStatement:
-      VisitExpression();  // read condition.
-      VisitStatement();   // read then.
-      VisitStatement();   // read otherwise.
+      builder_->ReadPosition();  // read position.
+      VisitExpression();         // read condition.
+      VisitStatement();          // read then.
+      VisitStatement();          // read otherwise.
       return;
     case kReturnStatement: {
       if ((depth_.function_ == 0) && (depth_.finally_ > 0) &&
@@ -4564,6 +4565,7 @@
       ReadUInt();      // read target_index.
       return;
     case kIfStatement:
+      ReadPosition();    // read position.
       SkipExpression();  // read condition.
       SkipStatement();   // read then.
       SkipStatement();   // read otherwise.
@@ -6980,6 +6982,7 @@
 
 Fragment StreamingFlowGraphBuilder::BuildIfStatement() {
   bool negate;
+  ReadPosition();                                       // read position.
   Fragment instructions = TranslateCondition(&negate);  // read condition.
   TargetEntryInstr* then_entry;
   TargetEntryInstr* otherwise_entry;