Fix a bug in ABCExpandVAArgPass.

eraseFromParent() invalidates the current iterator.

Change-Id: I969b5bad66410fc4c91d7a39f2674f8b84942185
diff --git a/lib/AndroidBitcode/ABCExpandVAArgPass.cpp b/lib/AndroidBitcode/ABCExpandVAArgPass.cpp
index 7b89ced..1f0debf 100644
--- a/lib/AndroidBitcode/ABCExpandVAArgPass.cpp
+++ b/lib/AndroidBitcode/ABCExpandVAArgPass.cpp
@@ -19,6 +19,7 @@
 
 #include "bcc/AndroidBitcode/ABCExpandVAArgPass.h"
 
+#include <llvm/ADT/STLExtras.h>
 #include <llvm/Instructions.h>
 #include <llvm/Support/InstIterator.h>
 
@@ -33,7 +34,8 @@
 
   // process va_arg inst
   for (llvm::inst_iterator inst = llvm::inst_begin(pFunc),
-          inst_end = llvm::inst_end(pFunc); inst != inst_end; inst++) {
+          inst_end = llvm::inst_end(pFunc), next_inst = llvm::next(inst);
+       inst != inst_end; inst = next_inst++) {
     if (inst->getOpcode() == llvm::Instruction::VAArg) {
       llvm::Value *v = expandVAArg(&*inst);
       inst->replaceAllUsesWith(v);