ART: Use std::vector in GraphChecker

(Temporarily) move GraphChecker to use std::vector for errors, as
std::strings need to be destructed.

Bug: 18120045
Change-Id: I7d38001e6b1f3cee14299194d4515b985541d656
diff --git a/compiler/optimizing/graph_checker.cc b/compiler/optimizing/graph_checker.cc
index 743ffc4..1953241 100644
--- a/compiler/optimizing/graph_checker.cc
+++ b/compiler/optimizing/graph_checker.cc
@@ -53,7 +53,7 @@
             << " lists " << block_count_in_p_successors
             << " occurrences of block " << block->GetBlockId()
             << " in its successors.";
-      errors_.Insert(error.str());
+      errors_.push_back(error.str());
     }
   }
 
@@ -83,7 +83,7 @@
             << " lists " << block_count_in_s_predecessors
             << " occurrences of block " << block->GetBlockId()
             << " in its predecessors.";
-      errors_.Insert(error.str());
+      errors_.push_back(error.str());
     }
   }
 
@@ -93,7 +93,7 @@
     std::stringstream error;
     error  << "Block " << block->GetBlockId()
            << " does not end with a branch instruction.";
-    errors_.Insert(error.str());
+    errors_.push_back(error.str());
   }
 
   // Visit this block's list of phis.
@@ -103,7 +103,7 @@
       std::stringstream error;
       error << "Block " << current_block_->GetBlockId()
             << " has a non-phi in its phi list.";
-      errors_.Insert(error.str());
+      errors_.push_back(error.str());
     }
     it.Current()->Accept(this);
   }
@@ -116,7 +116,7 @@
       std::stringstream error;
       error << "Block " << current_block_->GetBlockId()
             << " has a phi in its non-phi list.";
-      errors_.Insert(error.str());
+      errors_.push_back(error.str());
     }
     it.Current()->Accept(this);
   }
@@ -139,7 +139,7 @@
     } else {
       error << " not associated with any block.";
     }
-    errors_.Insert(error.str());
+    errors_.push_back(error.str());
   }
 
   // Ensure the inputs of `instruction` are defined in a block of the graph.
@@ -154,7 +154,7 @@
       error << "Input " << input->GetId()
             << " of instruction " << instruction->GetId()
             << " is not defined in a basic block of the control-flow graph.";
-      errors_.Insert(error.str());
+      errors_.push_back(error.str());
     }
   }
 
@@ -170,7 +170,7 @@
       error << "User " << use->GetId()
             << " of instruction " << instruction->GetId()
             << " is not defined in a basic block of the control-flow graph.";
-      errors_.Insert(error.str());
+      errors_.push_back(error.str());
     }
   }
 }
@@ -188,7 +188,7 @@
         std::stringstream error;
         error << "Critical edge between blocks " << block->GetBlockId()
               << " and "  << successor->GetBlockId() << ".";
-        errors_.Insert(error.str());
+        errors_.push_back(error.str());
       }
     }
   }
@@ -207,7 +207,7 @@
     std::stringstream error;
     error << "Loop pre-header is not the first predecessor of the loop header "
           << id << ".";
-    errors_.Insert(error.str());
+    errors_.push_back(error.str());
   }
 
   // Ensure the loop header has only two predecessors and that only the
@@ -215,25 +215,25 @@
   if (loop_header->GetPredecessors().Size() < 2) {
     std::stringstream error;
     error << "Loop header " << id << " has less than two predecessors.";
-    errors_.Insert(error.str());
+    errors_.push_back(error.str());
   } else if (loop_header->GetPredecessors().Size() > 2) {
     std::stringstream error;
     error << "Loop header " << id << " has more than two predecessors.";
-    errors_.Insert(error.str());
+    errors_.push_back(error.str());
   } else {
     HLoopInformation* loop_information = loop_header->GetLoopInformation();
     HBasicBlock* first_predecessor = loop_header->GetPredecessors().Get(0);
     if (loop_information->IsBackEdge(first_predecessor)) {
       std::stringstream error;
       error << "First predecessor of loop header " << id << " is a back edge.";
-      errors_.Insert(error.str());
+      errors_.push_back(error.str());
     }
     HBasicBlock* second_predecessor = loop_header->GetPredecessors().Get(1);
     if (!loop_information->IsBackEdge(second_predecessor)) {
       std::stringstream error;
       error << "Second predecessor of loop header " << id
             << " is not a back edge.";
-      errors_.Insert(error.str());
+      errors_.push_back(error.str());
     }
   }
 
