Adapt to clang-r383902

This change adapts versioner to llvm::StringRef losing its implicit
conversion to std::string().

Test: ./build-prebuilts.sh
Change-Id: Ie1b290cf12e7044a92545470ce4f968cc55d90c9
diff --git a/tools/versioner/src/DeclarationDatabase.cpp b/tools/versioner/src/DeclarationDatabase.cpp
index 3c6f643..b41c865 100644
--- a/tools/versioner/src/DeclarationDatabase.cpp
+++ b/tools/versioner/src/DeclarationDatabase.cpp
@@ -72,7 +72,7 @@
 
     // <math.h> maps fool onto foo on 32-bit, since long double is the same as double.
     if (auto asm_attr = decl->getAttr<AsmLabelAttr>()) {
-      return asm_attr->getLabel();
+      return asm_attr->getLabel().str();
     }
 
     // The decl might not have a name (e.g. bitfields).
@@ -84,7 +84,7 @@
         return mangled;
       }
 
-      return identifier->getName();
+      return identifier->getName().str();
     }
 
     return "<unnamed>";
@@ -173,7 +173,7 @@
               &arch_availability[Arch::x86_64].introduced } },
         };
 
-        if (auto it = prefix_map.find(fragments[0]); it != prefix_map.end()) {
+        if (auto it = prefix_map.find(fragments[0].str()); it != prefix_map.end()) {
           int value;
           if (fragments[1].getAsInteger(10, value)) {
             errx(1, "invalid __ANDROID_AVAILABILITY_DUMP__ annotation: '%s'",
@@ -201,7 +201,7 @@
     }
 
     Location location = {
-      .filename = filename,
+      .filename = filename.str(),
       .start = {
         .line = src_manager.getExpansionLineNumber(expansion_range.getBegin()),
         .column = src_manager.getExpansionColumnNumber(expansion_range.getBegin()),
diff --git a/tools/versioner/src/Preprocessor.cpp b/tools/versioner/src/Preprocessor.cpp
index 4ee3446..7a5b502 100644
--- a/tools/versioner/src/Preprocessor.cpp
+++ b/tools/versioner/src/Preprocessor.cpp
@@ -446,7 +446,7 @@
       continue;
     }
 
-    std::string rel_path = path.substr(src_dir.length() + 1);
+    std::string rel_path = path.substr(src_dir.length() + 1).str();
     std::string dst_path = dst_dir + "/" + rel_path;
     llvm::StringRef parent_path = llvm::sys::path::parent_path(dst_path);
     if (llvm::sys::fs::create_directories(parent_path)) {
@@ -471,13 +471,13 @@
     GuardMap guard_map;
     for (const auto& it : orig_guard_map) {
       Location loc = it.first;
-      loc.end = findNextSemicolon(file_lines[file_path], loc.end);
+      loc.end = findNextSemicolon(file_lines[file_path.str()], loc.end);
       guard_map[loc] = it.second;
     }
 
     // TODO: Make sure that the Locations don't overlap.
     // TODO: Merge adjacent non-identical guards.
-    mergeGuards(file_lines[file_path], guard_map);
+    mergeGuards(file_lines[file_path.str()], guard_map);
 
     if (!file_path.startswith(src_dir)) {
       errx(1, "input file %s is not in %s\n", file_path.str().c_str(), src_dir.c_str());
@@ -487,7 +487,7 @@
     llvm::StringRef rel_path = file_path.substr(src_dir.size(), file_path.size() - src_dir.size());
     std::string output_path = (llvm::Twine(dst_dir) + rel_path).str();
 
-    rewriteFile(output_path, file_lines[file_path], guard_map);
+    rewriteFile(output_path, file_lines[file_path.str()], guard_map);
   }
 
   return true;