union: __assert2() when a tag mismatches

Rather than abort()ing without any message, __assert2() will leave a bit
of hints.
- bad access: get<tag>() with a wrong tag.
- can't reach here: writeToParcel() with an unknown tag. (in practice,
this won't happen though)

Bug: 170681273
Test: aidl_integration_test
Change-Id: I85a872d602720542657ca1cbb1c931a3e6d15749
diff --git a/generate_ndk.cpp b/generate_ndk.cpp
index e841457..90d53b5 100644
--- a/generate_ndk.cpp
+++ b/generate_ndk.cpp
@@ -1120,6 +1120,13 @@
   }
   GenerateHeaderIncludes(out, types, defined_type);
 
+  // TODO(b/31559095) bionic on host should define this
+  out << "\n";
+  out << "#ifndef __BIONIC__\n";
+  out << "#define __assert2(a,b,c,d) ((void)0)\n";
+  out << "#endif\n";
+  out << "\n";
+
   EnterNdkNamespace(out, defined_type);
   out << cpp::TemplateDecl(defined_type);
   out << "class " << clazz << " {\n";