diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-10-05 21:07:28 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-10-05 21:07:28 +0000 |
commit | d54f3a1e58923f82e2b8dcebd80fd63718359663 (patch) | |
tree | ceb7126121379bb3a470a20c55ea6980bd1ac96c /clang/lib/Frontend/PCHReader.cpp | |
parent | 092cd6e624b5348841acbbe64a99e3d4330b785a (diff) | |
download | bcm5719-llvm-d54f3a1e58923f82e2b8dcebd80fd63718359663.tar.gz bcm5719-llvm-d54f3a1e58923f82e2b8dcebd80fd63718359663.zip |
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>.
llvm-svn: 83323
Diffstat (limited to 'clang/lib/Frontend/PCHReader.cpp')
-rw-r--r-- | clang/lib/Frontend/PCHReader.cpp | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/clang/lib/Frontend/PCHReader.cpp b/clang/lib/Frontend/PCHReader.cpp index ead00ee75ff..e61668dd317 100644 --- a/clang/lib/Frontend/PCHReader.cpp +++ b/clang/lib/Frontend/PCHReader.cpp @@ -26,6 +26,7 @@ #include "clang/Basic/SourceManagerInternals.h" #include "clang/Basic/FileManager.h" #include "clang/Basic/TargetInfo.h" +#include "clang/Basic/Version.h" #include "llvm/Bitcode/BitstreamReader.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/MemoryBuffer.h" @@ -1340,9 +1341,7 @@ PCHReader::ReadPCHBlock() { case pch::SOURCE_LOCATION_OFFSETS: SLocOffsets = (const uint32_t *)BlobStart; TotalNumSLocEntries = Record[0]; - SourceMgr.PreallocateSLocEntries(this, - TotalNumSLocEntries, - Record[1]); + SourceMgr.PreallocateSLocEntries(this, TotalNumSLocEntries, Record[1]); break; case pch::SOURCE_LOCATION_PRELOADS: @@ -1377,6 +1376,23 @@ PCHReader::ReadPCHBlock() { Comments = (SourceRange *)BlobStart; NumComments = BlobLen / sizeof(SourceRange); break; + + case pch::SVN_BRANCH_REVISION: { + unsigned CurRevision = getClangSubversionRevision(); + if (Record[0] && CurRevision && Record[0] != CurRevision) { + Diag(Record[0] < CurRevision? diag::warn_pch_version_too_old + : diag::warn_pch_version_too_new); + return IgnorePCH; + } + + const char *CurBranch = getClangSubversionPath(); + if (strncmp(CurBranch, BlobStart, BlobLen)) { + std::string PCHBranch(BlobStart, BlobLen); + Diag(diag::warn_pch_different_branch) << PCHBranch << CurBranch; + return IgnorePCH; + } + break; + } } } Error("premature end of bitstream in PCH file"); |