versioner: ignore functions that are __INTRODUCED_IN_FUTURE.

Bug: http://b/28178111
Change-Id: I8026181e08ed8f2d59b31a37adcf8b469fb6bdaf
diff --git a/tools/versioner/src/versioner.cpp b/tools/versioner/src/versioner.cpp
index 49cbc9f..91482ed 100644
--- a/tools/versioner/src/versioner.cpp
+++ b/tools/versioner/src/versioner.cpp
@@ -341,17 +341,15 @@
     arch_types[type.arch].insert(type);
   }
 
+  std::set<std::string> completely_unavailable;
+
   for (const auto& outer : declaration_database) {
     const std::string& symbol_name = outer.first;
     const auto& compilations = outer.second;
 
     auto platform_availability_it = symbol_database.find(symbol_name);
     if (platform_availability_it == symbol_database.end()) {
-      // This currently has lots of false positives (__INTRODUCED_IN_FUTURE, __errordecl, functions
-      // that come from crtbegin, etc.). Only print them with verbose, because of this.
-      if (verbose) {
-        printf("%s: not available in any platform\n", symbol_name.c_str());
-      }
+      completely_unavailable.insert(symbol_name);
       continue;
     }
 
@@ -467,6 +465,25 @@
     }
   }
 
+  for (const std::string& symbol_name : completely_unavailable) {
+    // This currently has some false positives (mostly functions that come from crtbegin).
+    // Therefore, only report these declarations when running with verbose for now.
+    if (!verbose) {
+      break;
+    }
+
+    // Check to see if the symbol is tagged with __INTRODUCED_IN_FUTURE.
+    auto symbol_it = declaration_database.find(symbol_name);
+    const Declaration& declaration = symbol_it->second.begin()->second;
+    DeclarationAvailability availability = declaration.locations.begin()->availability;
+    if (availability.introduced >= 10000) {
+      continue;
+    }
+
+    printf("%s: not available in any platform\n", symbol_name.c_str());
+    failed = true;
+  }
+
   return !failed;
 }
 
diff --git a/tools/versioner/tests/future/headers/foo.h b/tools/versioner/tests/future/headers/foo.h
new file mode 100644
index 0000000..b5113f4
--- /dev/null
+++ b/tools/versioner/tests/future/headers/foo.h
@@ -0,0 +1 @@
+int foo() __attribute__((availability(android, introduced = 10000)));
diff --git a/tools/versioner/tests/future/platforms/android-9/arch-arm/symbols/libc.so.functions.txt b/tools/versioner/tests/future/platforms/android-9/arch-arm/symbols/libc.so.functions.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tools/versioner/tests/future/platforms/android-9/arch-arm/symbols/libc.so.functions.txt
diff --git a/tools/versioner/tests/future/run.sh b/tools/versioner/tests/future/run.sh
new file mode 100644
index 0000000..0dea98f
--- /dev/null
+++ b/tools/versioner/tests/future/run.sh
@@ -0,0 +1 @@
+versioner -v headers -p platforms -r arm -a 9
diff --git a/tools/versioner/tests/future_arch/headers/foo.h b/tools/versioner/tests/future_arch/headers/foo.h
new file mode 100644
index 0000000..6740975
--- /dev/null
+++ b/tools/versioner/tests/future_arch/headers/foo.h
@@ -0,0 +1,5 @@
+#if defined(__arm__)
+int foo() __attribute__((availability(android, introduced = 9)));
+#else
+int foo() __attribute__((availability(android, introduced = 10000)));
+#endif
diff --git a/tools/versioner/tests/future_arch/platforms/android-9/arch-arm/symbols/libc.so.functions.txt b/tools/versioner/tests/future_arch/platforms/android-9/arch-arm/symbols/libc.so.functions.txt
new file mode 100644
index 0000000..257cc56
--- /dev/null
+++ b/tools/versioner/tests/future_arch/platforms/android-9/arch-arm/symbols/libc.so.functions.txt
@@ -0,0 +1 @@
+foo
diff --git a/tools/versioner/tests/future_arch/platforms/android-9/arch-x86/symbols/libc.so.functions.txt b/tools/versioner/tests/future_arch/platforms/android-9/arch-x86/symbols/libc.so.functions.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tools/versioner/tests/future_arch/platforms/android-9/arch-x86/symbols/libc.so.functions.txt
diff --git a/tools/versioner/tests/future_arch/run.sh b/tools/versioner/tests/future_arch/run.sh
new file mode 100644
index 0000000..36846da
--- /dev/null
+++ b/tools/versioner/tests/future_arch/run.sh
@@ -0,0 +1 @@
+versioner -v headers -p platforms -r arm -r x86 -a 9