Encode the Clang branch and Subversion revision into a PCH file, and
assume that PCH files from different Clang revisions are not
compatible. Addresses <rdar://problem/7266572>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83323 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Frontend/PCHWriter.cpp b/lib/Frontend/PCHWriter.cpp
index 08a1661..64a678e 100644
--- a/lib/Frontend/PCHWriter.cpp
+++ b/lib/Frontend/PCHWriter.cpp
@@ -394,7 +394,8 @@
   RECORD(STAT_CACHE);
   RECORD(EXT_VECTOR_DECLS);
   RECORD(COMMENT_RANGES);
-
+  RECORD(SVN_BRANCH_REVISION);
+  
   // SourceManager Block.
   BLOCK(SOURCE_MANAGER_BLOCK);
   RECORD(SM_SLOC_FILE_ENTRY);
@@ -564,6 +565,17 @@
     Record.push_back(pch::ORIGINAL_FILE_NAME);
     Stream.EmitRecordWithBlob(FileAbbrevCode, Record, MainFileNameStr);
   }
+  
+  // Subversion branch/version information.
+  BitCodeAbbrev *SvnAbbrev = new BitCodeAbbrev();
+  SvnAbbrev->Add(BitCodeAbbrevOp(pch::SVN_BRANCH_REVISION));
+  SvnAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32)); // SVN revision
+  SvnAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // SVN branch/tag
+  unsigned SvnAbbrevCode = Stream.EmitAbbrev(SvnAbbrev);
+  Record.clear();
+  Record.push_back(pch::SVN_BRANCH_REVISION);
+  Record.push_back(getClangSubversionRevision());
+  Stream.EmitRecordWithBlob(SvnAbbrevCode, Record, getClangSubversionPath());
 }
 
 /// \brief Write the LangOptions structure.