Build RS API doc generator with Android.bp

The RS API header/document generator should be compiled with a proper
Android.bp rather than relying on a hardcoded clang version. This CL
updates both the generate.sh and provides an Android.bp for the generator.

Also fixed a segfault caused by an old bug from advancing an invalidated
list iterator. The segfault was caught by switching toolchain and C++
library versions.

In addition, fixed warnings caught by -Werror.

Test: m
Test: run generate.sh and inspect the generated documents
Bug: 66509928
Change-Id: Ibbbaaf65a0d1fc8ca37d357d077530d351d112f5
diff --git a/script_api/GenerateTestFiles.cpp b/script_api/GenerateTestFiles.cpp
index d907d37..5a649a5 100644
--- a/script_api/GenerateTestFiles.cpp
+++ b/script_api/GenerateTestFiles.cpp
@@ -1010,8 +1010,9 @@
 }
 
 // Open the mJavaFile and writes the header.
-static bool startJavaFile(GeneratedFile* file, const Function& function, const string& directory,
-                          const string& testName, const string& relaxedTestName) {
+static bool startJavaFile(GeneratedFile* file, const string& directory,
+                          const string& testName,
+                          const string& relaxedTestName) {
     const string fileName = testName + ".java";
     if (!file->start(directory, fileName)) {
         return false;
@@ -1072,7 +1073,7 @@
 }
 
 // Open the script file and write its header.
-static bool startRsFile(GeneratedFile* file, const Function& function, const string& directory,
+static bool startRsFile(GeneratedFile* file, const string& directory,
                         const string& testName) {
     string fileName = testName + ".rs";
     if (!file->start(directory, fileName)) {
@@ -1086,8 +1087,8 @@
 }
 
 // Write the entire *Relaxed.rs test file, as it only depends on the name.
-static bool writeRelaxedRsFile(const Function& function, const string& directory,
-                               const string& testName, const string& relaxedTestName) {
+static bool writeRelaxedRsFile(const string& directory, const string& testName,
+                               const string& relaxedTestName) {
     string name = relaxedTestName + ".rs";
 
     GeneratedFile file;
@@ -1115,17 +1116,17 @@
     const string testName = "Test" + function.getCapitalizedName();
     const string relaxedTestName = testName + "Relaxed";
 
-    if (!writeRelaxedRsFile(function, directory, testName, relaxedTestName)) {
+    if (!writeRelaxedRsFile(directory, testName, relaxedTestName)) {
         return false;
     }
 
     GeneratedFile rsFile;    // The Renderscript test file we're generating.
     GeneratedFile javaFile;  // The Jave test file we're generating.
-    if (!startRsFile(&rsFile, function, directory, testName)) {
+    if (!startRsFile(&rsFile, directory, testName)) {
         return false;
     }
 
-    if (!startJavaFile(&javaFile, function, directory, testName, relaxedTestName)) {
+    if (!startJavaFile(&javaFile, directory, testName, relaxedTestName)) {
         return false;
     }