]> granicus.if.org Git - clang/commitdiff
Add EmitString helper method
authorKovarththanan Rajaratnam <kovarththanan.rajaratnam@gmail.com>
Sun, 14 Mar 2010 08:35:19 +0000 (08:35 +0000)
committerKovarththanan Rajaratnam <kovarththanan.rajaratnam@gmail.com>
Sun, 14 Mar 2010 08:35:19 +0000 (08:35 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98488 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Frontend/CacheTokens.cpp

index 029010dc1963d3688e2d8ec079f2fc9d80c342f5..3d7f5c0e8525fe2f53565b8e91924bc6136ec140 100644 (file)
@@ -196,6 +196,11 @@ class PTHWriter {
     Out.write(Ptr, NumBytes);
   }
 
+  void EmitString(llvm::StringRef V) {
+    ::Emit16(Out, V.size());
+    EmitBuf(V.data(), V.size());
+  }
+
   /// EmitIdentifierTable - Emits two tables to the PTH file.  The first is
   ///  a hashtable mapping from identifier strings to persistent IDs.
   ///  The second is a straight table mapping from persistent IDs to string data
@@ -447,8 +452,7 @@ void PTHWriter::GeneratePTH(const std::string &MainFile) {
 
   // Write the name of the MainFile.
   if (!MainFile.empty()) {
-    Emit16(MainFile.length());
-    EmitBuf(MainFile.data(), MainFile.length());
+       EmitString(MainFile);
   } else {
     // String with 0 bytes.
     Emit16(0);