]> granicus.if.org Git - clang/commitdiff
Switch PTH format from a 7 byte magic number to an 8 byte one, to avoid
authorRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 17 Aug 2012 03:55:43 +0000 (03:55 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 17 Aug 2012 03:55:43 +0000 (03:55 +0000)
misaligned reads throughout the file. Bump PTH format version to 10.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162076 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Lex/PTHManager.h
lib/Frontend/CacheTokens.cpp
lib/Lex/PTHLexer.cpp

index 25a49038a863d9b5a862fb4d1b6c8451c6c69df0..44f9ab39f3216fd8f6abc94bbce34673ae2e4507 100644 (file)
@@ -101,7 +101,7 @@ class PTHManager : public IdentifierInfoLookup {
 
 public:
   // The current PTH version.
-  enum { Version = 9 };
+  enum { Version = 10 };
 
   ~PTHManager();
 
index 58a6b8d19e1413ecb12679c02d0329848d10a916..3e666132dc8ad7b8cdaab6373fffa3e025cee814 100644 (file)
@@ -447,7 +447,7 @@ Offset PTHWriter::EmitCachedSpellings() {
 
 void PTHWriter::GeneratePTH(const std::string &MainFile) {
   // Generate the prologue.
-  Out << "cfe-pth";
+  Out << "cfe-pth" << '\0';
   Emit32(PTHManager::Version);
 
   // Leave 4 words for the prologue.
index f104f9670837fdf15dff72df9d6f8562f0aa3591..67738e907516705f4ba95a986aa404ebcab58c87 100644 (file)
@@ -452,14 +452,14 @@ PTHManager *PTHManager::Create(const std::string &file,
   const unsigned char *BufEnd = (unsigned char*)File->getBufferEnd();
 
   // Check the prologue of the file.
-  if ((BufEnd - BufBeg) < (signed)(sizeof("cfe-pth") + 3 + 4) ||
-      memcmp(BufBeg, "cfe-pth", sizeof("cfe-pth") - 1) != 0) {
+  if ((BufEnd - BufBeg) < (signed)(sizeof("cfe-pth") + 4 + 4) ||
+      memcmp(BufBeg, "cfe-pth", sizeof("cfe-pth")) != 0) {
     Diags.Report(diag::err_invalid_pth_file) << file;
     return 0;
   }
 
   // Read the PTH version.
-  const unsigned char *p = BufBeg + (sizeof("cfe-pth") - 1);
+  const unsigned char *p = BufBeg + (sizeof("cfe-pth"));
   unsigned Version = ReadLE32(p);
 
   if (Version < PTHManager::Version) {