versioner: Add R to codename map

This commit adds "R" to codename map because `libc.map.txt` started
using "introduced=R".

Test: PATH=prebuilts/clang-tools/linux-x86/bin:$PATH \
      ./bionic/tools/versioner/run_tests.py
Bug: 140110040

Change-Id: Ibc1154557c29d9580b5c527160116b24fa4c656f
diff --git a/tools/versioner/src/Arch.h b/tools/versioner/src/Arch.h
index 16fa265..e4bbcc4 100644
--- a/tools/versioner/src/Arch.h
+++ b/tools/versioner/src/Arch.h
@@ -138,7 +138,9 @@
   { Arch::x86_64, "x86_64-linux-android" },
 };
 
-static const std::set<int> default_levels = { 14, 15, 16, 17, 18, 19, 21, 23, 24, 25, 26, 27, 28, 29 };
+static const std::set<int> default_levels = {
+  14, 15, 16, 17, 18, 19, 21, 23, 24, 25, 26, 27, 28, 29, 30,
+};
 
 static const ArchMap<int> arch_min_api = {
   { Arch::arm, 9 },
@@ -165,4 +167,5 @@
   {"O-MR1", 27},
   {"P", 28},
   {"Q", 29},
+  {"R", 30},
 };
diff --git a/tools/versioner/src/SymbolFileParser.cpp b/tools/versioner/src/SymbolFileParser.cpp
index c312b48..1b4adae 100644
--- a/tools/versioner/src/SymbolFileParser.cpp
+++ b/tools/versioner/src/SymbolFileParser.cpp
@@ -266,19 +266,23 @@
     if (!api_level.empty()) {
       // If an api-level tag is specified, it must be an exact match (mainly
       // for versioner unit tests).
-      return compilation_type.api_level == decodeApiLevelValue(api_level);
+      return compilation_type.api_level == parseApiLevelValue(api_level);
     }
 
-    return compilation_type.api_level >= decodeApiLevelValue(intro);
+    return compilation_type.api_level >= parseApiLevelValue(intro);
   }
 
-  // Extract and decode the integer API level from api-level or introduced tags.
-  static int decodeApiLevelValue(const std::string& tag) {
+  // Parse the integer API level from api-level or introduced tags.
+  int parseApiLevelValue(const std::string& tag) const {
     std::string api_level = tag.substr(tag.find('=') + 1);
     auto it = api_codename_map.find(api_level);
     if (it != api_codename_map.end()) {
       return it->second;
     }
+    if (api_level.find_first_not_of("0123456789") != std::string::npos) {
+      errx(1, "%s:%zu: error: unknown API level codename specified: \"%s\"",
+           file_path.c_str(), curr_line_num, tag.c_str());
+    }
     return std::stoi(api_level);
   }