Fix RSExpandForEach pass.

The bug here is that the c_str() storage of a temporary std::string is not
guaranteed to persist beyond the scope of the std::string. In this case, we
were keeping a const char * to freed memory (and using garbage values to
populate our list of functions to keep).

Change-Id: I6e1bd64bbf302c004a34c926b2f7cd643ed98e76
diff --git a/lib/RenderScript/RSCompiler.cpp b/lib/RenderScript/RSCompiler.cpp
index 324696f..131fed6 100644
--- a/lib/RenderScript/RSCompiler.cpp
+++ b/lib/RenderScript/RSCompiler.cpp
@@ -74,7 +74,12 @@
        foreach_func_iter != foreach_func_end; foreach_func_iter++) {
     std::string name(foreach_func_iter->first);
     expanded_foreach_funcs.push_back(name.append(".expand"));
-    export_symbols.push_back(expanded_foreach_funcs.back().c_str());
+  }
+
+  // Need to wait until ForEachExpandList is fully populated to fill in
+  // exported symbols.
+  for (size_t i = 0; i < expanded_foreach_funcs.size(); i++) {
+    export_symbols.push_back(expanded_foreach_funcs[i].c_str());
   }
 
   pPM.add(llvm::createInternalizePass(export_symbols));