]> granicus.if.org Git - clang/commitdiff
[Modules] Extend Darwin hack to include the modification time of SystemVersion.plist.
authorDouglas Gregor <dgregor@apple.com>
Fri, 10 May 2013 21:54:08 +0000 (21:54 +0000)
committerDouglas Gregor <dgregor@apple.com>
Fri, 10 May 2013 21:54:08 +0000 (21:54 +0000)
Fixes <rdar://problem/13856838>.

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

lib/Frontend/CompilerInvocation.cpp

index 9c8eea10ad72ecee0c225e4d7a48735d39b7ce01..6af36630019a25839d3b838ef910bb0c30d4eda8 100644 (file)
@@ -30,6 +30,7 @@
 #include "llvm/Support/Host.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/system_error.h"
+#include <sys/stat.h>
 using namespace clang;
 
 //===----------------------------------------------------------------------===//
@@ -1689,7 +1690,8 @@ std::string CompilerInvocation::getModuleHash() const {
                       hsOpts.UseStandardCXXIncludes,
                       hsOpts.UseLibcxx);
 
-  // Darwin-specific hack: if we have a sysroot, use the contents of
+  // Darwin-specific hack: if we have a sysroot, use the contents and
+  // modification time of
   //   $sysroot/System/Library/CoreServices/SystemVersion.plist
   // as part of the module hash.
   if (!hsOpts.Sysroot.empty()) {
@@ -1702,6 +1704,10 @@ std::string CompilerInvocation::getModuleHash() const {
     llvm::sys::path::append(systemVersionFile, "SystemVersion.plist");
     if (!llvm::MemoryBuffer::getFile(systemVersionFile, buffer)) {
       code = hash_combine(code, buffer.get()->getBuffer());
+
+      struct stat statBuf;
+      if (stat(systemVersionFile.c_str(), &statBuf) == 0)
+        code = hash_combine(code, statBuf.st_mtime);
     }
   }