diff options
author | Douglas Gregor <dgregor@apple.com> | 2013-04-12 00:18:53 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2013-04-12 00:18:53 +0000 |
commit | c9be4734d68954b226aab349a08cdd89053f095a (patch) | |
tree | d6a28e106ada2f0d94b8ba7f37c27dbf4b6a8cf8 /clang/lib/Frontend/CompilerInvocation.cpp | |
parent | ecf132057979bd5e0d005d042ffcf6fcffbcff22 (diff) | |
download | llvm-c9be4734d68954b226aab349a08cdd89053f095a.zip llvm-c9be4734d68954b226aab349a08cdd89053f095a.tar.gz llvm-c9be4734d68954b226aab349a08cdd89053f095a.tar.bz2 |
<rdar://problem/13615607> Include SDK version information in the module hash.
This is a Darwin-SDK-specific hash criteria used to identify a
particular SDK without having to hash the contents of all of its
headers. If other platforms have such versioned files, we should add
those checks here.
llvm-svn: 179346
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r-- | clang/lib/Frontend/CompilerInvocation.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 42774f3..c8ccffa 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -29,6 +29,7 @@ #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/Host.h" #include "llvm/Support/Path.h" +#include "llvm/Support/system_error.h" using namespace clang; //===----------------------------------------------------------------------===// @@ -1696,5 +1697,21 @@ std::string CompilerInvocation::getModuleHash() const { hsOpts.UseStandardCXXIncludes, hsOpts.UseLibcxx); + // Darwin-specific hack: if we have a sysroot, use the contents of + // $sysroot/System/Library/CoreServices/SystemVersion.plist + // as part of the module hash. + if (!hsOpts.Sysroot.empty()) { + llvm::OwningPtr<llvm::MemoryBuffer> buffer; + SmallString<128> systemVersionFile; + systemVersionFile += hsOpts.Sysroot; + llvm::sys::path::append(systemVersionFile, "System"); + llvm::sys::path::append(systemVersionFile, "Library"); + llvm::sys::path::append(systemVersionFile, "CoreServices"); + llvm::sys::path::append(systemVersionFile, "SystemVersion.plist"); + if (!llvm::MemoryBuffer::getFile(systemVersionFile, buffer)) { + code = hash_combine(code, buffer.get()->getBuffer()); + } + } + return llvm::APInt(64, code).toString(36, /*Signed=*/false); } |