@@ -244,7 +244,7 @@
       std::stringstream error;
       error << "Loop defined by header " << id << " has "
             << num_back_edges << " back edge(s).";
-      errors_.Insert(error.str());
+      errors_.push_back(error.str());
   }
 
   // Ensure all blocks in the loop are dominated by the loop header.
@@ -256,7 +256,7 @@
       std::stringstream error;
       error << "Loop block " << loop_block->GetBlockId()
             << " not dominated by loop header " << id;
-      errors_.Insert(error.str());
+      errors_.push_back(error.str());
     }
   }
 }
@@ -274,7 +274,7 @@
             << " in block " << current_block_->GetBlockId()
             << " does not dominate use " << use->GetId()
             << " in block " << use->GetBlock()->GetBlockId() << ".";
-      errors_.Insert(error.str());
+      errors_.push_back(error.str());
     }
   }
 
@@ -292,7 +292,7 @@
               << " from block " << current_block_->GetBlockId()
               << " does not dominate instruction " << instruction->GetId()
               << ".";
-        errors_.Insert(error.str());
+        errors_.push_back(error.str());
       }
     }
   }
@@ -307,7 +307,7 @@
       error << "Loop phi " << phi->GetId()
             << " in block " << phi->GetBlock()->GetBlockId()
             << " is its own first input.";
-      errors_.Insert(error.str());
+      errors_.push_back(error.str());
   }
 
   // Ensure the number of phi inputs is the same as the number of
@@ -321,7 +321,7 @@
           << " has " << phi->InputCount() << " inputs, but block "
           << phi->GetBlock()->GetBlockId() << " has "
           << predecessors.Size() << " predecessors.";
-    errors_.Insert(error.str());
+    errors_.push_back(error.str());
   } else {
     // Ensure phi input at index I either comes from the Ith
     // predecessor or from a block that dominates this predecessor.
@@ -336,7 +336,7 @@
               << " from block " << phi->GetBlock()->GetBlockId()
               << " is not defined in predecessor number " << i
               << " nor in a block dominating it.";
-        errors_.Insert(error.str());
+        errors_.push_back(error.str());
       }
     }
   }
diff --git a/compiler/optimizing/graph_checker.h b/compiler/optimizing/graph_checker.h
index badf21d..8ba8cb1 100644
--- a/compiler/optimizing/graph_checker.h
+++ b/compiler/optimizing/graph_checker.h
@@ -30,7 +30,6 @@
                const char* dump_prefix = "art::GraphChecker: ")
     : HGraphVisitor(graph),
       allocator_(allocator),
-      errors_(allocator, 0),
       dump_prefix_(dump_prefix) {}
 
   // Check the whole graph (in insertion order).
@@ -44,18 +43,18 @@
 
   // Was the last visit of the graph valid?
   bool IsValid() const {
-    return errors_.IsEmpty();
+    return errors_.empty();
   }
 
   // Get the list of detected errors.
-  const GrowableArray<std::string>& GetErrors() const {
+  const std::vector<std::string>& GetErrors() const {
     return errors_;
   }
 
   // Print detected errors on output stream `os`.
   void Dump(std::ostream& os) const {
-    for (size_t i = 0, e = errors_.Size(); i < e; ++i) {
-      os << dump_prefix_ << errors_.Get(i) << std::endl;
+    for (size_t i = 0, e = errors_.size(); i < e; ++i) {
+      os << dump_prefix_ << errors_[i] << std::endl;
     }
   }
 
@@ -64,7 +63,7 @@
   // The block currently visited.
   HBasicBlock* current_block_ = nullptr;
   // Errors encountered while checking the graph.
-  GrowableArray<std::string> errors_;
+  std::vector<std::string> errors_;
 
  private:
   // String displayed before dumped errors.